diff options
Diffstat (limited to 'test/Interactive')
25 files changed, 2478 insertions, 0 deletions
diff --git a/test/Interactive/Alias.py b/test/Interactive/Alias.py new file mode 100644 index 0000000..fc05b9a --- /dev/null +++ b/test/Interactive/Alias.py @@ -0,0 +1,85 @@ +#!/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 build an Alias in --interactive mode. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +foo = Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Alias('foo-alias', foo) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo-alias\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1'), popen=scons) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +# Verify that "scons" can be used as a synonmyn for the "build" command. +scons.send("scons foo-alias\n") + +scons.send("scons 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build foo-alias\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("2") +scons>>> scons: `foo-alias' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/Default-None.py b/test/Interactive/Default-None.py new file mode 100644 index 0000000..36ebf2f --- /dev/null +++ b/test/Interactive/Default-None.py @@ -0,0 +1,96 @@ +#!/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 we get the expected error message when we use a "build" +command without arguments and there are no default targets (because they +explicitly called Default(None) in the SConstruct file). +""" + +import TestSCons + +test = TestSCons.TestSCons(combine=1) + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Default(None) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build\n") + +scons.send("build foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +# Verify that "scons" can be used as a synonmyn for the "build" command. +scons.send("scons\n") + +scons.send("scons foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build\n") + +scons.send("build foo.out\n") + +expect_stdout = """\ +scons>>> scons: *** No targets specified and no Default() targets found. Stop. +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> scons: *** No targets specified and no Default() targets found. Stop. +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("2") +scons>>> scons: *** No targets specified and no Default() targets found. Stop. +scons>>> scons: `foo.out' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/Default.py b/test/Interactive/Default.py new file mode 100644 index 0000000..d6205e2 --- /dev/null +++ b/test/Interactive/Default.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 that we can use a "build" command without arguments to (re-)build +the Default() targets, without exiting the command loop. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +foo_out = Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Default(foo_out) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +# Verify that "scons" can be used as a synonmy for the "build" command. +scons.send("scons\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("2") +scons>>> scons: `foo.out' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/added-include.py b/test/Interactive/added-include.py new file mode 100644 index 0000000..8c30314 --- /dev/null +++ b/test/Interactive/added-include.py @@ -0,0 +1,118 @@ +#!/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__" + +""" +This verifies the --interactive command line option's ability to +rebuild a target when an implicit dependency (include line) is +added to the source file. +""" + +import string + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('foo.h.in', """ +#define FOO_STRING "foo.h.in" +""") + +test.write('foo.c', """ +#include <stdio.h> + +int main() +{ + printf("foo.c\\n"); + return 0; +} +""") + +test.write('SConstruct', """ +env = Environment(CPPPATH=['.']) +env.Command('foo.h', ['foo.h.in'], Copy('$TARGET', '$SOURCE')) +env.Program('foo', ['foo.c']) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +""") + +foo_exe = test.workpath('foo' + TestSCons._exe) +_foo_exe_ = '"%s"' % string.replace(foo_exe, '\\', '\\\\') + + + +# Start scons, to build "foo" +scons = test.start(arguments = '--interactive') + +scons.send("build %(_foo_exe_)s 1\n" % locals()) + +test.wait_for(test.workpath('1'), popen=scons) + +test.run(program = foo_exe, stdout = 'foo.c\n') + + + + +# Update foo.c +# We add a new #include line, to make sure that scons notices +# the new implicit dependency and builds foo.h first. +test.write('foo.c', """ +#include <foo.h> + +#include <stdio.h> + +int main() +{ + printf("%s\\n", FOO_STRING); + return 0; +} +""") + +scons.send("build %(_foo_exe_)s 2\n" % locals()) + +test.wait_for(test.workpath('2')) + +# Run foo, and make sure it prints correctly +test.run(program = foo_exe, stdout = 'foo.h.in\n') + + + +test.write('foo.h.in', """ +#define FOO_STRING "foo.h.in 3" +""") + + + +scons.send("build %(_foo_exe_)s 3\n" % locals()) + +test.wait_for(test.workpath('3')) + +# Run foo, and make sure it prints correctly +test.run(program = foo_exe, stdout = 'foo.h.in 3\n') + + + +test.pass_test() diff --git a/test/Interactive/basic.py b/test/Interactive/basic.py new file mode 100644 index 0000000..4c78f69 --- /dev/null +++ b/test/Interactive/basic.py @@ -0,0 +1,84 @@ +#!/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 --interactive command line option to build +a target, rebuild it when the input changes, and not rebuild it when +the input doesn't change. + +Also tests that "scons" can be used as a synonym for "build". +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +# Verify that "scons" can be used as a synonmy for the "build" command. +scons.send("scons foo.out 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build foo.out\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> Copy("foo.out", "foo.in") +Touch("2") +scons>>> scons: `foo.out' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/cache-debug.py b/test/Interactive/cache-debug.py new file mode 100644 index 0000000..dab5159 --- /dev/null +++ b/test/Interactive/cache-debug.py @@ -0,0 +1,117 @@ +#!/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 --interactive command line option to build a target when the +--cache-debug option is used. +""" + +import TestCmd +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +CacheDir('cache') +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +Command('4', [], Touch('$TARGET')) +Command('5', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1'), popen=scons) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build foo.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3'), popen=scons) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 4\n") + +test.wait_for(test.workpath('4'), popen=scons) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build --cache-debug=- foo.out\n") + +scons.send("build 5\n") + +test.wait_for(test.workpath('5'), popen=scons) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + + + +expect_stdout = \ +r"""scons>>> Copy\("foo.out", "foo.in"\) +scons>>> Touch\("1"\) +scons>>> Removed foo.out +scons>>> Touch\("2"\) +scons>>> Retrieved `foo.out' from cache +scons>>> Touch\("3"\) +scons>>> Removed foo.out +scons>>> Touch\("4"\) +scons>>> Retrieved `foo.out' from cache +CacheRetrieve\(foo.out\): retrieving from [0-9A-za-z]+ +scons>>> Touch\("5"\) +scons>>> +""" + +test.finish(scons, stdout = expect_stdout, match=TestCmd.match_re) + + + +test.pass_test() diff --git a/test/Interactive/cache-disable.py b/test/Interactive/cache-disable.py new file mode 100644 index 0000000..0fb8435 --- /dev/null +++ b/test/Interactive/cache-disable.py @@ -0,0 +1,115 @@ +#!/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 --interactive command line option to build +a target when the --cache-disable option is used. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +CacheDir('cache') +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +Command('4', [], Touch('$TARGET')) +Command('5', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build foo.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 4\n") + +test.wait_for(test.workpath('4')) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build --cache-disable foo.out\n") + +scons.send("build 5\n") + +test.wait_for(test.workpath('5')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + + + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Removed foo.out +scons>>> Touch("2") +scons>>> Retrieved `foo.out' from cache +scons>>> Touch("3") +scons>>> Removed foo.out +scons>>> Touch("4") +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("5") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/cache-force.py b/test/Interactive/cache-force.py new file mode 100644 index 0000000..8fd3f92 --- /dev/null +++ b/test/Interactive/cache-force.py @@ -0,0 +1,113 @@ +#!/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 --interactive command line option to build a target when the +--cache-force option is used. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +CacheDir('cache') +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +Command('4', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build foo.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +import shutil +shutil.rmtree(test.workpath('cache')) + + + +scons.send("build --cache-force foo.out\n") + +scons.send("clean foo.out\n") + +scons.send("build foo.out\n") + +scons.send("build 4\n") + +test.wait_for(test.workpath('4')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + + + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Removed foo.out +scons>>> Touch("2") +scons>>> Retrieved `foo.out' from cache +scons>>> Touch("3") +scons>>> scons: `foo.out' is up to date. +scons>>> Removed foo.out +scons>>> Retrieved `foo.out' from cache +scons>>> Touch("4") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/cache-show.py b/test/Interactive/cache-show.py new file mode 100644 index 0000000..c1fe487 --- /dev/null +++ b/test/Interactive/cache-show.py @@ -0,0 +1,115 @@ +#!/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 --interactive command line option to build a target when the +--cache-show option is used. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +CacheDir('cache') +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +Command('4', [], Touch('$TARGET')) +Command('5', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build foo.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + +scons.send("clean foo.out\n") + +scons.send("build 4\n") + +test.wait_for(test.workpath('4')) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build --cache-show foo.out\n") + +scons.send("build 5\n") + +test.wait_for(test.workpath('5')) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + + + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Removed foo.out +scons>>> Touch("2") +scons>>> Retrieved `foo.out' from cache +scons>>> Touch("3") +scons>>> Removed foo.out +scons>>> Touch("4") +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("5") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/clean.py b/test/Interactive/clean.py new file mode 100644 index 0000000..4f4f80d --- /dev/null +++ b/test/Interactive/clean.py @@ -0,0 +1,105 @@ +#!/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__" + +""" +Verifies operation of the --interactive command line option +"clean" subcommand. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('f1.out', 'f1.in', Copy('$TARGET', '$SOURCE')) +Command('f2.out', 'f2.in', Copy('$TARGET', '$SOURCE')) +Command('f3.out', 'f3.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build f1.out f2.out f3.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('f1.out'), "f1.in\n") +test.must_match(test.workpath('f2.out'), "f2.in\n") +test.must_match(test.workpath('f3.out'), "f3.in\n") + + + +scons.send("clean f1.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_not_exist('f1.out') +test.must_exist('f2.out') +test.must_exist('f3.out') + + + +scons.send("build -c\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3')) + +test.must_not_exist('f1.out') +test.must_not_exist('f2.out') +test.must_not_exist('f3.out') + +expect_stdout = """\ +scons>>> Copy("f1.out", "f1.in") +Copy("f2.out", "f2.in") +Copy("f3.out", "f3.in") +scons>>> Touch("1") +scons>>> Removed f1.out +scons>>> Touch("2") +scons>>> Removed 1 +Removed 2 +Removed f2.out +Removed f3.out +scons>>> Touch("3") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/exit.py b/test/Interactive/exit.py new file mode 100644 index 0000000..df06d5d --- /dev/null +++ b/test/Interactive/exit.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 use of the "exit" subcommand. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +scons.send('exit\n') + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> """ + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/help.py b/test/Interactive/help.py new file mode 100644 index 0000000..ef4c578 --- /dev/null +++ b/test/Interactive/help.py @@ -0,0 +1,85 @@ +#!/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 behavior of the "help" subcommand (and its "h" and "?" aliases). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +scons.send('help\n') + +scons.send('h\n') + +scons.send('?\n') + +help_text = """\ +build [TARGETS] Build the specified TARGETS and their dependencies. + 'b' is a synonym. +clean [TARGETS] Clean (remove) the specified TARGETS and their + dependencies. 'c' is a synonym. +exit Exit SCons interactive mode. +help [COMMAND] Prints help for the specified COMMAND. 'h' and + '?' are synonyms. +shell [COMMANDLINE] Execute COMMANDLINE in a subshell. 'sh' and '!' + are synonyms. +version Prints SCons version information. +""" + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> %(help_text)s +scons>>> %(help_text)s +scons>>> %(help_text)s +scons>>> +""" % locals() + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/implicit-BuildDir.py b/test/Interactive/implicit-BuildDir.py new file mode 100644 index 0000000..7b7aa4b --- /dev/null +++ b/test/Interactive/implicit-BuildDir.py @@ -0,0 +1,142 @@ +#!/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__" + +""" +This is a regression test for a bug in earlier versions of the +--interactive command line option (specifically the original prototype +submitted by Adam Simpkins, who created this test case). + +It tests to make sure that cached state is cleared between files for +nodes in both the build tree and the source tree when BuildDirs are used. +This is needed especially with BuildDirs created with duplicate=0, since +the scanners scan the files in the source tree. Any cached implicit +deps must be cleared on the source files. +""" + +import os.path +import string + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('src', + ['src', 'inc']) + +# Create the top-level SConstruct file +test.write('SConstruct', """ +BUILD_ENV = Environment() +Export('BUILD_ENV') + +hdr_dir = '#build/include' +BUILD_ENV['HDR_DIR'] = hdr_dir +BUILD_ENV.Append(CPPPATH = hdr_dir) + +BUILD_ENV.BuildDir('build', 'src', duplicate = 0) +SConscript('build/SConscript') + +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +# Create the src/SConscript file +test.write(['src', 'SConscript'], """ +Import('BUILD_ENV') +BUILD_ENV.Install(BUILD_ENV['HDR_DIR'], ['inc/foo.h']) +BUILD_ENV.Program('foo', ['foo.c']) +""") + +# Create src/foo.c +test.write(['src', 'foo.c'], """ +#include <stdio.h> + +#define FOO_PRINT_STRING "Hello from foo.c" + +int main() +{ + printf(FOO_PRINT_STRING "\\n"); + return 0; +} +""") + +# Create src/inc/foo.h +test.write(['src', 'inc', 'foo.h'], """ +#ifndef INCLUDED_foo_h +#define INCLUDED_foo_h + +#define FOO_PRINT_STRING "Hello from foo.h" + +#endif /* INCLUDED_foo_h */ +""") + +# Start scons, to build only "build/foo" +build_foo_exe = os.path.join('build', 'foo' + TestSCons._exe) +_build_foo_exe_ = '"%s"' % string.replace(build_foo_exe, '\\', '\\\\') +abs_foo_exe = test.workpath(build_foo_exe) + +scons = test.start(arguments = '--interactive', combine=1) + + + +# Build build/foo +scons.send('build %(_build_foo_exe_)s 1\n' % locals()) + +test.wait_for(test.workpath('1')) + +# Run foo, and make sure it prints correctly +test.run(program = abs_foo_exe, stdout = 'Hello from foo.c\n') + + + +# Update foo.c to include foo.h +test.write(['src', 'foo.c'], """ +#include "foo.h" +#include <stdio.h> + +int main() +{ + printf(FOO_PRINT_STRING "\\n"); + return 0; +} +""") + +# Build build/foo +scons.send('build %(_build_foo_exe_)s 2\n' % locals()) + +test.wait_for(test.workpath('2')) + +# Run foo, and make sure it prints correctly +test.run(program = abs_foo_exe, stdout = 'Hello from foo.h\n') + + + +scons.send('exit\n') + +test.finish(scons) + + + +test.pass_test() diff --git a/test/Interactive/option--Q.py b/test/Interactive/option--Q.py new file mode 100644 index 0000000..4c02fa7 --- /dev/null +++ b/test/Interactive/option--Q.py @@ -0,0 +1,83 @@ +#!/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 -Q option on an individual "build" command +will suppress the progress messages. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '--interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +scons.send("build -Q foo.out 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +expect_stdout = """\ +scons: Reading SConscript files ... +scons: done reading SConscript files. +scons>>> scons: Building targets ... +Copy("foo.out", "foo.in") +Touch("1") +scons: done building targets. +scons: Clearing cached node information ... +scons: done clearing node information. +scons>>> Copy("foo.out", "foo.in") +Touch("2") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/option-i.py b/test/Interactive/option-i.py new file mode 100644 index 0000000..a2935a7 --- /dev/null +++ b/test/Interactive/option-i.py @@ -0,0 +1,106 @@ +#!/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 -i option, specified on the build command, causes +build errors to be ignored, just for that command. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +def error(target, source, env): + return 1 +e1 = Command('e1.out', 'e1.in', Action(error)) +e2 = Command('e2.out', 'e2.in', Action(error)) +f1 = Command('f1.out', 'f1.in', Copy('$TARGET', '$SOURCE')) +f2 = Command('f2.out', 'f2.in', Copy('$TARGET', '$SOURCE')) +Depends(f1, e1) +Depends(f2, e2) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +""") + +test.write('e1.in', "e1.in\n") +test.write('e2.in', "e2.in\n") +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") + + + +scons = test.start(arguments = '-Q --interactive', combine=1) + +scons.send("build f1.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1'), popen=scons) + +test.must_not_exist(test.workpath('f1.out')) + + + +scons.send("build -i e1.out f1.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_match(test.workpath('f1.out'), "f1.in\n") + + + +scons.send("build f2.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3'), popen=scons) + +test.must_not_exist(test.workpath('f2.out')) + + + +expect_stdout = """\ +scons>>> error(["e1.out"], ["e1.in"]) +scons: *** [e1.out] Error 1 +scons>>> Touch("1") +scons>>> error(["e1.out"], ["e1.in"]) +scons: *** [e1.out] Error 1 +Copy("f1.out", "f1.in") +scons>>> Touch("2") +scons>>> error(["e2.out"], ["e2.in"]) +scons: *** [e2.out] Error 1 +scons>>> Touch("3") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/option-j.py b/test/Interactive/option-j.py new file mode 100644 index 0000000..29bba88 --- /dev/null +++ b/test/Interactive/option-j.py @@ -0,0 +1,164 @@ +#!/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 "build" command of --interactive mode can take a -j +option to build things in parallel. +""" + +import TestSCons + +test = TestSCons.TestSCons(combine=1) + +test.write('SConstruct', """\ +import os +import time +from SCons.Script import * +def cat(target, source, env): + t = str(target[0]) + os.mkdir(t + '.started') + fp = open(t, 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + os.mkdir(t + '.finished') + +def must_be_finished(target, source, env, dir): + if not os.path.exists(dir): + msg = 'build failed, %s does not exist\\n' % dir + sys.stderr.write(msg) + return 1 + return cat(target, source, env) + +def f1_a_out_must_be_finished(target, source, env): + return must_be_finished(target, source, env, 'f1-a.out.finished') +def f3_a_out_must_be_finished(target, source, env): + return must_be_finished(target, source, env, 'f3-a.out.finished') + +def must_wait_for_f2_b_out(target, source, env): + t = str(target[0]) + os.mkdir(t + '.started') + f2_b_started = 'f2-b.out.started' + while not os.path.exists(f2_b_started): + time.sleep(1) + fp = open(t, 'wb') + for s in source: + fp.write(open(str(s), 'rb').read()) + fp.close() + os.mkdir(t + '.finished') + +def _f2_a_out_must_not_be_finished(target, source, env): + f2_a_started = 'f2-a.out.started' + f2_a_finished = 'f2-a.out.finished' + while not os.path.exists(f2_a_started): + time.sleep(1) + msg = 'f2_a_out_must_not_be_finished(["%s"], ["%s"])\\n' % (target[0], source[0]) + sys.stdout.write(msg) + if os.path.exists(f2_a_finished): + msg = 'build failed, %s exists\\n' % f2_a_finished + sys.stderr.write(msg) + return 1 + return cat(target, source, env) + +f2_a_out_must_not_be_finished = Action(_f2_a_out_must_not_be_finished, + strfunction = None) + +Cat = Action(cat) +f1_a = Command('f1-a.out', 'f1-a.in', cat) +f1_b = Command('f1-b.out', 'f1-b.in', f1_a_out_must_be_finished) +f2_a = Command('f2-a.out', 'f2-a.in', must_wait_for_f2_b_out) +f2_b = Command('f2-b.out', 'f2-b.in', f2_a_out_must_not_be_finished) +f3_a = Command('f3-a.out', 'f3-a.in', cat) +f3_b = Command('f3-b.out', 'f3-b.in', f3_a_out_must_be_finished) +Command('f1.out', f1_a + f1_b, cat) +Command('f2.out', f2_a + f2_b, cat) +Command('f3.out', f3_a + f3_b, cat) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +""") + +test.write('f1-a.in', "f1-a.in\n") +test.write('f1-b.in', "f1-b.in\n") +test.write('f2-a.in', "f2-a.in\n") +test.write('f2-b.in', "f2-b.in\n") +test.write('f3-a.in', "f3-a.in\n") +test.write('f3-b.in', "f3-b.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build f1.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1'), popen=scons) + +test.must_match(test.workpath('f1.out'), "f1-a.in\nf1-b.in\n") + + + +scons.send("build -j2 f2.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_match(test.workpath('f2.out'), "f2-a.in\nf2-b.in\n") + + + +scons.send("build f3.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3')) + +test.must_match(test.workpath('f3.out'), "f3-a.in\nf3-b.in\n") + + + +expect_stdout = """\ +scons>>> cat(["f1-a.out"], ["f1-a.in"]) +f1_a_out_must_be_finished(["f1-b.out"], ["f1-b.in"]) +cat(["f1.out"], ["f1-a.out", "f1-b.out"]) +scons>>> Touch("1") +scons>>> must_wait_for_f2_b_out(["f2-a.out"], ["f2-a.in"]) +f2_a_out_must_not_be_finished(["f2-b.out"], ["f2-b.in"]) +cat(["f2.out"], ["f2-a.out", "f2-b.out"]) +scons>>> Touch("2") +scons>>> cat(["f3-a.out"], ["f3-a.in"]) +f3_a_out_must_be_finished(["f3-b.out"], ["f3-b.in"]) +cat(["f3.out"], ["f3-a.out", "f3-b.out"]) +scons>>> Touch("3") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/option-k.py b/test/Interactive/option-k.py new file mode 100644 index 0000000..f15605e --- /dev/null +++ b/test/Interactive/option-k.py @@ -0,0 +1,108 @@ +#!/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 -k option, specified on the build command, causes +us to keep going and build additional targets. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +def error(target, source, env): + return 1 +e1 = Command('e1.out', 'e1.in', Action(error)) +f1 = Command('f1.out', 'f1.in', Copy('$TARGET', '$SOURCE')) +Command('f2.out', 'f2.in', Copy('$TARGET', '$SOURCE')) +Command('f3.out', 'f3.in', Copy('$TARGET', '$SOURCE')) +Depends(f1, e1) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +Command('3', [], Touch('$TARGET')) +""") + +test.write('e1.in', "e1.in\n") +test.write('e2.in', "e2.in\n") +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") + + + +scons = test.start(arguments = '-Q --interactive', combine=1) + +scons.send("build f1.out f2.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1'), popen=scons) + +test.must_not_exist(test.workpath('f1.out')) +test.must_not_exist(test.workpath('f2.out')) + + + +scons.send("build -k f1.out f2.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_not_exist(test.workpath('f1.out')) +test.must_match(test.workpath('f2.out'), "f2.in\n") + + + +scons.send("build f1.out f3.out\n") + +scons.send("build 3\n") + +test.wait_for(test.workpath('3'), popen=scons) + +test.must_not_exist(test.workpath('f1.out')) +test.must_not_exist(test.workpath('f3.out')) + + + +expect_stdout = """\ +scons>>> error(["e1.out"], ["e1.in"]) +scons: *** [e1.out] Error 1 +scons>>> Touch("1") +scons>>> error(["e1.out"], ["e1.in"]) +scons: *** [e1.out] Error 1 +Copy("f2.out", "f2.in") +scons>>> Touch("2") +scons>>> error(["e1.out"], ["e1.in"]) +scons: *** [e1.out] Error 1 +scons>>> Touch("3") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/option-n.py b/test/Interactive/option-n.py new file mode 100644 index 0000000..f5ee1e3 --- /dev/null +++ b/test/Interactive/option-n.py @@ -0,0 +1,79 @@ +#!/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 -n option, specified on the build command, reports +what would be built but doesn't actually build anything. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build -n foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1'), popen=scons) + +test.must_not_exist(test.workpath('foo.out')) + + + +scons.send("build foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2'), popen=scons) + +test.must_match(test.workpath('foo.out'), "foo.in\n") + + + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("2") +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/option-s.py b/test/Interactive/option-s.py new file mode 100644 index 0000000..167d581 --- /dev/null +++ b/test/Interactive/option-s.py @@ -0,0 +1,79 @@ +#!/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 --interactive command line option +to build a target, rebuild it when the input changes, and not rebuild +it when the input doesn't change. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +scons.send("build -s foo.out 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build foo.out\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> scons>>> scons: `foo.out' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/repeat-line.py b/test/Interactive/repeat-line.py new file mode 100644 index 0000000..e85b9ea --- /dev/null +++ b/test/Interactive/repeat-line.py @@ -0,0 +1,87 @@ +#!/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 a blank line repeats the last (build) command. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +scons.send("\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build foo.out\n") + +scons.send("\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> build foo.out 1 +Copy("foo.out", "foo.in") +scons: `1' is up to date. +scons>>> Touch("2") +scons>>> scons: `foo.out' is up to date. +scons>>> build foo.out +scons: `foo.out' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/shell.py b/test/Interactive/shell.py new file mode 100644 index 0000000..9d5e8a2 --- /dev/null +++ b/test/Interactive/shell.py @@ -0,0 +1,116 @@ +#!/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 of the "shell" command (and its "sh" and "!" aliases) +to shell out of interactive mode. +""" + +import string +import sys + +import TestSCons + +test = TestSCons.TestSCons(combine=1) + +_python_ = TestSCons._python_ + +shell_command_py = test.workpath('shell_command.py') +_shell_command_py_ = '"%s"' % string.replace(shell_command_py, '\\', '\\\\') + +test.write(shell_command_py, """\ +print 'hello from shell_command.py' +""") + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +scons.send('!%(_python_)s %(_shell_command_py_)s\n' % locals()) + +scons.send("\n") + +scons.send('shell %(_python_)s %(_shell_command_py_)s\n' % locals()) + +scons.send("\n") + +scons.send('sh %(_python_)s %(_shell_command_py_)s\n' % locals()) + +scons.send("\n") + +scons.send('!no_such_command arg1 arg2\n') + +scons.send("\n") + +scons.send("build foo.out\n") + +scons.send("\n") + +if sys.platform == 'win32': + no_such_error = 'The system cannot find the file specified' +else: + no_such_error = 'No such file or directory' + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> hello from shell_command.py +scons>>> !%(_python_)s %(_shell_command_py_)s +hello from shell_command.py +scons>>> hello from shell_command.py +scons>>> shell %(_python_)s %(_shell_command_py_)s +hello from shell_command.py +scons>>> hello from shell_command.py +scons>>> sh %(_python_)s %(_shell_command_py_)s +hello from shell_command.py +scons>>> scons: no_such_command: %(no_such_error)s +scons>>> !no_such_command arg1 arg2 +scons: no_such_command: %(no_such_error)s +scons>>> scons: `foo.out' is up to date. +scons>>> build foo.out +scons: `foo.out' is up to date. +scons>>> +""" % locals() + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/taskmastertrace.py b/test/Interactive/taskmastertrace.py new file mode 100644 index 0000000..23b9ad9 --- /dev/null +++ b/test/Interactive/taskmastertrace.py @@ -0,0 +1,90 @@ +#!/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 use of the --taskmastertrace= option to the "build" command +of --interactive mode. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +scons.send("build --taskmastertrace=- foo.out\n") + +scons.send("build 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build foo.out\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> Taskmaster: 'foo.out': children: + ['foo.in'] + waiting on unfinished children: + ['foo.in'] +Taskmaster: 'foo.in': evaluating foo.in +Taskmaster: 'foo.out': children: + ['foo.in'] + evaluating foo.out +Copy("foo.out", "foo.in") +scons>>> Touch("2") +scons>>> scons: `foo.out' is up to date. +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/tree.py b/test/Interactive/tree.py new file mode 100644 index 0000000..96e7d4a --- /dev/null +++ b/test/Interactive/tree.py @@ -0,0 +1,91 @@ +#!/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 --interactive command line option to build +a target, rebuild it when the input changes, and not rebuild it when +the input doesn't change. + +Also tests that "scons" can be used as a synonym for "build". +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +Command('2', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out\n") + +scons.send("build 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +test.write('foo.in', "foo.in 2\n") + +scons.send("build --tree=all foo.out\n") + +scons.send("scons 2\n") + +test.wait_for(test.workpath('2')) + +test.must_match(test.workpath('foo.out'), "foo.in 2\n") + + + +scons.send("build --debug=tree foo.out\n") + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +scons>>> Touch("1") +scons>>> Copy("foo.out", "foo.in") ++-foo.out + +-foo.in +scons>>> Touch("2") +scons>>> scons: `foo.out' is up to date. ++-foo.out + +-foo.in +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/unknown-command.py b/test/Interactive/unknown-command.py new file mode 100644 index 0000000..2b77378 --- /dev/null +++ b/test/Interactive/unknown-command.py @@ -0,0 +1,66 @@ +#!/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 error message when an unknown command is typed in. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE')) +Command('1', [], Touch('$TARGET')) +""") + +test.write('foo.in', "foo.in 1\n") + + + +scons = test.start(arguments = '-Q --interactive') + +scons.send("build foo.out 1\n") + +test.wait_for(test.workpath('1')) + +test.must_match(test.workpath('foo.out'), "foo.in 1\n") + + + +scons.send('this-is-an-unknown-command hello\n') + +expect_stdout = """\ +scons>>> Copy("foo.out", "foo.in") +Touch("1") +scons>>> *** Unknown command: this-is-an-unknown-command +scons>>> +""" + +test.finish(scons, stdout = expect_stdout) + + + +test.pass_test() diff --git a/test/Interactive/version.py b/test/Interactive/version.py new file mode 100644 index 0000000..84f70e8 --- /dev/null +++ b/test/Interactive/version.py @@ -0,0 +1,84 @@ +#!/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 behavior of the "version" subcommand. +""" + +import TestCmd +import TestSCons + +test = TestSCons.TestSCons(match = TestCmd.match_re) + +test.write('SConstruct', "") + + + +# Construct the standard copyright marker so it doesn't get replaced +# by the packaging build. +copyright_marker = '__' + 'COPYRIGHT' + '__' + +copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007' + +fmt = '(%s|Copyright \\(c\\) %s The SCons Foundation)\n' + +copyright_line = fmt % (copyright_marker, copyright_years) + + + +expect1 = """\ +scons>>> +scons>>> +""" + +expect2 = """\ +scons>>> +scons>>> +""" + +test.run(arguments = '-Q --interactive', + stdin = "version\nexit\n") + +# Windows may or may not print a line for the script version +# depending on whether it's invoked through scons.py or scons.bat. +expect1 = r"""scons>>> SCons by Steven Knight et al\.: +\tengine: v\S+, [^,]*, by \S+ on \S+ +%(copyright_line)sscons>>> +""" % locals() + +expect2 = r"""scons>>> SCons by Steven Knight et al\.: +\tscript: v\S+, [^,]*, by \S+ on \S+ +\tengine: v\S+, [^,]*, by \S+ on \S+ +%(copyright_line)sscons>>> +""" % locals() + +stdout = test.stdout() + '\n' +if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): + print repr(stdout) + test.fail_test() + + + +test.pass_test() |