summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-04-30 15:35:30 (GMT)
committerSteven Knight <knight@baldmt.com>2003-04-30 15:35:30 (GMT)
commit212d77d88aa4374ef13f2e6bc7edf3395ac9736c (patch)
tree464ca9fd18866613629e2381dfb6b93190a5e2e6 /test
parent7ff542f3fb5b361087ef2738a82b5d849e005d45 (diff)
downloadSCons-212d77d88aa4374ef13f2e6bc7edf3395ac9736c.zip
SCons-212d77d88aa4374ef13f2e6bc7edf3395ac9736c.tar.gz
SCons-212d77d88aa4374ef13f2e6bc7edf3395ac9736c.tar.bz2
Provide uniform access to (some) command-line options. (Anthony Roach)
Diffstat (limited to 'test')
-rw-r--r--test/option--implicit-cache.py47
-rw-r--r--test/option--max-drift.py41
-rw-r--r--test/option-c.py54
-rw-r--r--test/option-j.py18
4 files changed, 150 insertions, 10 deletions
diff --git a/test/option--implicit-cache.py b/test/option--implicit-cache.py
index 0e5bf24..e959856 100644
--- a/test/option--implicit-cache.py
+++ b/test/option--implicit-cache.py
@@ -327,5 +327,52 @@ assert string.find(test.stdout(), 'is up to date') != -1, test.stdout()
test.run(arguments = "--implicit-deps-changed " + variant_prog)
assert string.find(test.stdout(), 'is up to date') == -1, test.stdout()
+# Test that Set/GetOption('implicit_cache') works:
+test.write('SConstruct', """
+assert not GetOption('implicit_cache')
+SetOption('implicit_cache', 1)
+assert GetOption('implicit_cache')
+""")
+
+test.run()
+
+test.write('SConstruct', """
+assert GetOption('implicit_cache')
+SetOption('implicit_cache', 0)
+assert GetOption('implicit_cache')
+""")
+
+test.run(arguments='--implicit-cache')
+
+# Test to make sure SetOption('implicit_cache', 1) actually enables implicit caching
+# by detecting the one case where implicit caching causes inaccurate builds:
+test.write('SConstruct', """
+SetOption('implicit_cache', 1)
+env=Environment(CPPPATH=['i1', 'i2'])
+env.Object('foo.c')
+""")
+
+test.subdir('i1')
+test.subdir('i2')
+
+test.write('foo.c', """
+#include <foo.h>
+
+int foo(void)
+{
+ FOO_H_DEFINED
+}
+""")
+
+test.write('i2/foo.h', """
+#define FOO_H_DEFINED int x = 1;
+""")
+
+test.run()
+
+test.write('i1/foo.h', """
+""");
+
+test.run()
test.pass_test()
diff --git a/test/option--max-drift.py b/test/option--max-drift.py
index 4dacb4d..3b90b68 100644
--- a/test/option--max-drift.py
+++ b/test/option--max-drift.py
@@ -88,5 +88,46 @@ test.run(arguments = '--max-drift=-1 f1.out f2.out',
scons: "f2.out" is up to date.
""" % python))
+# Test that Set/GetOption('max_drift') works:
+test.write('SConstruct', """
+assert GetOption('max_drift') == 2*24*60*60
+SetOption('max_drift', 1)
+assert GetOption('max_drift') == 1
+""")
+
+test.run()
+
+test.write('SConstruct', """
+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', """
+SetOption('max_drift', 0)
+B = Builder(action = r'%s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'foo.out', source = 'foo.in')
+""" % python)
+
+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.fail_test(test.read('foo.out') != 'foo.in\n')
+
+test.write('foo.in', 'foo.in delta\n')
+os.utime(test.workpath('foo.in'), (atime,mtime))
+
+test.run()
+
+test.fail_test(test.read('foo.out') != 'foo.in\n')
+
test.pass_test()
diff --git a/test/option-c.py b/test/option-c.py
index d545b10..482525d 100644
--- a/test/option-c.py
+++ b/test/option-c.py
@@ -193,7 +193,7 @@ Removed foo3.out
Removed %s
Removed %s
Removed directory subd
-""" % (os.path.join('subd', 'SConscript'), os.path.join('subd','foon.in')))
+""" % (os.path.join('subd','SConscript'), os.path.join('subd', 'foon.in')))
test.run(arguments = '-c -n .', stdout=expect)
expect = test.wrap_stdout("""Removed foo1.out
@@ -207,4 +207,56 @@ test.run(arguments = '-c .', stdout=expect)
test.fail_test(os.path.exists(test.workpath('subdir', 'foon.in')))
test.fail_test(os.path.exists(test.workpath('subdir')))
+
+# Ensure that Set/GetOption('clean') works correctly:
+test.write('SConstruct', """
+B = Builder(action = r'%s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'foo.out', source = 'foo.in')
+
+assert not GetOption('clean')
+"""%python)
+
+test.write('foo.in', '"Foo", I say!\n')
+
+test.run(arguments='foo.out')
+test.fail_test(test.read(test.workpath('foo.out')) != '"Foo", I say!\n')
+
+test.write('SConstruct', """
+B = Builder(action = r'%s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'foo.out', source = 'foo.in')
+
+assert GetOption('clean')
+SetOption('clean', 0)
+assert GetOption('clean')
+"""%python)
+
+test.run(arguments='-c foo.out')
+test.fail_test(os.path.exists(test.workpath('foo.out')))
+
+test.write('SConstruct', """
+B = Builder(action = r'%s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'foo.out', source = 'foo.in')
+"""%python)
+
+test.run(arguments='foo.out')
+test.fail_test(test.read(test.workpath('foo.out')) != '"Foo", I say!\n')
+
+test.write('SConstruct', """
+B = Builder(action = r'%s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'foo.out', source = 'foo.in')
+
+assert not GetOption('clean')
+SetOption('clean', 1)
+assert GetOption('clean')
+"""%python)
+
+test.run(arguments='foo.out')
+test.fail_test(os.path.exists(test.workpath('foo.out')))
+
test.pass_test()
+
+
diff --git a/test/option-j.py b/test/option-j.py
index bf80f02..cf41930 100644
--- a/test/option-j.py
+++ b/test/option-j.py
@@ -23,8 +23,8 @@
#
"""
-This tests the -j command line option, and the SetJobs() and GetJobs()
-SConscript functions.
+This tests the -j command line option, and the num_jobs
+SConscript settable option.
"""
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
@@ -134,12 +134,12 @@ def copyn(env, target, source):
t = env.Command(target=['foo/foo1.out', 'foo/foo2.out'], source='foo/foo.in', action=copyn)
env.Install('out', t)
-assert GetJobs() == 1
-SetJobs(2)
-assert GetJobs() == 2
+assert GetOption('num_jobs') == 1
+SetOption('num_jobs', 2)
+assert GetOption('num_jobs') == 2
""" % python)
-# This should be a prallel build because the SConscript sets jobs to 2.
+# 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")
@@ -162,9 +162,9 @@ def copyn(env, target, source):
t = env.Command(target=['foo/foo1.out', 'foo/foo2.out'], source='foo/foo.in', action=copyn)
env.Install('out', t)
-assert GetJobs() == 1
-SetJobs(2)
-assert GetJobs() == 1
+assert GetOption('num_jobs') == 1
+SetOption('num_jobs', 2)
+assert GetOption('num_jobs') == 1
""" % python)
# This should be a serial build since -j 1 overrides the call to SetJobs().