diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2012-08-01 01:36:08 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2012-08-01 01:36:08 (GMT) |
commit | 4b14de8984c550a36d5f29011e7a8e037bef12f3 (patch) | |
tree | 210d3f63b6c82ced0e8e13c2f6c1943928c40123 /test | |
parent | 104cd10cf98ea0e6dcfdfba02db0100eed7bd8cb (diff) | |
parent | 611b809ac42c269cb337a2e20ad0d4363bc6fe91 (diff) | |
download | SCons-4b14de8984c550a36d5f29011e7a8e037bef12f3.zip SCons-4b14de8984c550a36d5f29011e7a8e037bef12f3.tar.gz SCons-4b14de8984c550a36d5f29011e7a8e037bef12f3.tar.bz2 |
Merged in ptomulik/scons, pull request #25: gettext toolset
Diffstat (limited to 'test')
-rw-r--r-- | test/FindSourceFiles.py | 75 | ||||
-rw-r--r-- | test/SWIG/SWIGOUTDIR.py | 2 | ||||
-rw-r--r-- | test/gettext/MOFiles/UserExamples.py | 240 | ||||
-rw-r--r-- | test/gettext/POInit/UserExamples.py | 221 | ||||
-rw-r--r-- | test/gettext/POTUpdate/UserExamples.py | 217 | ||||
-rw-r--r-- | test/gettext/POUpdate/UserExamples.py | 402 | ||||
-rw-r--r-- | test/gettext/Translate/UserExamples.py | 179 | ||||
-rw-r--r-- | test/option/debug-duplicate.py | 134 | ||||
-rw-r--r-- | test/option/debug-prepare.py | 60 |
9 files changed, 1334 insertions, 196 deletions
diff --git a/test/FindSourceFiles.py b/test/FindSourceFiles.py new file mode 100644 index 0000000..b08cbbd --- /dev/null +++ b/test/FindSourceFiles.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test Environment's FindSourceFiles method. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +# Quite complex, but real-life test. +# 0. Setup VariantDir, "var", without duplication. The "src" is source dir. +# 1. Generate souce file var/foo.c from src/foo.c.in. Define program foo. +# 2. Gather all sources necessary to create '.' node and create source +# tarball. We expect 'src/foo.c.in' file within tarbal, and no content +# under 'var' directory. +test.subdir('src') + +test.write('SConstruct', """ +VariantDir(src_dir = 'src', variant_dir = 'var', duplicate = 0) +env = Environment(tools = ['default','textfile','packaging']) +SConscript(['var/SConscript'], exports = 'env') +sources = env.FindSourceFiles('.') +pkg = env.Package( NAME = 'foo', VERSION = '1.0', PACKAGETYPE = 'src_tarbz2', + source = sources ) +Ignore( '.', pkg ) +""") + +test.write('src/SConscript', """ +Import('env') +foo_c = env.Substfile('foo.c.in', SUBST_DICT = {'__A__' : '0' }) +foo = env.Program(foo_c) +""") + +test.write('src/foo.c.in', """ int main() { return __A__;} +""") + +test.run(arguments = 'package') + +test.must_exist('foo-1.0/src/SConscript') +test.must_exist('foo-1.0/src/foo.c.in') +test.must_not_exist('foo-1.0/var/SConscript') +test.must_not_exist('foo-1.0/var/foo.c.in') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/SWIG/SWIGOUTDIR.py b/test/SWIG/SWIGOUTDIR.py index fe5b8a0..10b1575 100644 --- a/test/SWIG/SWIGOUTDIR.py +++ b/test/SWIG/SWIGOUTDIR.py @@ -33,8 +33,6 @@ import TestSCons test = TestSCons.TestSCons() -test = TestSCons.TestSCons() - swig = test.where_is('swig') if not swig: diff --git a/test/gettext/MOFiles/UserExamples.py b/test/gettext/MOFiles/UserExamples.py new file mode 100644 index 0000000..1b78268 --- /dev/null +++ b/test/gettext/MOFiles/UserExamples.py @@ -0,0 +1,240 @@ + +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Make sure, that the examples given in user guide all work. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + +if not test.where_is('msgfmt'): + test.skip_test("Could not find 'msgfmt'; skipping test(s)\n") + +en_po_contents = """\ +# English translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Pawel Tomulik <ptomulik@meil.pw.edu.pl>, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: dummypkg 1.0\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:37+0200\\n" +"Last-Translator: Pawel Tomulik <ptomulik@meil.pw.edu.pl>\\n" +"Language-Team: English\\n" +"Language: en\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "Old message from a.cpp" +""" + +pl_po_contents = """\ +# Polish translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: dummypkg 1.0\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:35+0200\\n" +"Last-Translator: Automatically generated\\n" +"Language-Team: none\\n" +"Language: pl\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "Stara wiadomosc z a.cpp" +""" + +de_po_contents = """\ +# German translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: dummypkg 1.0\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:35+0200\\n" +"Last-Translator: Automatically generated\\n" +"Language-Team: none\\n" +"Language: de\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "" +""" + +fr_po_contents = """\ +# French translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: dummypkg 1.0\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:35+0200\\n" +"Last-Translator: Automatically generated\\n" +"Language-Team: none\\n" +"Language: fr\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "" +""" + +############################################################################# +# MOFiles: Example 1 +############################################################################# +test.subdir(['ex1']) +test.write( ['ex1', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgfmt"] ) +env.MOFiles(['pl', 'en']) +""") +test.write(['ex1', 'en.po'], en_po_contents) +test.write(['ex1', 'pl.po'], pl_po_contents) + +test.run(arguments = '.', chdir = 'ex1') +test.must_exist(['ex1', 'en.mo']) +test.must_exist(['ex1', 'pl.mo']) + + +############################################################################# +# MOFiles: Example 2 +############################################################################# +test.subdir(['ex2']) +test.write( ['ex2', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgfmt"] ) +env.MOFiles(LINGUAS_FILE = 1) +""") +# +test.write(['ex2', 'LINGUAS'], +""" +en +pl +""") +# +test.write(['ex2', 'en.po'], en_po_contents) +test.write(['ex2', 'pl.po'], pl_po_contents) + +test.run(arguments = '.', chdir = 'ex2') +test.must_exist(['ex2', 'en.mo']) +test.must_exist(['ex2', 'pl.mo']) + + +############################################################################# +# MOFiles: Example 3 +############################################################################# +test.subdir(['ex3']) +test.write( ['ex3', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgfmt"] ) +env.MOFiles(['en', 'pl'], LINGUAS_FILE = 1) +""") +test.write(['ex3', 'LINGUAS'], +""" +de +fr +""") +# +test.write(['ex3', 'en.po'], en_po_contents) +test.write(['ex3', 'pl.po'], pl_po_contents) +test.write(['ex3', 'de.po'], de_po_contents) +test.write(['ex3', 'fr.po'], fr_po_contents) + +test.run(arguments = '.', chdir = 'ex3') +test.must_exist(['ex3', 'en.mo']) +test.must_exist(['ex3', 'pl.mo']) +test.must_exist(['ex3', 'de.mo']) +test.must_exist(['ex3', 'fr.mo']) + + +############################################################################# +# MOFiles: Example 4 +############################################################################# +test.subdir(['ex4']) +test.write( ['ex4', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgfmt"] ) +env['LINGUAS_FILE'] = 1 +env.MOFiles() +""") + +test.write(['ex4', 'LINGUAS'], +""" +en +pl +""") + +test.write(['ex4', 'en.po'], en_po_contents) +test.write(['ex4', 'pl.po'], pl_po_contents) + +test.run(arguments = '.', chdir = 'ex4') +test.must_exist(['ex4', 'en.mo']) +test.must_exist(['ex4', 'pl.mo']) + +test.pass_test() + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/gettext/POInit/UserExamples.py b/test/gettext/POInit/UserExamples.py new file mode 100644 index 0000000..a498a53 --- /dev/null +++ b/test/gettext/POInit/UserExamples.py @@ -0,0 +1,221 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Make sure, that the examples given in user guide all work. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +if not test.where_is('msginit'): + test.skip_test("Could not find 'msginit'; skipping test(s)\n") + +pot_contents = """\ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" +"Language-Team: LANGUAGE <LL@li.org>\\n" +"Language: \\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=CHARSET\\n" +"Content-Transfer-Encoding: 8bit\\n" +# +#: a.cpp:1 +msgid "Hello from a.cpp" +msgstr "" +""" + +############################################################################### +# POInit: Example 1 +############################################################################### +test.subdir(['ex1']) +test.write( ['ex1', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit"] ) +env['POAUTOINIT'] = 1 +env.POInit(['en','pl']) # messages.pot --> [en.po, pl.po] +""") +# +test.write(['ex1', 'messages.pot'], pot_contents) + +# NOTE: msginit(1) prints all its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-create', chdir = 'ex1', stderr = None) +test.must_exist( ['ex1', 'en.po'] ) +test.must_exist( ['ex1', 'pl.po'] ) +test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp") +test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp") + + +############################################################################### +# POInit: Example 2 +############################################################################### +test.subdir(['ex2']) +test.write( ['ex2', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit"] ) +env['POAUTOINIT'] = 1 +env.POInit(['en','pl'], ['foo']) # foo.pot --> [en.po, pl.po] +""") +# +test.write(['ex2', 'foo.pot'], pot_contents) + +# NOTE: msginit(1) prints all its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-create', chdir = 'ex2', stderr = None) +test.must_exist( ['ex2', 'en.po'] ) +test.must_exist( ['ex2', 'pl.po'] ) +test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp" ) + +############################################################################### +# POInit: Example 3 +############################################################################### +test.subdir(['ex3']) +test.write( ['ex3', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit"] ) +env['POAUTOINIT'] = 1 +env.POInit(['en','pl'], POTDOMAIN='foo') # foo.pot --> [en.po, pl.po] +""") +# +test.write(['ex3', 'foo.pot'], pot_contents) + +# NOTE: msginit(1) prints all its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-create', chdir = 'ex3', stderr = None) +test.must_exist( ['ex3', 'en.po'] ) +test.must_exist( ['ex3', 'pl.po'] ) +test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp") +test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp") + +############################################################################### +# POInit: Example 4 +############################################################################### +test.subdir(['ex4']) +test.write( ['ex4', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit"] ) +env['POAUTOINIT'] = 1 +env.POInit(LINGUAS_FILE = 1) # needs 'LINGUAS' file +""") +test.write(['ex4', 'LINGUAS'],""" +en +pl +""") +# +test.write(['ex4', 'messages.pot'], pot_contents) + +# NOTE: msginit(1) prints all its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-create', chdir = 'ex4', stderr = None) +test.must_exist( ['ex4', 'en.po'] ) +test.must_exist( ['ex4', 'pl.po'] ) +test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp") +test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp") + +############################################################################### +# POInit: Example 5 +############################################################################### +test.subdir(['ex5']) +test.write( ['ex5', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit"] ) +env['POAUTOINIT'] = 1 +env.POInit(['en', 'pl'], LINGUAS_FILE = 1) # needs 'LINGUAS' file +""") +test.write(['ex5', 'LINGUAS'],""" +de +fr +""") +# +test.write(['ex5', 'messages.pot'], pot_contents) + +# NOTE: msginit(1) prints all its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-create', chdir = 'ex5', stderr = None) +test.must_exist( ['ex5', 'en.po'] ) +test.must_exist( ['ex5', 'pl.po'] ) +test.must_exist( ['ex5', 'de.po'] ) +test.must_exist( ['ex5', 'fr.po'] ) +test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp") +test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp") +test.must_contain( ['ex5', 'de.po'], "Hello from a.cpp") +test.must_contain( ['ex5', 'fr.po'], "Hello from a.cpp") + +############################################################################### +# POInit: Example 6 +############################################################################### +test.subdir(['ex6']) +test.write( ['ex6', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit"] ) +env['POAUTOINIT'] = 1 +env['LINGUAS_FILE'] = 1 +env['POTDOMAIN'] = 'foo' +env.POInit() +""") +test.write(['ex6', 'LINGUAS'],""" +en +pl +""") +# +test.write(['ex6', 'foo.pot'], pot_contents) + +# NOTE: msginit(1) prints all its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-create', chdir = 'ex6', stderr = None) +test.must_exist( ['ex6', 'en.po'] ) +test.must_exist( ['ex6', 'pl.po'] ) +test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp") +test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp") + +test.pass_test() + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/gettext/POTUpdate/UserExamples.py b/test/gettext/POTUpdate/UserExamples.py new file mode 100644 index 0000000..3c1f298 --- /dev/null +++ b/test/gettext/POTUpdate/UserExamples.py @@ -0,0 +1,217 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +End-to-end tests for POTUpdate. Assure, taht the examples from user's +documentation all work. +""" + +import TestSCons +from os import path + +test = TestSCons.TestSCons() + +if not test.where_is('xgettext'): + test.skip_test("Could not find 'xgettext', skipping test(s).\n") + +############################################################################# +# POTUpdate: Example 1 +############################################################################# +test.subdir(['ex1']) +test.subdir(['ex1', 'po']) +test.write( ['ex1', 'po', 'SConstruct' ], +""" +env = Environment( tools = ['default', 'xgettext'] ) +env.POTUpdate(['foo'], ['../a.cpp', '../b.cpp']) +env.POTUpdate(['bar'], ['../c.cpp', '../d.cpp']) +""") +test.write(['ex1', 'a.cpp'], """ gettext("Hello from a.cpp") """) +test.write(['ex1', 'b.cpp'], """ gettext("Hello from b.cpp") """) +test.write(['ex1', 'c.cpp'], """ gettext("Hello from c.cpp") """) +test.write(['ex1', 'd.cpp'], """ gettext("Hello from d.cpp") """) + +# scons '.' does not create foo.pot nor bar.pot +test.run(arguments = '.', chdir = path.join('ex1', 'po')) +test.must_not_exist( ['ex1', 'po', 'foo.pot'] ) +test.must_not_exist( ['ex1', 'po', 'bar.pot'] ) + +# scons 'foo.pot' creates foo.pot +test.run(arguments = 'foo.pot', chdir = path.join('ex1', 'po')) +test.must_exist( ['ex1', 'po', 'foo.pot'] ) +test.must_not_exist( ['ex1', 'po', 'bar.pot'] ) +test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from a.cpp" ) +test.must_contain( ['ex1', 'po', 'foo.pot'], "Hello from b.cpp" ) +test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from c.cpp" ) +test.must_not_contain( ['ex1', 'po', 'foo.pot'], "Hello from d.cpp" ) + +# scons 'pot-update' creates foo.pot and bar.pot +test.run(arguments = 'pot-update', chdir = path.join('ex1', 'po')) +test.must_exist( ['ex1', 'po', 'foo.pot'] ) +test.must_exist( ['ex1', 'po', 'bar.pot'] ) +test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from a.cpp" ) +test.must_not_contain( ['ex1', 'po', 'bar.pot'], "Hello from b.cpp" ) +test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from c.cpp" ) +test.must_contain( ['ex1', 'po', 'bar.pot'], "Hello from d.cpp" ) + +# scons -c does not clean anything +test.run(arguments = '-c', chdir = path.join('ex1', 'po')) +test.must_exist( ['ex1', 'po', 'foo.pot'] ) +test.must_exist( ['ex1', 'po', 'bar.pot'] ) + + +############################################################################# +# POTUpdate: Example 2 +############################################################################# +test.subdir(['ex2']) +test.write( ['ex2', 'SConstruct'], +""" +env = Environment( tools = ['default', 'xgettext'] ) +env['POTDOMAIN'] = "foo" +env.POTUpdate(source = ["a.cpp", "b.cpp"]) # Creates foo.pot ... +env.POTUpdate(POTDOMAIN = "bar", source = ["c.cpp", "d.cpp"]) # and bar.pot +""") +test.write(['ex2', 'a.cpp'], """ gettext("Hello from a.cpp") """) +test.write(['ex2', 'b.cpp'], """ gettext("Hello from b.cpp") """) +test.write(['ex2', 'c.cpp'], """ gettext("Hello from c.cpp") """) +test.write(['ex2', 'd.cpp'], """ gettext("Hello from d.cpp") """) + +test.run(arguments = 'pot-update', chdir = path.join('ex2')) + +test.must_exist( ['ex2', 'foo.pot']) +test.must_contain( ['ex2', 'foo.pot'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'foo.pot'], "Hello from b.cpp" ) +test.must_not_contain( ['ex2', 'foo.pot'], "Hello from c.cpp" ) +test.must_not_contain( ['ex2', 'foo.pot'], "Hello from d.cpp" ) + +test.must_exist( ['ex2', 'bar.pot']) +test.must_not_contain( ['ex2', 'bar.pot'], "Hello from a.cpp" ) +test.must_not_contain( ['ex2', 'bar.pot'], "Hello from b.cpp" ) +test.must_contain( ['ex2', 'bar.pot'], "Hello from c.cpp" ) +test.must_contain( ['ex2', 'bar.pot'], "Hello from d.cpp" ) + + +############################################################################# +# POTUpdate: Example 3 +############################################################################# +test.subdir(['ex3']) +test.subdir(['ex3', 'po']) +test.write( ['ex3', 'po', 'SConstruct'], +""" +# SConstruct file in 'po/' subdirectory +env = Environment( tools = ['default', 'xgettext'] ) +env.POTUpdate(XGETTEXTFROM = 'POTFILES.in') +""") +test.write( ['ex3', 'po', 'POTFILES.in'], +""" +# POTFILES.in in 'po/' subdirectory +../a.cpp +../b.cpp +# end of file +""") +test.write(['ex3', 'a.cpp'], """ gettext("Hello from a.cpp") """) +test.write(['ex3', 'b.cpp'], """ gettext("Hello from b.cpp") """) + +# scons 'pot-update' creates messages.pot +test.run(arguments = 'pot-update', chdir = path.join('ex3', 'po')) +test.must_exist(['ex3', 'po', 'messages.pot']) + + +############################################################################# +# POTUpdate: Example 4 +############################################################################# +test.subdir(['ex4']) +test.subdir(['ex4', 'po']) +test.write( ['ex4', 'po', 'SConstruct'], +""" +# SConstruct file in 'po/' subdirectory +env = Environment( tools = ['default', 'xgettext'] ) +env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH='../') +""") +test.write(['ex4', 'po', 'POTFILES.in'], +""" +# POTFILES.in in 'po/' subdirectory +a.cpp +b.cpp +# end of file +""") +test.write(['ex4', 'a.cpp'], """ gettext("Hello from a.cpp") """) +test.write(['ex4', 'b.cpp'], """ gettext("Hello from b.cpp") """) + +# scons 'pot-update' creates messages.pot +test.run(arguments = 'pot-update', chdir = path.join('ex4', 'po')) +test.must_exist(['ex4', 'po', 'messages.pot']) + + + +############################################################################# +# POTUpdate: Example 5 +############################################################################# +test.subdir(['ex5']) +test.subdir(['ex5', '0']) +test.subdir(['ex5', '0','1']) +test.subdir(['ex5', '0', '1', 'po']) +test.write( ['ex5', '0', '1', 'po', 'SConstruct'], +""" +# SConstruct file in '0/1/po/' subdirectory +env = Environment( tools = ['default', 'xgettext'] ) +env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../', '../../']) +""") +test.write( ['ex5', '0', '1', 'po', 'POTFILES.in'], +""" +# POTFILES.in in '0/1/po/' subdirectory +a.cpp +# end of file +""") +test.write(['ex5', '0', 'a.cpp'], """ gettext("Hello from ../../a.cpp") """) +test.write(['ex5', '0', '1', 'a.cpp'], """ gettext("Hello from ../a.cpp") """) + +# scons 'pot-update' creates messages.pot +test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) +test.must_exist( ['ex5', '0', '1', 'po', 'messages.pot']) +test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], + 'Hello from ../a.cpp' ) +test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], + 'Hello from ../../a.cpp' ) + +test.write(['ex5', '0', '1', 'po', 'SConstruct'], +""" +# SConstruct file in '0/1/po/' subdirectory +env = Environment( tools = ['default', 'xgettext'] ) +env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../../', '../']) +""") +test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) +test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], + 'Hello from ../../a.cpp' ) +test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], + 'Hello from ../a.cpp') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/gettext/POUpdate/UserExamples.py b/test/gettext/POUpdate/UserExamples.py new file mode 100644 index 0000000..01d3706 --- /dev/null +++ b/test/gettext/POUpdate/UserExamples.py @@ -0,0 +1,402 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Make sure, that the examples given in user guide all work. +""" + +import TestSCons +import os + +test = TestSCons.TestSCons() + + +if not test.where_is('msgmerge'): + test.skip_test("Could not find 'msgmerge'; skipping test(s)\n") + +pot_contents = """\ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" +"Language-Team: LANGUAGE <LL@li.org>\\n" +"Language: \\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=CHARSET\\n" +"Content-Transfer-Encoding: 8bit\\n" +# +#: a.cpp:1 +msgid "Hello from a.cpp" +msgstr "" +""" + +en_po_contents = """\ +# English translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Pawel Tomulik <ptomulik@meil.pw.edu.pl>, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:37+0200\\n" +"Last-Translator: Pawel Tomulik <ptomulik@meil.pw.edu.pl>\\n" +"Language-Team: English\\n" +"Language: en\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "Old message from a.cpp" +""" + +pl_po_contents = """\ +# Polish translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:35+0200\\n" +"Last-Translator: Automatically generated\\n" +"Language-Team: none\\n" +"Language: pl\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "Stara wiadomosc z a.cpp" +""" + +de_po_contents = """\ +# German translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:35+0200\\n" +"Last-Translator: Automatically generated\\n" +"Language-Team: none\\n" +"Language: de\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "EINE ALTE Nachricht vom a.cpp" +""" + +fr_po_contents = """\ +# French translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\\n" +"Report-Msgid-Bugs-To: \\n" +"POT-Creation-Date: 2012-05-27 00:35+0200\\n" +"PO-Revision-Date: 2012-05-27 00:35+0200\\n" +"Last-Translator: Automatically generated\\n" +"Language-Team: none\\n" +"Language: fr\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=ASCII\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\\n" + +#: a.cpp:1 +msgid "Old message from a.cpp" +msgstr "Un ancien message du a.cpp" +""" + +############################################################################# +# POUpdate: Example 1 +############################################################################# +test.subdir(['ex1']) +test.write( ['ex1', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgmerge"] ) +env.POUpdate(['en','pl']) # messages.pot --> [en.po, pl.po] +""") +test.write(['ex1', 'messages.pot'], pot_contents) +test.write(['ex1', 'en.po'], en_po_contents) +test.write(['ex1', 'pl.po'], pl_po_contents) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex1', stderr = None) +test.must_exist( ['ex1', 'en.po'] ) +test.must_exist( ['ex1', 'pl.po'] ) +test.must_contain( ['ex1', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex1', 'pl.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 2 +############################################################################# +test.subdir(['ex2']) +test.write( ['ex2', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgmerge"] ) +env.POUpdate(['en','pl'], ['foo']) # foo.pot --> [en.po, pl.po] +""") +# +test.write(['ex2', 'foo.pot'], pot_contents) +test.write(['ex2', 'en.po'], en_po_contents) +test.write(['ex2', 'pl.po'], pl_po_contents) + +# NOTE: msgmerge(1) prints all messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex2', stderr = None) +test.must_exist( ['ex2', 'en.po'] ) +test.must_exist( ['ex2', 'pl.po'] ) +test.must_contain( ['ex2', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'pl.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 3 +############################################################################# +test.subdir(['ex3']) +test.write( ['ex3', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgmerge"] ) +env.POUpdate(['en','pl'], POTDOMAIN='foo') # foo.pot --> [en.po, pl.po] +""") +# +test.write(['ex3', 'foo.pot'], pot_contents) +test.write(['ex3', 'en.po'], en_po_contents) +test.write(['ex3', 'pl.po'], pl_po_contents) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex3', stderr = None) +test.must_exist( ['ex3', 'en.po'] ) +test.must_exist( ['ex3', 'pl.po'] ) +test.must_contain( ['ex3', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex3', 'pl.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 4 +############################################################################# +test.subdir(['ex4']) +test.write( ['ex4', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgmerge"] ) +env.POUpdate(LINGUAS_FILE = 1) # needs 'LINGUAS' file +""") +# +test.write(['ex4', 'LINGUAS'], +""" +en +pl +""") +# +test.write(['ex4', 'messages.pot'], pot_contents) +test.write(['ex4', 'en.po'], en_po_contents) +test.write(['ex4', 'pl.po'], pl_po_contents) + +# NOTE: msgmerge(1) prints all messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex4', stderr = None) +test.must_exist( ['ex4', 'messages.pot'] ) +test.must_exist( ['ex4', 'en.po'] ) +test.must_exist( ['ex4', 'pl.po'] ) +test.must_contain( ['ex4', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex4', 'pl.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 5 +############################################################################# +test.subdir(['ex5']) +test.write( ['ex5', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgmerge"] ) +env.POUpdate(LINGUAS_FILE = 1, source = ['foo']) +""") +test.write(['ex5', 'LINGUAS'], +""" +en +pl +""") +# +test.write(['ex5', 'foo.pot'], pot_contents) +test.write(['ex5', 'en.po'], en_po_contents) +test.write(['ex5', 'pl.po'], pl_po_contents) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir= 'ex5', stderr = None) +test.must_exist( ['ex5', 'en.po'] ) +test.must_exist( ['ex5', 'pl.po'] ) +test.must_contain( ['ex5', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex5', 'pl.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 6 +############################################################################# +test.subdir(['ex6']) +test.write( ['ex6', 'SConstruct'], +""" +env = Environment( tools = ["default", "msgmerge"] ) +env.POUpdate(['en', 'pl'], LINGUAS_FILE = 1) +""") +test.write(['ex6', 'LINGUAS'], +""" +de +fr +""") +test.write(['ex6', 'messages.pot'], pot_contents) +test.write(['ex6', 'en.po'], en_po_contents) +test.write(['ex6', 'pl.po'], pl_po_contents) +test.write(['ex6', 'de.po'], de_po_contents) +test.write(['ex6', 'fr.po'], fr_po_contents) + +# Note: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex6', stderr = None) +test.must_exist( ['ex6', 'en.po'] ) +test.must_exist( ['ex6', 'pl.po'] ) +test.must_exist( ['ex6', 'de.po'] ) +test.must_exist( ['ex6', 'fr.po'] ) +test.must_contain( ['ex6', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex6', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex6', 'de.po'], "Hello from a.cpp" ) +test.must_contain( ['ex6', 'fr.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 7 +############################################################################# +# +# From this poin we need msginit +# +if not test.where_is('msginit'): + test.skip_test("could not find 'msginit'; skipping test(s)\n") +### +test.subdir(['ex7']) +test.write( ['ex7', 'SConstruct'], +""" +env = Environment( tools = ["default", "msginit", "msgmerge"] ) +env.POUpdate(LINGUAS_FILE = 1, POAUTOINIT = 1) +""") +test.write(['ex7', 'LINGUAS'], +""" +en +pl +""") +# +test.write(['ex7', 'messages.pot'], pot_contents) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir= 'ex7', stderr = None) +test.must_exist( ['ex7', 'en.po'] ) +test.must_exist( ['ex7', 'pl.po'] ) +test.must_contain( ['ex7', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex7', 'pl.po'], "Hello from a.cpp" ) + +############################################################################# +# POUpdate: Example 8 +############################################################################# +# +# From this point we need xgettext +# +if not test.where_is('xgettext'): + test.skip_test("could not find 'xgettext'; skipping test(s)\n") +### +test.subdir(['ex8']) +test.write( ['ex8', 'SConstruct'], +""" +env = Environment( tools = ["default", "xgettext", "msginit", "msgmerge"] ) + +# script-wise settings +env['POAUTOINIT'] = 1 +env['LINGUAS_FILE'] = 1 +env['POTDOMAIN'] = 'foo' +env.POTUpdate(source = 'a.cpp') +env.POUpdate() +""") +test.write(['ex8', 'LINGUAS'], +""" +en +pl +""") +test.write(['ex8', 'a.cpp'], """ gettext("Hello from a.cpp") """) + +# Note: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex8', stderr = None) +test.must_exist( ['ex8', 'foo.pot'] ) +test.must_exist( ['ex8', 'en.po'] ) +test.must_exist( ['ex8', 'pl.po'] ) +test.must_contain( ['ex8', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex8', 'pl.po'], "Hello from a.cpp" ) + +test.pass_test() + + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/gettext/Translate/UserExamples.py b/test/gettext/Translate/UserExamples.py new file mode 100644 index 0000000..b2e6a59 --- /dev/null +++ b/test/gettext/Translate/UserExamples.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +XXX Put a description of the test here. +""" + +import TestSCons +from os import path + +test = TestSCons.TestSCons() + +if not test.where_is('xgettext'): + test.skip_test("could not find 'xgettext'; skipping test(s)\n") +if not test.where_is('msgmerge'): + test.skip_test("Could not find 'msgmerge'; skipping test(s)\n") +if not test.where_is('msginit'): + test.skip_test("could not find 'msginit'; skipping test(s)\n") +if not test.where_is('msgfmt'): + # We really don't use it until the Example 3, but we load "gettext" tool, + # which depends on msgfmt. + test.skip_test("could not find 'msgfmt'; skipping test(s)\n") + + +############################################################################# +# Translate: Example 1 +############################################################################# +test.subdir(['ex1']) +test.subdir(['ex1', 'po']) +test.write( ['ex1', 'po', 'SConstruct'], +""" +env = Environment( tools = ["default", "gettext"] ) +env['POAUTOINIT'] = 1 +env.Translate(['en','pl'], ['../a.cpp', '../b.cpp']) +""") +test.write(['ex1', 'a.cpp'], """ gettext("Hello from a.cpp") """ ) +test.write(['ex1', 'b.cpp'], """ gettext("Hello from b.cpp") """) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = path.join('ex1','po'), stderr = None) +test.must_exist( ['ex1', 'po', 'en.po'] ) +test.must_exist( ['ex1', 'po', 'pl.po'] ) +test.must_contain( ['ex1', 'po', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex1', 'po', 'en.po'], "Hello from b.cpp" ) +test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex1', 'po', 'pl.po'], "Hello from b.cpp" ) + +############################################################################# +# Translate: Example 2 +############################################################################# +test.subdir(['ex2']) +test.subdir(['ex2', 'po']) +test.write( ['ex2', 'po', 'SConstruct'], +""" +env = Environment( tools = ["default", "gettext"] ) +env['POAUTOINIT'] = 1 +env['XGETTEXTPATH'] = ['../'] +env.Translate(LINGUAS_FILE = 1, XGETTEXTFROM = 'POTFILES.in') +""") +test.write(['ex2', 'po', 'LINGUAS'], """ +# LINGUAS +en pl +#end""") +test.write(['ex2', 'po', 'POTFILES.in'], """ +# POTFILES.in +a.cpp +b.cpp +# end""") +test.write(['ex2', 'a.cpp'], """ gettext("Hello from a.cpp") """ ) +test.write(['ex2', 'b.cpp'], """ gettext("Hello from b.cpp") """) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = path.join('ex2','po'), stderr = None) +test.must_exist( ['ex2', 'po', 'en.po'] ) +test.must_exist( ['ex2', 'po', 'pl.po'] ) +test.must_contain( ['ex2', 'po', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'po', 'en.po'], "Hello from b.cpp" ) +test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex2', 'po', 'pl.po'], "Hello from b.cpp" ) + +############################################################################# +# Translate: Example 3 +############################################################################# +test.subdir(['ex3']) +test.subdir(['ex3', 'build']) +test.subdir(['ex3', 'src']) +test.subdir(['ex3', 'src', 'po']) +test.write( ['ex3', 'Sconstruct'], +""" +# SConstruct +env = Environment( tools = ["default", "gettext"] ) +VariantDir('build', 'src', duplicate = 0) +env['POAUTOINIT'] = 1 +SConscript('src/po/SConscript.i18n', exports = 'env') +SConscript('build/po/SConscript', exports = 'env') +""") +test.write( ['ex3', 'src', 'po', 'SConscript.i18n'], +""" +# src/po/SConscript.i18n +Import('env') +env.Translate(LINGUAS_FILE=1, XGETTEXTFROM='POTFILES.in', XGETTEXTPATH=['../']) +""") +test.write( ['ex3', 'src', 'po', 'SConscript'], +""" +# src/po/SConscript +Import('env') +env.MOFiles(LINGUAS_FILE = 1) +""") +test.write(['ex3', 'src', 'po', 'LINGUAS'], """ +# LINGUAS +en pl +#end""") +test.write(['ex3', 'src', 'po', 'POTFILES.in'], """ +# POTFILES.in +a.cpp +b.cpp +# end""") +test.write(['ex3', 'src', 'a.cpp'], """ gettext("Hello from a.cpp") """ ) +test.write(['ex3', 'src', 'b.cpp'], """ gettext("Hello from b.cpp") """) + +# NOTE: msgmerge(1) prints its messages to stderr, we must ignore them, +# So, stderr=None is crucial here. It is no point to match stderr to some +# specific valuse; the messages are internationalized :) ). +test.run(arguments = 'po-update', chdir = 'ex3', stderr = None) +test.must_exist( ['ex3', 'src', 'po', 'messages.pot'] ) +test.must_exist( ['ex3', 'src', 'po', 'en.po'] ) +test.must_exist( ['ex3', 'src', 'po', 'pl.po'] ) +# +test.must_not_exist( ['ex3', 'build', 'po', 'messages.pot'] ) +test.must_not_exist( ['ex3', 'build', 'po', 'en.po'] ) +test.must_not_exist( ['ex3', 'build', 'po', 'pl.po'] ) +# +test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from a.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'messages.pot'], "Hello from b.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from a.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'en.po'], "Hello from b.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from a.cpp" ) +test.must_contain( ['ex3', 'src', 'po', 'pl.po'], "Hello from b.cpp" ) + +test.run(arguments = '.', chdir = 'ex3', stderr = None) +test.must_exist( ['ex3', 'build', 'po', 'en.mo'] ) +test.must_exist( ['ex3', 'build', 'po', 'pl.mo'] ) +test.must_not_exist( ['ex3', 'src', 'po', 'en.mo'] ) +test.must_not_exist( ['ex3', 'src', 'po', 'pl.mo'] ) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/option/debug-duplicate.py b/test/option/debug-duplicate.py index e46a535..df2723e 100644 --- a/test/option/debug-duplicate.py +++ b/test/option/debug-duplicate.py @@ -65,137 +65,3 @@ test.pass_test() # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.subdir('sub1') - -test.write('SConstruct', """\ -env=Environment() -Export('env') -env.SConscript('SConscript', variant_dir='Build') -""") - -test.write('SConscript', """\ -Import('env') -env.Command('foo.out', 'SConscript', Copy('$TARGET', '$SOURCE')) -""") - -test.run(arguments = "--debug=duplicate -Q", - stdout='.*relinking variant.*', match=TestSCons.match_re_dotall) - -test.must_exist('Build/foo.out') - -test.write('SConscript', """\ -# different this time! -Import('env') -env.Command('foo.out', 'SConscript', Copy('$TARGET', '$SOURCE')) -""") - -test.run(arguments = "--debug=duplicate -Q", - stdout='.*relinking variant.*removing existing target.*', - match=TestSCons.match_re_dotall) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.subdir('sub1') - -test.write('SConstruct', """\ -env=Environment() -Export('env') -env.SConscript('SConscript', variant_dir='Build') -""") - -test.write('SConscript', """\ -Import('env') -env.Command('foo.out', 'SConscript', Copy('$TARGET', '$SOURCE')) -""") - -test.run(arguments = "--debug=duplicate -Q", - stdout='.*relinking variant.*', match=TestSCons.match_re_dotall) - -test.must_exist('Build/foo.out') - -test.write('SConscript', """\ -# different this time! -Import('env') -env.Command('foo.out', 'SConscript', Copy('$TARGET', '$SOURCE')) -""") - -test.run(arguments = "--debug=duplicate -Q", - stdout='.*relinking variant.*removing existing target.*', - match=TestSCons.match_re_dotall) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/option/debug-prepare.py b/test/option/debug-prepare.py index a29f431..350c352 100644 --- a/test/option/debug-prepare.py +++ b/test/option/debug-prepare.py @@ -58,63 +58,3 @@ test.pass_test() # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4: -#!/usr/bin/env python -# -# __COPYRIGHT__ -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -env=Environment() -dest=env.Command('foo.out', 'SConstruct', - [Copy('$TARGET', '$SOURCE'), - Copy('${TARGET}.extra', '$SOURCE')]) -env.SideEffect('foo.out.extra', dest) -""") - -expect = """\ -Preparing target foo.out... -...with side-effect foo.out.extra... -...Preparing side-effect foo.out.extra... -Copy("foo.out", "SConstruct") -Copy("foo.out.extra", "SConstruct") -Preparing target .... -""" - -test.run(arguments = "--debug=prepare", stdout=test.wrap_stdout(expect)) - -test.must_exist('foo.out') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: |