summaryrefslogtreecommitdiffstats
path: root/test/option
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2021-04-09 21:52:23 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2021-04-09 23:48:31 (GMT)
commite7922f6c78b786b8c04fe780e892b23946fe82b5 (patch)
tree15b24c5eee939a26a32ba2c797781fc8ac641299 /test/option
parent349412dc284c9cc228e90143d513bb1b1f2dc016 (diff)
downloadSCons-e7922f6c78b786b8c04fe780e892b23946fe82b5.zip
SCons-e7922f6c78b786b8c04fe780e892b23946fe82b5.tar.gz
SCons-e7922f6c78b786b8c04fe780e892b23946fe82b5.tar.bz2
move all the option-* tests into test/option to clean up directory and match normal organization.
Diffstat (limited to 'test/option')
-rw-r--r--test/option/option--.py65
-rw-r--r--test/option/option--C.py111
-rw-r--r--test/option/option--I.py67
-rw-r--r--test/option/option--Q.py95
-rw-r--r--test/option/option--R.py43
-rw-r--r--test/option/option--S.py47
-rw-r--r--test/option/option--W.py49
-rw-r--r--test/option/option--Y.py318
-rw-r--r--test/option/option--duplicate.py140
-rw-r--r--test/option/option--la.py41
-rw-r--r--test/option/option--ld.py41
-rw-r--r--test/option/option--lw.py41
-rw-r--r--test/option/option--max-drift.py129
-rw-r--r--test/option/option--override.py41
-rw-r--r--test/option/option--random.py121
-rw-r--r--test/option/option--tree.py92
-rw-r--r--test/option/option--wf.py41
-rw-r--r--test/option/option--wuv.py49
-rw-r--r--test/option/option-b.py43
-rw-r--r--test/option/option-f.py117
-rw-r--r--test/option/option-i.py99
-rw-r--r--test/option/option-j.py230
-rw-r--r--test/option/option-k.py303
-rw-r--r--test/option/option-l.py45
-rw-r--r--test/option/option-m.py43
-rw-r--r--test/option/option-n.py243
-rw-r--r--test/option/option-o.py45
-rw-r--r--test/option/option-p.py41
-rw-r--r--test/option/option-r.py43
-rw-r--r--test/option/option-s.py98
-rw-r--r--test/option/option-t.py46
-rw-r--r--test/option/option-unknown.py53
-rw-r--r--test/option/option-v.py64
33 files changed, 3044 insertions, 0 deletions
diff --git a/test/option/option--.py b/test/option/option--.py
new file mode 100644
index 0000000..8e06260
--- /dev/null
+++ b/test/option/option--.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.write('build.py', r"""
+import sys
+file = open(sys.argv[1], 'w')
+file.write("build.py: %s\n" % sys.argv[1])
+file.close()
+""")
+
+test.write('SConstruct', """
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGETS')
+env = Environment(BUILDERS = { 'MyBuild' : MyBuild })
+env.MyBuild(target = '-f1.out', source = 'f1.in')
+env.MyBuild(target = '-f2.out', source = 'f2.in')
+""" % locals())
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+
+expect = test.wrap_stdout('%(_python_)s build.py -f1.out\n%(_python_)s build.py -f2.out\n' % locals())
+
+test.run(arguments = '-- -f1.out -f2.out', stdout = expect)
+
+test.fail_test(not os.path.exists(test.workpath('-f1.out')))
+test.fail_test(not os.path.exists(test.workpath('-f2.out')))
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--C.py b/test/option/option--C.py
new file mode 100644
index 0000000..2d86fac
--- /dev/null
+++ b/test/option/option--C.py
@@ -0,0 +1,111 @@
+#!/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.
+#
+
+"""
+Test that the -C option changes directory as expected and that
+multiple -C options are additive, except if a full path is given
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+
+import TestSCons
+
+def match_normcase(lines, matches):
+ if not isinstance(lines, list):
+ lines = lines.split("\n")
+ if not isinstance(matches, list):
+ matches = matches.split("\n")
+ if len(lines) != len(matches):
+ return None
+ for line, match in zip(lines, matches):
+ if os.path.normcase(line) != os.path.normcase(match):
+ return None
+ return 1
+
+test = TestSCons.TestSCons(match=match_normcase)
+
+wpath = test.workpath()
+wpath_sub = test.workpath('sub')
+wpath_sub_dir = test.workpath('sub', 'dir')
+wpath_sub_foo_bar = test.workpath('sub', 'foo', 'bar')
+
+test.subdir('sub', ['sub', 'dir'])
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+import os
+print("SConstruct " + os.getcwd())
+""")
+
+test.write(['sub', 'SConstruct'], """
+DefaultEnvironment(tools=[])
+import os
+print(GetBuildPath('..'))
+""")
+
+test.write(['sub', 'dir', 'SConstruct'], """
+DefaultEnvironment(tools=[])
+import os
+env = Environment(FOO='foo', BAR='bar', tools=[])
+print(env.GetBuildPath('../$FOO/$BAR'))
+""")
+
+# single -C
+test.run(arguments='-C sub .',
+ stdout="scons: Entering directory `%s'\n" % wpath_sub \
+ + test.wrap_stdout(read_str='%s\n' % wpath,
+ build_str="scons: `.' is up to date.\n"))
+
+# multiple -C
+test.run(arguments='-C sub -C dir .',
+ stdout="scons: Entering directory `%s'\n" % wpath_sub_dir \
+ + test.wrap_stdout(read_str='%s\n' % wpath_sub_foo_bar,
+ build_str="scons: `.' is up to date.\n"))
+
+test.run(arguments=".",
+ stdout=test.wrap_stdout(read_str='SConstruct %s\n' % wpath,
+ build_str="scons: `.' is up to date.\n"))
+
+# alternate form
+test.run(arguments='--directory=sub/dir .',
+ stdout="scons: Entering directory `%s'\n" % wpath_sub_dir \
+ + test.wrap_stdout(read_str='%s\n' % wpath_sub_foo_bar,
+ build_str="scons: `.' is up to date.\n"))
+
+# checks that using full paths is not additive
+test.run(arguments='-C %s -C %s .' % (wpath_sub_dir, wpath_sub),
+ stdout="scons: Entering directory `%s'\n" % wpath_sub \
+ + test.wrap_stdout(read_str='%s\n' % wpath,
+ build_str="scons: `.' is up to date.\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/option/option--I.py b/test/option/option--I.py
new file mode 100644
index 0000000..0ca262d
--- /dev/null
+++ b/test/option/option--I.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('sub1', 'sub2')
+
+test.write(['sub1', 'foo.py'], """
+variable = "sub1/foo"
+""")
+
+test.write(['sub2', 'foo.py'], """
+variable = "sub2/foo"
+""")
+
+test.write(['sub2', 'bar.py'], """
+variable = "sub2/bar"
+""")
+
+test.write('SConstruct', """
+import foo
+print(foo.variable)
+import bar
+print(bar.variable)
+""")
+
+test.run(arguments = '-I sub1 -I sub2 .',
+ stdout = test.wrap_stdout(read_str = 'sub1/foo\nsub2/bar\n',
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--include-dir=sub2 --include-dir=sub1 .',
+ stdout = test.wrap_stdout(read_str = 'sub2/foo\nsub2/bar\n',
+ build_str = "scons: `.' is up to date.\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/option/option--Q.py b/test/option/option--Q.py
new file mode 100644
index 0000000..f3b82f9
--- /dev/null
+++ b/test/option/option--Q.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+
+test.write('build.py', r"""
+import sys
+file = open(sys.argv[1], 'w')
+file.write("build.py: %s\n" % sys.argv[1])
+file.close()
+""")
+
+test.write('SConstruct', """
+
+AddOption('--use_SetOption', action='store_true', dest='setoption', default=False)
+
+use_setoption=GetOption('setoption')
+
+if use_setoption:
+ SetOption('no_progress', True)
+
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGET')
+env = Environment(BUILDERS = { 'MyBuild' : MyBuild })
+env.MyBuild(target = 'f1.out', source = 'f1.in')
+env.MyBuild(target = 'f2.out', source = 'f2.in')
+""" % locals())
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+
+test.run(arguments = '-Q f1.out f2.out', stdout = """\
+%(_python_)s build.py f1.out
+%(_python_)s build.py f2.out
+""" % locals())
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+# Make sure -q doesn't suppress other messages, too.
+test.run(arguments = '-Q -c f1.out f2.out', stdout = """\
+Removed f1.out
+Removed f2.out
+""")
+test.fail_test(os.path.exists(test.workpath('f1.out')))
+test.fail_test(os.path.exists(test.workpath('f2.out')))
+
+
+# When set via a SetOption, it will happen after the initial output of
+# scons: Reading SConscript files ...
+# but remaining status/progress output will not be output
+test.run(arguments = '--use_SetOption f1.out f2.out', stdout = """\
+scons: Reading SConscript files ...
+%(_python_)s build.py f1.out
+%(_python_)s build.py f2.out
+""" % locals())
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--R.py b/test/option/option--R.py
new file mode 100644
index 0000000..3b66e28
--- /dev/null
+++ b/test/option/option--R.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('-R', '.')
+
+test.option_not_yet_implemented('--no-builtin-variables', '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--S.py b/test/option/option--S.py
new file mode 100644
index 0000000..e95f14f
--- /dev/null
+++ b/test/option/option--S.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.run(arguments = '-S .', stderr = "Warning: ignoring -S option\n")
+
+test.run(arguments = '--no-keep-going .',
+ stderr = "Warning: ignoring --no-keep-going option\n")
+
+test.run(arguments = '--stop .', stderr = "Warning: ignoring --stop option\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/option/option--W.py b/test/option/option--W.py
new file mode 100644
index 0000000..3f68fbc
--- /dev/null
+++ b/test/option/option--W.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """\
+DefaultEnvironment(tools=[])
+""")
+
+test.option_not_yet_implemented('-W', 'foo .')
+
+test.option_not_yet_implemented('--what-if', '=foo .')
+
+test.option_not_yet_implemented('--new-file', '=foo .')
+
+test.option_not_yet_implemented('--assume-new', '=foo .')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--Y.py b/test/option/option--Y.py
new file mode 100644
index 0000000..69951c0
--- /dev/null
+++ b/test/option/option--Y.py
@@ -0,0 +1,318 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import sys
+import TestSCons
+
+if sys.platform == 'win32':
+ _exe = '.exe'
+else:
+ _exe = ''
+
+
+
+test = TestSCons.TestSCons()
+
+test.subdir('repository', 'work1')
+
+repository = test.workpath('repository')
+repository_foo_c = test.workpath('repository', 'foo.c')
+work1_foo = test.workpath('work1', 'foo' + _exe)
+work1_foo_c = test.workpath('work1', 'foo.c')
+
+test.write(['repository', 'SConstruct'], r"""
+env = Environment()
+env.Program(target= 'foo', source = Split('aaa.c bbb.c foo.c'))
+""")
+
+test.write(['repository', 'aaa.c'], r"""
+#include <stdio.h>
+void
+aaa(void)
+{
+ printf("repository/aaa.c\n");
+}
+""")
+
+test.write(['repository', 'bbb.c'], r"""
+#include <stdio.h>
+void
+bbb(void)
+{
+ printf("repository/bbb.c\n");
+}
+""")
+
+test.write(['repository', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+extern void aaa(void);
+extern void bbb(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ aaa();
+ bbb();
+ printf("repository/foo.c\n");
+ exit (0);
+}
+""")
+
+opts = '-Y ' + repository
+
+# Make the entire repository non-writable, so we'll detect
+# if we try to write into it accidentally.
+test.writable('repository', 0)
+
+test.run(chdir = 'work1', options = opts, arguments = '.')
+
+test.run(program = work1_foo, stdout = """repository/aaa.c
+repository/bbb.c
+repository/foo.c
+""")
+
+test.up_to_date(chdir = 'work1', options = opts, arguments = '.')
+
+#
+test.write(['work1', 'bbb.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+void
+bbb(void)
+{
+ printf("work1/bbb.c\n");
+}
+""")
+
+test.run(chdir = 'work1', options = opts, arguments = '.')
+
+test.run(program = work1_foo, stdout = """repository/aaa.c
+work1/bbb.c
+repository/foo.c
+""")
+
+test.up_to_date(chdir = 'work1', options = opts, arguments = '.')
+
+#
+test.write(['work1', 'aaa.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+void
+aaa(void)
+{
+ printf("work1/aaa.c\n");
+}
+""")
+
+test.write(['work1', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+extern void aaa(void);
+extern void bbb(void);
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ aaa();
+ bbb();
+ printf("work1/foo.c\n");
+ exit (0);
+}
+""")
+
+test.run(chdir = 'work1', options = opts, arguments = '.')
+
+test.run(program = work1_foo, stdout = """work1/aaa.c
+work1/bbb.c
+work1/foo.c
+""")
+
+test.up_to_date(chdir = 'work1', options = opts, arguments = '.')
+
+#
+test.unlink(['work1', 'bbb.c'])
+test.unlink(['work1', 'foo.c'])
+
+test.run(chdir = 'work1', options = opts, arguments = '.')
+
+test.run(program = work1_foo, stdout = """work1/aaa.c
+repository/bbb.c
+repository/foo.c
+""")
+
+test.up_to_date(chdir = 'work1', options = opts, arguments = '.')
+
+
+
+#
+test.subdir('r.NEW', 'r.OLD', 'work2')
+
+workpath_r_NEW = test.workpath('r.NEW')
+workpath_r_OLD = test.workpath('r.OLD')
+work2_foo = test.workpath('work2', 'foo' + _exe)
+
+SConstruct = """
+env = Environment()
+env.Program(target = 'foo', source = 'foo.c')
+"""
+
+test.write(['r.OLD', 'SConstruct'], SConstruct)
+
+test.write(['r.NEW', 'SConstruct'], SConstruct)
+
+test.write(['r.OLD', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("r.OLD/foo.c\n");
+ exit (0);
+}
+""")
+
+opts = '-Y %s -Y %s' % (workpath_r_NEW, workpath_r_OLD)
+
+# Make the repositories non-writable, so we'll detect
+# if we try to write into them accidentally.
+test.writable('r.OLD', 0)
+test.writable('r.NEW', 0)
+
+test.run(chdir = 'work2', options = opts, arguments = '.')
+
+test.run(program = work2_foo, stdout = "r.OLD/foo.c\n")
+
+test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
+
+#
+test.writable('r.NEW', 1)
+
+test.write(['r.NEW', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("r.NEW/foo.c\n");
+ exit (0);
+}
+""")
+
+test.writable('r.NEW', 0)
+
+test.run(chdir = 'work2', options = opts, arguments = '.')
+
+test.run(program = work2_foo, stdout = "r.NEW/foo.c\n")
+
+test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
+
+#
+test.write(['work2', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("work2/foo.c\n");
+ exit (0);
+}
+""")
+
+test.run(chdir = 'work2', options = opts, arguments = '.')
+
+test.run(program = work2_foo, stdout = "work2/foo.c\n")
+
+test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
+
+#
+test.writable('r.OLD', 1)
+test.writable('r.NEW', 1)
+
+test.write(['r.OLD', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("r.OLD/foo.c 2\n");
+ exit (0);
+}
+""")
+
+test.write(['r.NEW', 'foo.c'], r"""
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("r.NEW/foo.c 2\n");
+ exit (0);
+}
+""")
+
+test.writable('r.OLD', 0)
+test.writable('r.NEW', 0)
+
+test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
+
+#
+test.unlink(['work2', 'foo.c'])
+
+test.run(chdir = 'work2', options = opts, arguments = '.')
+
+test.run(program = work2_foo, stdout = "r.NEW/foo.c 2\n")
+
+test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
+
+#
+test.writable('r.NEW', 1)
+
+test.unlink(['r.NEW', 'foo.c'])
+
+test.writable('r.NEW', 0)
+
+test.run(chdir = 'work2', options = opts, arguments = '.')
+
+test.run(program = work2_foo, stdout = "r.OLD/foo.c 2\n")
+
+test.up_to_date(chdir = 'work2', options = opts, arguments = '.')
+
+
+
+#
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--duplicate.py b/test/option/option--duplicate.py
new file mode 100644
index 0000000..91dc61c
--- /dev/null
+++ b/test/option/option--duplicate.py
@@ -0,0 +1,140 @@
+#!/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.
+#
+
+"""
+This tests the --duplicate command line option, and the duplicate
+SConscript settable option.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import sys
+import stat
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+try:
+ duplicate = ARGUMENTS['duplicate']
+ SetOption('duplicate', duplicate)
+except KeyError:
+ pass
+VariantDir('build', '.', duplicate=1)
+SConscript('build/SConscript')
+""")
+
+test.write('SConscript', '')
+
+# we don't use links on windows currently as they
+# require permissions not usually set
+hard = hasattr(os, 'link') and sys.platform != 'win32'
+soft = hasattr(os, 'symlink') and sys.platform != 'win32'
+copy = 1 # should always work
+
+bss = test.workpath('build/SConscript')
+
+criterion_hardlinks = {
+ 'hard' : lambda nl, islink: nl == 2 and not islink,
+ 'soft' : lambda nl, islink: nl == 1 and islink,
+ 'copy' : lambda nl, islink: nl == 1 and not islink,
+}
+
+criterion_no_hardlinks = {
+ 'hard' : lambda nl, islink: not islink,
+ 'soft' : lambda nl, islink: islink,
+ 'copy' : lambda nl, islink: not islink,
+}
+
+# On systems without hard linking, it doesn't make sense to check ST_NLINK
+if hard:
+ criterion = criterion_hardlinks
+else:
+ criterion = criterion_no_hardlinks
+
+description = {
+ 'hard' : 'a hard link',
+ 'soft' : 'a soft link',
+ 'copy' : 'copied',
+}
+
+def testLink(file, type):
+ nl = os.stat(file)[stat.ST_NLINK]
+ islink = os.path.islink(file)
+ assert criterion[type](nl, islink), \
+ "Expected %s to be %s (nl %d, islink %d)" \
+ % (file, description[type], nl, islink)
+
+def RunTest(order, type, bss):
+ # Test the command-line --duplicate option.
+ test.run(arguments='--duplicate='+order)
+ testLink(bss, type)
+
+ # Test setting the option in the SConstruct file.
+ test.run(arguments='duplicate='+order)
+ testLink(bss, type)
+
+ # Clean up for next run.
+ os.unlink(bss)
+
+# test the default (hard-soft-copy)
+if hard: type='hard'
+elif soft: type='soft'
+else: type='copy'
+RunTest('hard-soft-copy', type, bss)
+
+if soft: type='soft'
+elif hard: type='hard'
+else: type='copy'
+RunTest('soft-hard-copy', type, bss)
+
+if soft: type='soft'
+else: type='copy'
+RunTest('soft-copy', type, bss)
+
+if hard: type='hard'
+else: type='copy'
+RunTest('hard-copy', type, bss)
+
+type='copy'
+RunTest('copy', type, bss)
+
+test.run(arguments='--duplicate=nonsense', status=2, stderr="""\
+usage: scons [OPTION] [TARGET] ...
+
+SCons Error: `nonsense' is not a valid duplication option type, try:
+ hard-soft-copy, soft-hard-copy, hard-copy, soft-copy, copy
+""")
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--la.py b/test/option/option--la.py
new file mode 100644
index 0000000..8a264aa
--- /dev/null
+++ b/test/option/option--la.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('--list-actions', '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--ld.py b/test/option/option--ld.py
new file mode 100644
index 0000000..90c9346
--- /dev/null
+++ b/test/option/option--ld.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('--list-derived', '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--lw.py b/test/option/option--lw.py
new file mode 100644
index 0000000..f0f5e78
--- /dev/null
+++ b/test/option/option--lw.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('--list-where', '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--max-drift.py b/test/option/option--max-drift.py
new file mode 100644
index 0000000..9db3933
--- /dev/null
+++ b/test/option/option--max-drift.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.write('build.py', r"""
+import sys
+with open(sys.argv[1], 'wb') as f, open(sys.argv[2], 'rb') as ifp:
+ f.write(ifp.read())
+""")
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B }, tools=[])
+env.B(target = 'f1.out', source = 'f1.in')
+env.B(target = 'f2.out', source = 'f2.in')
+""" % locals())
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+
+
+
+test.run(arguments = 'f1.out')
+
+test.run(arguments = 'f1.out f2.out',
+ stdout = test.wrap_stdout(
+"""scons: `f1.out' is up to date.
+%(_python_)s build.py f2.out f2.in
+""" % locals()))
+
+atime = os.path.getatime(test.workpath('f1.in'))
+mtime = os.path.getmtime(test.workpath('f1.in'))
+
+test.up_to_date(options='--max-drift=0', arguments='f1.out f2.out')
+
+test.write('f1.in', "f1.in delta\n")
+os.utime(test.workpath('f1.in'), (atime,mtime))
+
+test.up_to_date(options='--max-drift=0', arguments='f1.out f2.out')
+
+expect = test.wrap_stdout(
+"""%(_python_)s build.py f1.out f1.in
+scons: `f2.out' is up to date.
+""" % locals())
+
+test.run(arguments = '--max-drift=-1 f1.out f2.out', stdout = expect)
+
+# Test that Set/GetOption('max_drift') works:
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+assert GetOption('max_drift') == 2*24*60*60
+SetOption('max_drift', 1)
+assert GetOption('max_drift') == 1
+""")
+
+test.run()
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+assert GetOption('max_drift') == 1
+SetOption('max_drift', 10)
+assert GetOption('max_drift') == 1
+""")
+
+test.run(arguments='--max-drift=1')
+
+# Test that SetOption('max_drift') actually sets max_drift
+# by mucking with the file timestamps to make SCons not realize the source has changed
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+SetOption('max_drift', 0)
+B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B }, tools=[])
+env.B(target = 'foo.out', source = 'foo.in')
+""" % locals())
+
+test.write('foo.in', 'foo.in\n')
+
+atime = os.path.getatime(test.workpath('foo.in'))
+mtime = os.path.getmtime(test.workpath('foo.in'))
+
+test.run()
+test.must_match('foo.out', 'foo.in\n', mode='r')
+
+test.write('foo.in', 'foo.in delta\n')
+os.utime(test.workpath('foo.in'), (atime,mtime))
+
+test.run()
+
+test.must_match('foo.out', 'foo.in\n', mode='r')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--override.py b/test/option/option--override.py
new file mode 100644
index 0000000..7d81fb1
--- /dev/null
+++ b/test/option/option--override.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('--override', '=foo .')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--random.py b/test/option/option--random.py
new file mode 100644
index 0000000..1dafca4
--- /dev/null
+++ b/test/option/option--random.py
@@ -0,0 +1,121 @@
+#!/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.
+
+"""
+Verify that we build correctly using the --random option.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConscript', """\
+def cat(env, source, target):
+ target = str(target[0])
+ with open(target, "wb") as f:
+ for src in source:
+ with open(str(src), "rb") as ifp:
+ f.write(ifp.read())
+env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env.Cat('aaa.out', 'aaa.in')
+env.Cat('bbb.out', 'bbb.in')
+env.Cat('ccc.out', 'ccc.in')
+env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out'])
+""")
+
+test.write('aaa.in', "aaa.in\n")
+test.write('bbb.in', "bbb.in\n")
+test.write('ccc.in', "ccc.in\n")
+
+
+
+test.write('SConstruct', """\
+SetOption('random', 1)
+SConscript('SConscript')
+""")
+
+test.run(arguments = '-n -Q')
+non_random_output = test.stdout()
+
+tries = 0
+max_tries = 10
+while test.stdout() == non_random_output:
+ if tries >= max_tries:
+ print("--random generated the non-random output %s times!" % max_tries)
+ test.fail_test()
+ tries = tries + 1
+ test.run(arguments = '-n -Q --random')
+
+
+
+test.write('SConstruct', """\
+SConscript('SConscript')
+""")
+
+test.run(arguments = '-n -Q')
+non_random_output = test.stdout()
+
+tries = 0
+max_tries = 10
+while test.stdout() == non_random_output:
+ if tries >= max_tries:
+ print("--random generated the non-random output %s times!" % max_tries)
+ test.fail_test()
+ tries = tries + 1
+ test.run(arguments = '-n -Q --random')
+
+
+
+test.run(arguments = '-Q --random')
+
+test.must_match('all', "aaa.in\nbbb.in\nccc.in\n")
+
+test.run(arguments = '-q --random .')
+
+test.run(arguments = '-c --random .')
+
+test.must_not_exist(test.workpath('aaa.out'))
+test.must_not_exist(test.workpath('bbb.out'))
+test.must_not_exist(test.workpath('ccc.out'))
+test.must_not_exist(test.workpath('all'))
+
+test.run(arguments = '-q --random .', status = 1)
+
+test.run(arguments = '--random .')
+
+test.must_match('all', "aaa.in\nbbb.in\nccc.in\n")
+
+test.run(arguments = '-c --random .')
+
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--tree.py b/test/option/option--tree.py
new file mode 100644
index 0000000..5192ac0
--- /dev/null
+++ b/test/option/option--tree.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__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.run(arguments='-Q --tree=prune',
+ stdout="""scons: `.' is up to date.
++-.
+ +-SConstruct
+""")
+
+test.run(arguments='-Q --tree=foofoo',
+ stderr="""usage: scons [OPTION] [TARGET] ...
+
+SCons Error: `foofoo' is not a valid --tree option type, try:
+ all, derived, prune, status, linedraw
+""",
+ status=2)
+
+
+# Test that unicode characters can be printed (escaped) with the --tree option
+test.write('SConstruct', """\
+env = Environment()
+env.Tool("textfile")
+name = "français"
+env.Textfile("Foo", name)
+""")
+
+uchar = chr(0xe7)
+
+expected = """Creating 'Foo.txt'
++-.
+ +-Foo.txt
+ | +-fran%sais
+ +-SConstruct
+""" % uchar
+
+test.run(arguments='-Q --tree=all', stdout=expected, status=0)
+
+# Test the "linedraw" option: same basic test as previous.
+# With "--tree=linedraw" must default to "all", and use line-drawing chars.
+test.write('SConstruct', """\
+env = Environment()
+env.Tool("textfile")
+name = "français"
+env.Textfile("LineDraw", name)
+""")
+
+expected = """Creating 'LineDraw.txt'
+└─┬.
+ ├─┬LineDraw.txt
+ │ └─fran%sais
+ └─SConstruct
+""" % uchar
+
+
+test.run(arguments='-Q --tree=linedraw', stdout=expected, status=0)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--wf.py b/test/option/option--wf.py
new file mode 100644
index 0000000..79824f3
--- /dev/null
+++ b/test/option/option--wf.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('--write-filenames', '=FILE .')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option--wuv.py b/test/option/option--wuv.py
new file mode 100644
index 0000000..c684528
--- /dev/null
+++ b/test/option/option--wuv.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+# We want to preserve the --warn-undefined-variables option for
+# compatibility with GNU Make. Unfortunately, this conflicts with
+# the --warn=type option that we're using for our own warning
+# control. The getopt module reports "--warn not a unique prefix"
+# when both are defined. We may be able to support both in the
+# future with a more robust getopt solution.
+test.pass_test() #XXX Short-circuit until then.
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('--warn-undefined-variables')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-b.py b/test/option/option-b.py
new file mode 100644
index 0000000..5a1e645
--- /dev/null
+++ b/test/option/option-b.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.run(arguments = '-b .',
+ stderr = "Warning: ignoring -b option\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/option/option-f.py b/test/option/option-f.py
new file mode 100644
index 0000000..94e7e46
--- /dev/null
+++ b/test/option/option-f.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__"
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('subdir')
+
+subdir_BuildThis = os.path.join('subdir', 'Buildthis')
+
+test.write('SConscript', """
+DefaultEnvironment(tools=[])
+import os
+print("SConscript " + os.getcwd())
+""")
+
+test.write(subdir_BuildThis, """
+DefaultEnvironment(tools=[])
+import os
+print("subdir/BuildThis "+ os.getcwd())
+""")
+
+test.write('Build2', """
+DefaultEnvironment(tools=[])
+import os
+print("Build2 "+ os.getcwd())
+""")
+
+wpath = test.workpath()
+
+test.run(arguments = '-f SConscript .',
+ stdout = test.wrap_stdout(read_str = 'SConscript %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '-f %s .' % subdir_BuildThis,
+ stdout = test.wrap_stdout(read_str = 'subdir/BuildThis %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--file=SConscript .',
+ stdout = test.wrap_stdout(read_str = 'SConscript %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--file=%s .' % subdir_BuildThis,
+ stdout = test.wrap_stdout(read_str = 'subdir/BuildThis %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--makefile=SConscript .',
+ stdout = test.wrap_stdout(read_str = 'SConscript %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--makefile=%s .' % subdir_BuildThis,
+ stdout = test.wrap_stdout(read_str = 'subdir/BuildThis %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--sconstruct=SConscript .',
+ stdout = test.wrap_stdout(read_str = 'SConscript %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '--sconstruct=%s .' % subdir_BuildThis,
+ stdout = test.wrap_stdout(read_str = 'subdir/BuildThis %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+test.run(arguments = '-f - .', stdin = """
+DefaultEnvironment(tools=[])
+import os
+print("STDIN " + os.getcwd())
+""",
+ stdout = test.wrap_stdout(read_str = 'STDIN %s\n' % wpath,
+ build_str = "scons: `.' is up to date.\n"))
+
+expect = test.wrap_stdout(read_str = 'Build2 %s\nSConscript %s\n' % (wpath, wpath),
+ build_str = "scons: `.' is up to date.\n")
+test.run(arguments = '-f Build2 -f SConscript .', stdout=expect)
+
+test.run(arguments = '-f no_such_file .',
+ stdout = test.wrap_stdout("scons: `.' is up to date.\n"),
+ stderr = None)
+expect = """
+scons: warning: Calling missing SConscript without error is deprecated.
+Transition by adding must_exist=0 to SConscript calls.
+Missing SConscript 'no_such_file'"""
+stderr = test.stderr()
+test.must_contain_all(test.stderr(), expect)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-i.py b/test/option/option-i.py
new file mode 100644
index 0000000..9b5212d
--- /dev/null
+++ b/test/option/option-i.py
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.write('succeed.py', r"""
+import sys
+file = open(sys.argv[1], 'w')
+file.write("succeed.py: %s\n" % sys.argv[1])
+file.close()
+sys.exit(0)
+""")
+
+test.write('fail.py', r"""
+import sys
+sys.exit(1)
+""")
+
+test.write('SConstruct', """
+Succeed = Builder(action = r'%(_python_)s succeed.py $TARGETS')
+Fail = Builder(action = r'%(_python_)s fail.py $TARGETS')
+env = Environment(BUILDERS = { 'Succeed' : Succeed, 'Fail' : Fail })
+env.Fail(target = 'aaa.1', source = 'aaa.in')
+env.Succeed(target = 'aaa.out', source = 'aaa.1')
+env.Fail(target = 'bbb.1', source = 'bbb.in')
+env.Succeed(target = 'bbb.out', source = 'bbb.1')
+""" % locals())
+
+test.write('aaa.in', "aaa.in\n")
+test.write('bbb.in', "bbb.in\n")
+
+test.run(arguments = 'aaa.1 aaa.out bbb.1 bbb.out',
+ stderr = 'scons: *** [aaa.1] Error 1\n',
+ status = 2)
+
+test.fail_test(os.path.exists(test.workpath('aaa.1')))
+test.fail_test(os.path.exists(test.workpath('aaa.out')))
+test.fail_test(os.path.exists(test.workpath('bbb.1')))
+test.fail_test(os.path.exists(test.workpath('bbb.out')))
+
+test.run(arguments = '-i aaa.1 aaa.out bbb.1 bbb.out',
+ stderr =
+ 'scons: *** [aaa.1] Error 1\n'
+ 'scons: *** [bbb.1] Error 1\n')
+
+test.fail_test(os.path.exists(test.workpath('aaa.1')))
+test.fail_test(test.read('aaa.out',mode='r') != "succeed.py: aaa.out\n")
+test.fail_test(os.path.exists(test.workpath('bbb.1')))
+test.fail_test(test.read('bbb.out',mode='r') != "succeed.py: bbb.out\n")
+
+test.unlink("aaa.out")
+test.unlink("bbb.out")
+
+test.run(arguments='--ignore-errors aaa.1 aaa.out bbb.1 bbb.out',
+ stderr='scons: *** [aaa.1] Error 1\n'
+ 'scons: *** [bbb.1] Error 1\n')
+
+test.fail_test(os.path.exists(test.workpath('aaa.1')))
+test.fail_test(test.read('aaa.out', mode='r') != "succeed.py: aaa.out\n")
+test.fail_test(os.path.exists(test.workpath('bbb.1')))
+test.fail_test(test.read('bbb.out', mode='r') != "succeed.py: bbb.out\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/option/option-j.py b/test/option/option-j.py
new file mode 100644
index 0000000..0b0078f
--- /dev/null
+++ b/test/option/option-j.py
@@ -0,0 +1,230 @@
+#!/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.
+#
+
+"""
+This tests the -j command line option, and the num_jobs
+SConscript settable option.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+import sys
+
+import TestSCons
+
+
+_python_ = TestSCons._python_
+
+try:
+ import threading
+except ImportError:
+ # if threads are not supported, then
+ # there is nothing to test
+ TestCmd.no_result()
+ sys.exit()
+
+
+test = TestSCons.TestSCons()
+
+test.write('build.py', r"""
+import time
+import sys
+with open(sys.argv[1], 'w') as f:
+ f.write(str(time.time()) + '\n')
+ time.sleep(1)
+ f.write(str(time.time()))
+""")
+
+test.subdir('foo')
+
+test.write(['foo','foo.in'], r"""
+foo you
+""")
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGETS')
+env = Environment(BUILDERS={'MyBuild': MyBuild}, tools=[])
+env.Tool('install')
+env.MyBuild(target='f1', source='f1.in')
+env.MyBuild(target='f2', source='f2.in')
+
+def copyn(env, target, source):
+ import shutil
+ import time
+ time.sleep(1)
+ for t in target:
+ shutil.copy(str(source[0]), str(t))
+
+t = env.Command(target=['foo/foo1.out', 'foo/foo2.out'],
+ source='foo/foo.in',
+ action=copyn)
+env.Install('out', t)
+""" % locals())
+
+def RunTest(args, extra):
+ """extra is used to make scons rebuild the output file"""
+ test.write('f1.in', 'f1.in'+extra)
+ test.write('f2.in', 'f2.in'+extra)
+
+ test.run(arguments = args)
+
+ str = test.read("f1", mode='r')
+ start1,finish1 = list(map(float, str.split("\n")))
+
+ str = test.read("f2", mode='r')
+ start2,finish2 = list(map(float, str.split("\n")))
+
+ return start2, finish1
+
+# Test 2 parallel jobs.
+# fail if the second file was not started
+# before the first one was finished.
+start2, finish1 = RunTest('-j 2 f1 f2', "first")
+test.fail_test(not (start2 < finish1))
+
+# re-run the test with the same input, fail if we don't
+# get back the same times, which would indicate that
+# SCons rebuilt the files even though nothing changed
+s2, f1 = RunTest('-j 2 f1 f2', "first")
+test.fail_test(start2 != s2)
+test.fail_test(finish1 != f1)
+
+# Test a single serial job.
+# fail if the second file was started
+# before the first one was finished
+start2, finish1 = RunTest('f1 f2', "second")
+test.fail_test(start2 < finish1)
+
+# Make sure that a parallel build using a list builder
+# succeeds.
+test.run(arguments='-j 2 out')
+
+if sys.platform != 'win32' and sys.version_info[0] == 2:
+ # Test breaks on win32 when using real subprocess is not the only
+ # package to import threading
+ #
+ # Test that we fall back and warn properly if there's no threading.py
+ # module (simulated), which is the case if this version of Python wasn't
+ # built with threading support.
+
+ test.subdir('pythonlib')
+
+ test.write(['pythonlib', 'threading.py'], "raise ImportError\n")
+
+ save_pythonpath = os.environ.get('PYTHONPATH', '')
+ os.environ['PYTHONPATH'] = test.workpath('pythonlib')
+
+ #start2, finish1 = RunTest('-j 2 f1, f2', "fifth")
+
+ test.write('f1.in', 'f1.in pythonlib\n')
+ test.write('f2.in', 'f2.in pythonlib\n')
+
+ test.run(arguments = "-j 2 f1 f2", stderr=None)
+
+ warn = """scons: warning: parallel builds are unsupported by this version of Python;
+\tignoring -j or num_jobs option."""
+ test.must_contain_all_lines(test.stderr(), [warn])
+
+ str = test.read("f1", mode='r')
+ start1,finish1 = list(map(float, str.split("\n")))
+
+ str = test.read("f2", mode='r')
+ start2,finish2 = list(map(float, str.split("\n")))
+
+ test.fail_test(start2 < finish1)
+
+ os.environ['PYTHONPATH'] = save_pythonpath
+
+
+# Test SetJobs() with no -j:
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+MyBuild = Builder(action=r'%(_python_)s build.py $TARGETS')
+env = Environment(BUILDERS={'MyBuild': MyBuild}, tools=[])
+env.Tool('install')
+env.MyBuild(target = 'f1', source = 'f1.in')
+env.MyBuild(target = 'f2', source = 'f2.in')
+
+def copyn(env, target, source):
+ import shutil
+ import time
+ time.sleep(1)
+ for t in target:
+ shutil.copy(str(source[0]), str(t))
+
+t = env.Command(target=['foo/foo1.out', 'foo/foo2.out'], source='foo/foo.in', action=copyn)
+env.Install('out', t)
+
+assert GetOption('num_jobs') == 1
+SetOption('num_jobs', 2)
+assert GetOption('num_jobs') == 2
+""" % locals())
+
+# This should be a parallel build because the SConscript sets jobs to 2.
+# fail if the second file was not started
+# before the first one was finished
+start2, finish1 = RunTest('f1 f2', "third")
+test.fail_test(not (start2 < finish1))
+
+# Test SetJobs() with -j:
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGETS')
+env = Environment(BUILDERS = {'MyBuild': MyBuild}, tools=[])
+env.Tool('install')
+env.MyBuild(target='f1', source='f1.in')
+env.MyBuild(target='f2', source='f2.in')
+
+def copyn(env, target, source):
+ import shutil
+ import time
+ time.sleep(1)
+ for t in target:
+ shutil.copy(str(source[0]), str(t))
+
+t = env.Command(target=['foo/foo1.out', 'foo/foo2.out'], source='foo/foo.in', action=copyn)
+env.Install('out', t)
+
+assert GetOption('num_jobs') == 1
+SetOption('num_jobs', 2)
+assert GetOption('num_jobs') == 1
+""" % locals())
+
+# This should be a serial build since -j 1 overrides the call to SetJobs().
+# fail if the second file was started
+# before the first one was finished
+start2, finish1 = RunTest('-j 1 f1 f2', "fourth")
+test.fail_test(start2 < finish1)
+
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-k.py b/test/option/option-k.py
new file mode 100644
index 0000000..d6c81ea
--- /dev/null
+++ b/test/option/option-k.py
@@ -0,0 +1,303 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.subdir('work1', 'work2', 'work3')
+
+
+
+test.write('succeed.py', r"""
+import sys
+file = open(sys.argv[1], 'w')
+file.write("succeed.py: %s\n" % sys.argv[1])
+file.close()
+sys.exit(0)
+""")
+
+test.write('fail.py', r"""
+import sys
+sys.exit(1)
+""")
+
+
+#
+# Test: work1
+#
+
+test.write(['work1', 'SConstruct'], """\
+DefaultEnvironment(tools=[])
+Succeed = Builder(action=r'%(_python_)s ../succeed.py $TARGETS')
+Fail = Builder(action=r'%(_python_)s ../fail.py $TARGETS')
+env = Environment(BUILDERS={'Succeed': Succeed, 'Fail': Fail}, tools=[])
+env.Fail(target='aaa.1', source='aaa.in')
+env.Succeed(target='aaa.out', source='aaa.1')
+env.Succeed(target='bbb.out', source='bbb.in')
+""" % locals())
+
+test.write(['work1', 'aaa.in'], "aaa.in\n")
+test.write(['work1', 'bbb.in'], "bbb.in\n")
+
+test.run(chdir='work1',
+ arguments='aaa.out bbb.out',
+ stderr='scons: *** [aaa.1] Error 1\n',
+ status=2)
+
+test.must_not_exist(test.workpath('work1', 'aaa.1'))
+test.must_not_exist(test.workpath('work1', 'aaa.out'))
+test.must_not_exist(test.workpath('work1', 'bbb.out'))
+
+test.run(chdir='work1',
+ arguments='-k aaa.out bbb.out',
+ stderr='scons: *** [aaa.1] Error 1\n',
+ status=2)
+
+test.must_not_exist(test.workpath('work1', 'aaa.1'))
+test.must_not_exist(test.workpath('work1', 'aaa.out'))
+test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r')
+
+test.unlink(['work1', 'bbb.out'])
+
+test.run(chdir = 'work1',
+ arguments='--keep-going aaa.out bbb.out',
+ stderr='scons: *** [aaa.1] Error 1\n',
+ status=2)
+
+test.must_not_exist(test.workpath('work1', 'aaa.1'))
+test.must_not_exist(test.workpath('work1', 'aaa.out'))
+test.must_match(['work1', 'bbb.out'], "succeed.py: bbb.out\n", mode='r')
+
+expect = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Cleaning targets ...
+Removed bbb.out
+scons: done cleaning targets.
+"""
+
+test.run(chdir='work1',
+ arguments='--clean --keep-going aaa.out bbb.out',
+ stdout=expect)
+
+test.must_not_exist(test.workpath('work1', 'aaa.1'))
+test.must_not_exist(test.workpath('work1', 'aaa.out'))
+test.must_not_exist(test.workpath('work1', 'bbb.out'))
+
+
+
+#
+# Test: work2
+#
+
+test.write(['work2', 'SConstruct'], """\
+DefaultEnvironment(tools=[])
+Succeed = Builder(action=r'%(_python_)s ../succeed.py $TARGETS')
+Fail = Builder(action=r'%(_python_)s ../fail.py $TARGETS')
+env = Environment(BUILDERS={'Succeed': Succeed, 'Fail': Fail}, tools=[])
+env.Fail('aaa.out', 'aaa.in')
+env.Succeed('bbb.out', 'aaa.out')
+env.Succeed('ccc.out', 'ccc.in')
+env.Succeed('ddd.out', 'ccc.in')
+""" % locals())
+
+test.write(['work2', 'aaa.in'], "aaa.in\n")
+test.write(['work2', 'ccc.in'], "ccc.in\n")
+
+test.run(chdir='work2',
+ arguments='-k .',
+ status=2,
+ stderr=None,
+ stdout="""\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Building targets ...
+%(_python_)s ../fail.py aaa.out
+%(_python_)s ../succeed.py ccc.out
+%(_python_)s ../succeed.py ddd.out
+scons: done building targets (errors occurred during build).
+""" % locals())
+
+test.must_not_exist(['work2', 'aaa.out'])
+test.must_not_exist(['work2', 'bbb.out'])
+test.must_match(['work2', 'ccc.out'], "succeed.py: ccc.out\n", mode='r')
+test.must_match(['work2', 'ddd.out'], "succeed.py: ddd.out\n", mode='r')
+
+
+
+#
+# Test: work3
+#
+# Check that the -k (keep-going) switch works correctly when the Nodes
+# forms a DAG. The test case is the following
+#
+# all
+# |
+# +-----+-----+-------------+
+# | | |
+# a1 a2 a3
+# | | |
+# + +---+---+ +---+---+
+# \ | / | |
+# \ bbb.out / a4 ccc.out
+# \ / /
+# \ / /
+# \ / /
+# aaa.out (fails)
+#
+
+test.write(['work3', 'SConstruct'], """\
+DefaultEnvironment(tools=[])
+Succeed = Builder(action = r'%(_python_)s ../succeed.py $TARGETS')
+Fail = Builder(action = r'%(_python_)s ../fail.py $TARGETS')
+env = Environment(BUILDERS = {'Succeed': Succeed, 'Fail': Fail}, tools=[])
+a = env.Fail('aaa.out', 'aaa.in')
+b = env.Succeed('bbb.out', 'bbb.in')
+c = env.Succeed('ccc.out', 'ccc.in')
+
+a1 = Alias( 'a1', a )
+a2 = Alias( 'a2', a+b)
+a4 = Alias( 'a4', c)
+a3 = Alias( 'a3', a4+c)
+
+Alias('all', a1+a2+a3)
+""" % locals())
+
+test.write(['work3', 'aaa.in'], "aaa.in\n")
+test.write(['work3', 'bbb.in'], "bbb.in\n")
+test.write(['work3', 'ccc.in'], "ccc.in\n")
+
+
+# Test tegular build (i.e. without -k)
+test.run(chdir = 'work3',
+ arguments = '.',
+ status = 2,
+ stderr = None,
+ stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Building targets ...
+%(_python_)s ../fail.py aaa.out
+scons: building terminated because of errors.
+""" % locals())
+
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_not_exist(['work3', 'bbb.out'])
+test.must_not_exist(['work3', 'ccc.out'])
+
+
+test.run(chdir = 'work3',
+ arguments = '-c .')
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_not_exist(['work3', 'bbb.out'])
+test.must_not_exist(['work3', 'ccc.out'])
+
+
+# Current directory
+test.run(chdir = 'work3',
+ arguments = '-k .',
+ status = 2,
+ stderr = None,
+ stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Building targets ...
+%(_python_)s ../fail.py aaa.out
+%(_python_)s ../succeed.py bbb.out
+%(_python_)s ../succeed.py ccc.out
+scons: done building targets (errors occurred during build).
+""" % locals())
+
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_exist(['work3', 'bbb.out'])
+test.must_exist(['work3', 'ccc.out'])
+
+
+test.run(chdir = 'work3',
+ arguments = '-c .')
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_not_exist(['work3', 'bbb.out'])
+test.must_not_exist(['work3', 'ccc.out'])
+
+
+# Single target
+test.run(chdir = 'work3',
+ arguments = '--keep-going all',
+ status = 2,
+ stderr = None,
+ stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Building targets ...
+%(_python_)s ../fail.py aaa.out
+%(_python_)s ../succeed.py bbb.out
+%(_python_)s ../succeed.py ccc.out
+scons: done building targets (errors occurred during build).
+""" % locals())
+
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_exist(['work3', 'bbb.out'])
+test.must_exist(['work3', 'ccc.out'])
+
+
+test.run(chdir = 'work3',
+ arguments = '-c .')
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_not_exist(['work3', 'bbb.out'])
+test.must_not_exist(['work3', 'ccc.out'])
+
+
+# Separate top-level targets
+test.run(chdir = 'work3',
+ arguments = '-k a1 a2 a3',
+ status = 2,
+ stderr = None,
+ stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+scons: Building targets ...
+%(_python_)s ../fail.py aaa.out
+%(_python_)s ../succeed.py bbb.out
+%(_python_)s ../succeed.py ccc.out
+scons: done building targets (errors occurred during build).
+""" % locals())
+
+test.must_not_exist(['work3', 'aaa.out'])
+test.must_exist(['work3', 'bbb.out'])
+test.must_exist(['work3', 'ccc.out'])
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-l.py b/test/option/option-l.py
new file mode 100644
index 0000000..af308af
--- /dev/null
+++ b/test/option/option-l.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('-l', '1 .')
+
+test.option_not_yet_implemented('--load-average', '=1 .')
+
+test.option_not_yet_implemented('--max-load', '=1 .')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-m.py b/test/option/option-m.py
new file mode 100644
index 0000000..319b4f7
--- /dev/null
+++ b/test/option/option-m.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.run(arguments = '-m .',
+ stderr = "Warning: ignoring -m option\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/option/option-n.py b/test/option/option-n.py
new file mode 100644
index 0000000..e647b8e
--- /dev/null
+++ b/test/option/option-n.py
@@ -0,0 +1,243 @@
+#!/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.
+#
+
+"""
+This test verifies:
+ 1) that we don't build files when we use the -n, --no-exec,
+ --just-print, --dry-run, and --recon options;
+ 2) that we don't remove built files when -n is used in
+ conjunction with -c;
+ 3) that files installed by the Install() method don't get
+ installed when -n is used;
+ 4) that source files don't get duplicated in a VariantDir
+ when -n is used.
+ 5) that Configure calls don't build any files. If a file
+ needs to be built (i.e. is not up-to-date), a ConfigureError
+ is raised.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import re
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.subdir('build', 'src')
+
+test.write('build.py', r"""
+import sys
+with open(sys.argv[1], 'w') as ofp:
+ ofp.write("build.py: %s\n" % sys.argv[1])
+""")
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+MyBuild = Builder(action=r'%(_python_)s build.py $TARGETS')
+env = Environment(BUILDERS={'MyBuild': MyBuild}, tools=[])
+env.Tool('install')
+env.MyBuild(target='f1.out', source='f1.in')
+env.MyBuild(target='f2.out', source='f2.in')
+env.Install('install', 'f3.in')
+VariantDir('build', 'src', duplicate=1)
+SConscript('build/SConscript', "env")
+""" % locals())
+
+test.write(['src', 'SConscript'], """
+Import("env")
+env.MyBuild(target='f4.out', source='f4.in')
+""")
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+test.write('f3.in', "f3.in\n")
+test.write(['src', 'f4.in'], "src/f4.in\n")
+
+args = 'f1.out f2.out'
+expect = test.wrap_stdout("""\
+%(_python_)s build.py f1.out
+%(_python_)s build.py f2.out
+""" % locals())
+
+test.run(arguments=args, stdout=expect)
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+test.unlink('f1.out')
+test.unlink('f2.out')
+
+test.run(arguments='-n ' + args, stdout=expect)
+test.fail_test(os.path.exists(test.workpath('f1.out')))
+test.fail_test(os.path.exists(test.workpath('f2.out')))
+
+test.run(arguments='--no-exec ' + args, stdout=expect)
+test.fail_test(os.path.exists(test.workpath('f1.out')))
+test.fail_test(os.path.exists(test.workpath('f2.out')))
+
+test.run(arguments='--just-print ' + args, stdout=expect)
+test.fail_test(os.path.exists(test.workpath('f1.out')))
+test.fail_test(os.path.exists(test.workpath('f2.out')))
+
+test.run(arguments='--dry-run ' + args, stdout=expect)
+test.fail_test(os.path.exists(test.workpath('f1.out')))
+test.fail_test(os.path.exists(test.workpath('f2.out')))
+
+test.run(arguments='--recon ' + args, stdout=expect)
+test.fail_test(os.path.exists(test.workpath('f1.out')))
+test.fail_test(os.path.exists(test.workpath('f2.out')))
+
+test.run(arguments=args)
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+
+# Test that SCons does not write a modified .sconsign when -n is used.
+expect = test.wrap_stdout("""\
+%(_python_)s build.py f1.out
+""" % locals())
+test.unlink('.sconsign.dblite')
+test.write('f1.out', "X1.out\n")
+test.run(arguments='-n f1.out', stdout=expect)
+test.run(arguments='-n f1.out', stdout=expect)
+
+expect = test.wrap_stdout("Removed f1.out\nRemoved f2.out\n", cleaning=1)
+
+test.run(arguments='-n -c ' + args, stdout=expect)
+
+test.run(arguments='-c -n ' + args, stdout=expect)
+
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+#
+install_f3_in = os.path.join('install', 'f3.in')
+expect = test.wrap_stdout('Install file: "f3.in" as "%s"\n' % install_f3_in)
+
+test.run(arguments='-n install', stdout=expect)
+test.fail_test(os.path.exists(test.workpath('install', 'f3.in')))
+
+test.run(arguments='install', stdout=expect)
+test.fail_test(not os.path.exists(test.workpath('install', 'f3.in')))
+
+test.write('f3.in', "f3.in again\n")
+
+test.run(arguments='-n install', stdout=expect)
+test.fail_test(not os.path.exists(test.workpath('install', 'f3.in')))
+
+# Make sure duplicate source files in a VariantDir aren't created
+# when the -n option is used.
+
+# First, make sure none of the previous non-dryrun invocations caused
+# the build directory to be populated. Processing of the
+# src/SConscript (actually build/SConscript) will reference f4.in as a
+# source, causing a Node object to be built for "build/f4.in".
+# Creating the node won't cause "build/f4.in" to be created from
+# "src/f4.in", but that *is* a side-effect of calling the exists()
+# method on that node, which may happen via other processing.
+# Therefore add this conditional removal to ensure a clean setting
+# before running this test.
+
+if os.path.exists(test.workpath('build', 'f4.in')):
+ test.unlink(test.workpath('build', 'f4.in'))
+
+test.run(arguments='-n build')
+test.fail_test(os.path.exists(test.workpath('build', 'f4.in')))
+
+# test Configure-calls in conjunction with -n
+test.subdir('configure')
+test.set_match_function(TestSCons.match_re_dotall)
+test.set_diff_function(TestSCons.diff_re)
+test.write('configure/SConstruct', """\
+DefaultEnvironment(tools=[])
+def CustomTest(context):
+ def userAction(target,source,env):
+ import shutil
+ shutil.copyfile( str(source[0]), str(target[0]))
+ def strAction(target,source,env):
+ return "cp " + str(source[0]) + " " + str(target[0])
+ context.Message("Executing Custom Test ... " )
+ (ok, msg) = context.TryAction(Action(userAction,strAction),
+ "Hello World", ".in")
+ context.Result(ok)
+ return ok
+
+env = Environment(tools=[])
+conf = Configure(env,
+ custom_tests={'CustomTest':CustomTest},
+ conf_dir="config.test",
+ log_file="config.log")
+if not conf.CustomTest():
+ Exit(1)
+else:
+ env = conf.Finish()
+""")
+# test that conf_dir isn't created and an error is raised
+stderr = r"""
+scons: \*\*\* Cannot create configure directory "config\.test" within a dry-run\.
+File \S+, line \S+, in \S+
+"""
+test.run(arguments="-n", stderr=stderr, status=2,
+ chdir=test.workpath("configure"))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.log")))
+
+# test that targets are not built, if conf_dir exists.
+# verify that .cache and config.log are not created.
+# an error should be raised
+stderr = r"""
+scons: \*\*\* Cannot update configure test "%s" within a dry-run\.
+File \S+, line \S+, in \S+
+""" % re.escape(os.path.join("config.test", "conftest_b10a8db164e0754105b7a99be72e3fe5_0.in"))
+test.subdir(['configure', 'config.test'])
+test.run(arguments="-n", stderr=stderr, status=2,
+ chdir=test.workpath("configure"))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test",
+ ".cache")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test",
+ "conftest_0")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test",
+ "conftest_0.in")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.log")))
+
+# test that no error is raised, if all targets are up-to-date. In this
+# case .cache and config.log shouldn't be created
+stdout = test.wrap_stdout(build_str="scons: `.' is up to date.\n",
+ read_str=r"""Executing Custom Test ... \(cached\) yes
+""")
+test.run(status=0, chdir=test.workpath("configure"))
+log1_mtime = os.path.getmtime(test.workpath("configure", "config.log"))
+test.run(stdout=stdout, arguments="-n", status=0,
+ chdir=test.workpath("configure"))
+log2_mtime = os.path.getmtime(test.workpath("configure", "config.log"))
+test.fail_test(log1_mtime != log2_mtime)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-o.py b/test/option/option-o.py
new file mode 100644
index 0000000..bde8e8f
--- /dev/null
+++ b/test/option/option-o.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('-o', 'foo .')
+
+test.option_not_yet_implemented('--old-file', '=foo .')
+
+test.option_not_yet_implemented('--assume-old', '=foo .')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-p.py b/test/option/option-p.py
new file mode 100644
index 0000000..11390ab
--- /dev/null
+++ b/test/option/option-p.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('-p', '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-r.py b/test/option/option-r.py
new file mode 100644
index 0000000..a3c3911
--- /dev/null
+++ b/test/option/option-r.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.option_not_yet_implemented('-r', '.')
+
+test.option_not_yet_implemented('--no-builtin-rules', '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-s.py b/test/option/option-s.py
new file mode 100644
index 0000000..89a0c62
--- /dev/null
+++ b/test/option/option-s.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os.path
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+test.write('build.py', r"""
+import sys
+file = open(sys.argv[1], 'w')
+file.write("build.py: %s\n" % sys.argv[1])
+file.close()
+""")
+
+test.write('SConstruct', """
+DefaultEnvironment(tools=[])
+MyBuild = Builder(action = r'%(_python_)s build.py $TARGET')
+
+silent = ARGUMENTS.get('QUIET',0)
+if silent:
+ SetOption('silent',True)
+
+env = Environment(BUILDERS={'MyBuild': MyBuild}, tools=[])
+env.MyBuild(target='f1.out', source='f1.in')
+env.MyBuild(target='f2.out', source='f2.in')
+""" % locals())
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+
+test.run(arguments='-s f1.out f2.out', stdout="")
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+test.unlink('f1.out')
+test.unlink('f2.out')
+
+test.run(arguments='--silent f1.out f2.out', stdout="")
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+test.unlink('f1.out')
+test.unlink('f2.out')
+
+test.run(arguments='--quiet f1.out f2.out', stdout="")
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+# -C should also be quiet Issue#2796
+test.subdir( 'sub' )
+test.write(['sub','SConstruct'],"")
+test.run(arguments='-s -C sub', stdout="" )
+
+test.unlink('f1.out')
+test.unlink('f2.out')
+
+test.run(arguments='QUIET=1 f1.out f2.out',
+ stdout="scons: Reading SConscript files ...\nscons: done reading SConscript files.\n")
+test.fail_test(not os.path.exists(test.workpath('f1.out')))
+test.fail_test(not os.path.exists(test.workpath('f2.out')))
+
+
+
+test.pass_test()
+
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-t.py b/test/option/option-t.py
new file mode 100644
index 0000000..f7ec081
--- /dev/null
+++ b/test/option/option-t.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.run(arguments = '-t .',
+ stderr = "Warning: ignoring -t option\n")
+
+test.run(arguments = '--touch .',
+ stderr = "Warning: ignoring --touch option\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/option/option-unknown.py b/test/option/option-unknown.py
new file mode 100644
index 0000000..8b42762
--- /dev/null
+++ b/test/option/option-unknown.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', "")
+
+test.run(arguments = '-Z',
+ stderr = """usage: scons [OPTION] [TARGET] ...
+
+SCons Error: no such option: -Z
+""",
+ status = 2)
+
+test.run(arguments = '--ZizzerZazzerZuzz',
+ stderr = """usage: scons [OPTION] [TARGET] ...
+
+SCons Error: no such option: --ZizzerZazzerZuzz
+""",
+ status = 2)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/option/option-v.py b/test/option/option-v.py
new file mode 100644
index 0000000..49dd84d
--- /dev/null
+++ b/test/option/option-v.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__"
+
+import TestCmd
+import TestSCons
+
+test = TestSCons.TestSCons(match = TestCmd.match_re)
+
+test.write('SConstruct', "")
+
+# Standard copyright marker is mangled so it doesn't get replaced
+# by the packaging build.
+copyright_line = """\
+(_{2}COPYRIGHT__|Copyright \\(c\\) 2001[-\\d, ]+ The SCons Foundation)
+"""
+
+
+expect2 = r"""SCons by Steven Knight et al.:
+\tSCons: v\S+, [^,]*, by \S+ on \S+
+\tSCons path: \[.*\]
+""" + copyright_line
+
+test.run(arguments = '-v')
+stdout = test.stdout()
+if not test.match_re(stdout, expect2):
+ print(stdout)
+ test.fail_test()
+
+test.run(arguments = '--version')
+stdout = test.stdout()
+if not test.match_re(stdout, expect2):
+ print(stdout)
+ test.fail_test()
+
+test.pass_test()
+
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: