diff options
| author | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
|---|---|---|
| committer | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
| commit | 0941093e0e5a030faa49968457638a3a6aee7ad8 (patch) | |
| tree | 6d33513c14eb6eac0531dd050de0ecca4c39bd79 /test/Glob | |
| download | SCons-2.4.0.zip SCons-2.4.0.tar.gz SCons-2.4.0.tar.bz2 | |
release 2.4.02.4.0
Diffstat (limited to 'test/Glob')
| -rw-r--r-- | test/Glob/Repository.py | 126 | ||||
| -rw-r--r-- | test/Glob/VariantDir.py | 75 | ||||
| -rw-r--r-- | test/Glob/basic.py | 63 | ||||
| -rw-r--r-- | test/Glob/exclude.py | 86 | ||||
| -rw-r--r-- | test/Glob/glob-libpath.py | 92 | ||||
| -rw-r--r-- | test/Glob/source.py | 92 | ||||
| -rw-r--r-- | test/Glob/strings.py | 76 | ||||
| -rw-r--r-- | test/Glob/subdir.py | 64 | ||||
| -rw-r--r-- | test/Glob/subst.py | 64 |
9 files changed, 738 insertions, 0 deletions
diff --git a/test/Glob/Repository.py b/test/Glob/Repository.py new file mode 100644 index 0000000..22a7f88 --- /dev/null +++ b/test/Glob/Repository.py @@ -0,0 +1,126 @@ +#!/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__" + +""" +Verify that the Glob() function finds files in repositories. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('work', + 'repository', + ['repository', 'src'], + ['repository', 'src', 'sub1'], + ['repository', 'src', 'sub2']) + +work_aaa = test.workpath('work', 'aaa') +work_bbb = test.workpath('work', 'bbb') +work_ccc = test.workpath('work', 'ccc') +work_src_xxx = test.workpath('work', 'src', 'xxx') +work_src_yyy = test.workpath('work', 'src', 'yyy') + +opts = "-Y " + test.workpath('repository') + +test.write(['repository', 'SConstruct'], """\ +def cat(env, source, target): + target = str(target[0]) + f = open(target, "wb") + for src in source: + f.write(open(str(src), "rb").read()) + f.close() + +# Verify that we can glob a repository-only Node that exists +# only in memory, not on disk. +File('../repository/mmm.in') +m = Glob('m*.in') +assert str(m[0]) == 'mmm.in' + +env = Environment(BUILDERS={'Build':Builder(action=cat)}) +env.Build('aaa.out', Glob('a*.in')) +env.Build('bbb.out', Glob('b*.in')) +env.Build('ccc.out', Glob('c*.in')) +SConscript('src/SConscript', "env") +""") + +test.write(['repository', 'aaa.in'], "repository/aaa.in\n") +test.write(['repository', 'bbb.in'], "repository/bbb.in\n") +test.write(['repository', 'ccc.in'], "repository/ccc.in\n") + +test.write(['repository', 'src', 'SConscript'], """ +Import("env") +env.Build('xxx.out', Glob('x*.in')) +env.Build('yyy.out', Glob('yy?.in')) +env.Build('zzz.out', sorted(Glob('*/zzz.in'), key=lambda t: t.get_abspath())) +""") + +test.write(['repository', 'src', 'xxx.in'], "repository/src/xxx.in\n") +test.write(['repository', 'src', 'yyy.in'], "repository/src/yyy.in\n") +test.write(['repository', 'src', 'sub1', 'zzz.in'], "repository/src/sub1/zzz.in\n") +test.write(['repository', 'src', 'sub2', 'zzz.in'], "repository/src/sub2/zzz.in\n") + +# +# Make the repository non-writable, +# so we'll detect if we try to write into it accidentally. +test.writable('repository', 0) + +# +test.run(chdir = 'work', options = opts, arguments = 'aaa.out') + +test.must_match(['work', 'aaa.out'], "repository/aaa.in\n") +test.must_not_exist(test.workpath('work', 'bbb.out')) +test.must_not_exist(test.workpath('work', 'ccc.out')) +test.must_not_exist(test.workpath('work', 'src', 'xxx.out')) +test.must_not_exist(test.workpath('work', 'src', 'yyy.out')) + +test.run(chdir = 'work', options = opts, arguments = 'bbb.out src') + +test.must_match(['work', 'bbb.out'], "repository/bbb.in\n") +test.must_not_exist(test.workpath('work', 'ccc.out')) +test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n") +test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n") + +expect = """\ +repository/src/sub1/zzz.in +repository/src/sub2/zzz.in +""" + +test.must_match(['work', 'src', 'zzz.out'], expect) + +# +test.run(chdir = 'work', options = opts, arguments = '.') + +test.must_match(['work', 'ccc.out'], "repository/ccc.in\n") + +# +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/VariantDir.py b/test/Glob/VariantDir.py new file mode 100644 index 0000000..175e5b9 --- /dev/null +++ b/test/Glob/VariantDir.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__" + +""" +Verify that default use of the Glob() function within a VariantDir() +finds the local file Nodes. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src') + +test.write('SConstruct', """\ +VariantDir('var1', 'src') +VariantDir('var2', 'src') + +SConscript('var1/SConscript') +SConscript('var2/SConscript') +""") + +test.write(['src', 'SConscript'], """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('f.out', sorted(Glob('f*.in'), key=lambda t: t.name)) +""") + +test.write(['src', 'f1.in'], "src/f1.in\n") +test.write(['src', 'f2.in'], "src/f2.in\n") +test.write(['src', 'f3.in'], "src/f3.in\n") + +test.run(arguments = '.') + +test.must_match(['var1', 'f.out'], "src/f1.in\nsrc/f2.in\nsrc/f3.in\n") +test.must_match(['var2', 'f.out'], "src/f1.in\nsrc/f2.in\nsrc/f3.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/basic.py b/test/Glob/basic.py new file mode 100644 index 0000000..9afbbc6 --- /dev/null +++ b/test/Glob/basic.py @@ -0,0 +1,63 @@ +#!/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__" + +""" +Verify basic operation of the Glob() function. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('f.out', sorted(Glob('f*.in'), key=lambda t: t.name)) +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") + +test.run(arguments = '.') + +test.must_match('f.out', "f1.in\nf2.in\nf3.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/exclude.py b/test/Glob/exclude.py new file mode 100644 index 0000000..fe93b82 --- /dev/null +++ b/test/Glob/exclude.py @@ -0,0 +1,86 @@ +#!/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__" + +""" +Verify the "exclude" parameter usage of the Glob() function. + - with or without subdir + - with or without returning strings + - a file in a subdir is not excluded by a pattern without this subdir +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('fa.out', sorted(Glob('f*.in' , exclude=['f2.in', 'f4.*'] , strings=False), key=lambda t: t.get_internal_path())) +env.Concatenate('fb.out', sorted(Glob('f*.in' , exclude=['f2.in', 'f4.*'] , strings=True))) +env.Concatenate('fc.out', sorted(Glob('d?/f*.in', exclude=['d?/f1.*', 'f2.in'], strings=False), key=lambda t: t.get_internal_path())) +env.Concatenate('fd.out', sorted(Glob('d?/f*.in', exclude=['d?/f1.*', 'f2.in'], strings=True))) +env.Concatenate('fe.out', sorted(Glob('f*.in', exclude='f1.in' , strings=True))) +env.Concatenate('ff.out', sorted(Glob('f*.in', exclude='other' , strings=True))) +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") +test.write('f4.in', "f4.in\n") +test.write('f5.in', "f5.in\n") + +test.subdir('d1', 'd2') +test.write(['d1', 'f1.in'], "d1/f1.in\n") +test.write(['d1', 'f2.in'], "d1/f2.in\n") +test.write(['d1', 'f3.in'], "d1/f3.in\n") +test.write(['d2', 'f1.in'], "d2/f1.in\n") +test.write(['d2', 'f2.in'], "d2/f2.in\n") +test.write(['d2', 'f3.in'], "d2/f3.in\n") + +test.run(arguments = '.') + +test.must_match('fa.out', "f1.in\nf3.in\nf5.in\n") +test.must_match('fb.out', "f1.in\nf3.in\nf5.in\n") +test.must_match('fc.out', "d1/f2.in\nd1/f3.in\nd2/f2.in\nd2/f3.in\n") +test.must_match('fd.out', "d1/f2.in\nd1/f3.in\nd2/f2.in\nd2/f3.in\n") +test.must_match('fe.out', "f2.in\nf3.in\nf4.in\nf5.in\n") +test.must_match('ff.out', "f1.in\nf2.in\nf3.in\nf4.in\nf5.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/glob-libpath.py b/test/Glob/glob-libpath.py new file mode 100644 index 0000000..b09aab9 --- /dev/null +++ b/test/Glob/glob-libpath.py @@ -0,0 +1,92 @@ +#!/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__" + +""" +Verify that Glob() in a subdir doesn't corrupt LIBPATH. +See bug #2184, "Glob pollutes LIBPATH" from Ian P. Cardenas. +Test output should not contain -Lsrc/util. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src', ['src', 'util']) + +test.write('SConstruct', """\ +base_env = Environment() +Export('base_env') +swat = base_env.SConscript('src/SConscript', variant_dir='build') +Default(swat) +""") + +test.write('SConstruct', """\ +base_env = Environment() +Export('base_env') +swat = base_env.SConscript('src/SConscript', variant_dir='build') +Default(swat) +""") + +test.write(['src', 'SConscript'], """Import('base_env') + +libutil = base_env.SConscript('util/SConscript') + +env = base_env.Clone() +env.AppendUnique( LIBPATH = 'util') +env.AppendUnique( LIBS = libutil ) + +swat = env.Program( 'main', 'main.cpp' ) + +Return('swat') +""") + +test.write(['src', 'main.cpp'], """int main(void) { return 0; } +""") + + +test.write(['src', 'util', 'SConscript'], """Import('base_env') +libutil = base_env.Library('util', Glob('*.cpp')) +Return('libutil') +""") + +test.write(['src', 'util', 'util.cpp'], """int i=0; +""") + +test.run(arguments = '-Q .') +if not test.match_re_dotall(test.stdout(), r".*(-L|/LIBPATH:)build[/\\]util.*"): + print repr(test.stdout())+" should contain -Lbuild/util or /LIBPATH:build\\util" + test.fail_test() +if test.match_re_dotall(test.stdout(), r".*(-L|/LIBPATH:)src[/\\]util.*"): + print repr(test.stdout())+" should not contain -Lsrc/util or /LIBPATH:src\\util" + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/source.py b/test/Glob/source.py new file mode 100644 index 0000000..f1ea566 --- /dev/null +++ b/test/Glob/source.py @@ -0,0 +1,92 @@ +#!/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__" + +""" +Verify that use of the Glob() function within a VariantDir() returns the +file Nodes in the source directory when the source= keyword argument is +specified (and duplicate=0 is specified for the VariantDir()). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src', 'var1', 'var2') + +test.write('SConstruct', """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +Export("env") + +VariantDir('var1', 'src', duplicate=0) +VariantDir('var2', 'src', duplicate=0) + +SConscript('var1/SConscript') +SConscript('var2/SConscript') +""") + +test.write(['var1', 'SConscript'], """\ +Import("env") + +env.Concatenate('f.out', sorted(Glob('f[45].in', source=True), + key=lambda t: t.name)) +""") + +test.write(['var2', 'SConscript'], """\ +Import("env") + +f_in = sorted(Glob('f[67].in'), key=lambda a: a.name) +env.Concatenate('f.out', f_in) +""") + +test.write(['src', 'f1.in'], "src/f1.in\n") +test.write(['src', 'f2.in'], "src/f2.in\n") + +test.write(['src', 'f4.in'], "src/f4.in\n") +test.write(['src', 'f5.in'], "src/f5.in\n") +test.write(['src', 'f6.in'], "src/f6.in\n") +test.write(['src', 'f7.in'], "src/f7.in\n") + +test.run(arguments = '.') + +test.must_match(['var1', 'f.out'], "src/f4.in\nsrc/f5.in\n") +test.must_match(['var2', 'f.out'], "src/f6.in\nsrc/f7.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/strings.py b/test/Glob/strings.py new file mode 100644 index 0000000..3e47d10 --- /dev/null +++ b/test/Glob/strings.py @@ -0,0 +1,76 @@ +#!/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__" + +""" +Verify that use of the Glob() function with the strings= option works +when they're used in the same SConscript file (and therefore the same +directory) as input to a Builder call. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src') + +test.write('SConstruct', """\ +VariantDir('var1', 'src') +VariantDir('var2', 'src') + +SConscript('var1/SConscript') +SConscript('var2/SConscript') +""") + +test.write(['src', 'SConscript'], """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('f.out', sorted(Glob('f*.in', strings=True))) +""") + +test.write(['src', 'f1.in'], "src/f1.in\n") +test.write(['src', 'f2.in'], "src/f2.in\n") +test.write(['src', 'f3.in'], "src/f3.in\n") + +test.run(arguments = '.') + +test.must_match(['var1', 'f.out'], "src/f1.in\nsrc/f2.in\nsrc/f3.in\n") +test.must_match(['var2', 'f.out'], "src/f1.in\nsrc/f2.in\nsrc/f3.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/subdir.py b/test/Glob/subdir.py new file mode 100644 index 0000000..6fc00f6 --- /dev/null +++ b/test/Glob/subdir.py @@ -0,0 +1,64 @@ +#!/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__" + +""" +Verify that Glob() works to find Nodes underneath an explicitly- +named subdirectory. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('subdir') + +test.write('SConstruct', """\ +env = Environment() + +def concatenate(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Concatenate'] = Builder(action=concatenate) + +env.Concatenate('f.out', sorted(Glob('subdir/*.in'), key=lambda t: t.name)) +""") + +test.write(['subdir', 'file.in'], "subdir/file.in\n") + +test.run(arguments = '.') + +test.must_match('f.out', "subdir/file.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Glob/subst.py b/test/Glob/subst.py new file mode 100644 index 0000000..e21da81 --- /dev/null +++ b/test/Glob/subst.py @@ -0,0 +1,64 @@ +#!/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__" + +""" +Verify the ability to Glob() using a pattern from a construction variable +expansion. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +env = Environment(PATTERN = 'f*.in') + +def copy(target, source, env): + fp = open(str(target[0]), 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + +env['BUILDERS']['Copy'] = Builder(action=copy) + +env.Copy('f.out', sorted(env.Glob('$PATTERN'), key=lambda t: t.name)) +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") + +test.run(arguments = '.') + +test.must_match('f.out', "f1.in\nf2.in\nf3.in\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |
