summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-07-12 06:17:59 (GMT)
committerSteven Knight <knight@baldmt.com>2002-07-12 06:17:59 (GMT)
commit721c0b5439329cce1a68d44c0e58204a83d9d354 (patch)
tree640ad8f81638eaf79461675d47418643fbb2e6b1 /test
parent25846c09acbebca4f41664a76dfc6175b3617e90 (diff)
downloadSCons-721c0b5439329cce1a68d44c0e58204a83d9d354.zip
SCons-721c0b5439329cce1a68d44c0e58204a83d9d354.tar.gz
SCons-721c0b5439329cce1a68d44c0e58204a83d9d354.tar.bz2
Added --implicit-deps-unchanged option. Added GetLaunchDir() function. Added SetBuildSignatureType() function. (Anthony Roach)
Diffstat (limited to 'test')
-rw-r--r--test/SetBuildSignatureType.py122
-rw-r--r--test/option--U.py6
-rw-r--r--test/option--implicit-cache.py31
3 files changed, 159 insertions, 0 deletions
diff --git a/test/SetBuildSignatureType.py b/test/SetBuildSignatureType.py
new file mode 100644
index 0000000..39534dd
--- /dev/null
+++ b/test/SetBuildSignatureType.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# 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', """
+env = Environment()
+
+def copy1(env, source, target):
+ print 'copy %s -> %s'%(str(source[0]), str(target[0]))
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+
+def copy2(env, source, target):
+ return copy1(env, source, target)
+
+env['BUILDERS']['Copy1'] = Builder(action=copy1)
+env['BUILDERS']['Copy2'] = Builder(action=copy2)
+
+env.Copy2('foo.out', 'foo.in')
+env.Copy1('foo.out.out', 'foo.out')
+
+SetBuildSignatureType('content')
+""")
+
+test.write('foo.in', 'foo.in')
+
+test.run(arguments='foo.out.out', stdout='copy foo.in -> foo.out\ncopy foo.out -> foo.out.out\n')
+
+test.run(arguments='foo.out.out', stdout='scons: "foo.out.out" is up to date.\n')
+
+test.write('SConstruct', """
+env = Environment()
+
+def copy1(env, source, target):
+ print 'copy %s -> %s'%(str(source[0]), str(target[0]))
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+
+def copy2(env, source, target):
+ # added this line
+ return copy1(env, source, target)
+
+env['BUILDERS']['Copy1'] = Builder(action=copy1)
+env['BUILDERS']['Copy2'] = Builder(action=copy2)
+
+env.Copy2('foo.out', 'foo.in')
+env.Copy1('foo.out.out', 'foo.out')
+
+SetBuildSignatureType('content')
+""")
+
+test.run(arguments='foo.out.out', stdout='copy foo.in -> foo.out\nscons: "foo.out.out" is up to date.\n')
+
+test.write('SConstruct', """
+env = Environment()
+
+def copy1(env, source, target):
+ print 'copy %s -> %s'%(str(source[0]), str(target[0]))
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+
+def copy2(env, source, target):
+ # added this line
+ return copy1(env, source, target)
+
+env['BUILDERS']['Copy1'] = Builder(action=copy1)
+env['BUILDERS']['Copy2'] = Builder(action=copy2)
+
+env.Copy2('foo.out', 'foo.in')
+env.Copy1('foo.out.out', 'foo.out')
+
+SetBuildSignatureType('build')
+""")
+
+test.run(arguments='foo.out.out', stdout='copy foo.out -> foo.out.out\n')
+
+test.write('SConstruct', """
+env = Environment()
+
+def copy1(env, source, target):
+ print 'copy %s -> %s'%(str(source[0]), str(target[0]))
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+
+def copy2(env, source, target):
+ return copy1(env, source, target)
+
+env['BUILDERS']['Copy1'] = Builder(action=copy1)
+env['BUILDERS']['Copy2'] = Builder(action=copy2)
+
+env.Copy2('foo.out', 'foo.in')
+env.Copy1('foo.out.out', 'foo.out')
+
+SetBuildSignatureType('build')
+""")
+
+test.run(arguments='foo.out.out', stdout='copy foo.in -> foo.out\ncopy foo.out -> foo.out.out\n')
+
+
+test.pass_test()
diff --git a/test/option--U.py b/test/option--U.py
index a683a8d..1facab8 100644
--- a/test/option--U.py
+++ b/test/option--U.py
@@ -54,6 +54,7 @@ Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in'))
BuildDir('sub2b', 'sub2')
SConscript('sub2b/SConscript')
Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in'))
+SConscript('SConscript')
""" % python)
test.write(['sub2', 'SConscript'], """
@@ -70,6 +71,7 @@ test.write(['sub2', 'bar.in'], "sub2/bar.in\n")
test.write(['sub3', 'baz.in'], "sub3/baz.in\n")
test.write('xxx.in', "xxx.in\n")
+test.write('SConscript', """assert GetLaunchDir() == '%s'"""%test.workpath('sub1'))
test.run(arguments = '-U foo.out', chdir = 'sub1')
test.fail_test(not os.path.exists(test.workpath('sub1', 'foo.out')))
@@ -81,6 +83,7 @@ test.fail_test(os.path.exists(test.workpath('sub2/xxx.out')))
test.unlink(['sub1', 'foo.out'])
+test.write('SConscript', """assert GetLaunchDir() == '%s'"""%test.workpath('sub1'))
test.run(arguments = '-U', chdir = 'sub1')
test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out')))
test.fail_test(os.path.exists(test.workpath('sub2', 'bar.out')))
@@ -89,6 +92,7 @@ test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out')))
test.fail_test(os.path.exists(test.workpath('bar.out')))
test.fail_test(os.path.exists(test.workpath('sub2/xxx.out')))
+test.write('SConscript', """assert GetLaunchDir() == '%s'"""%test.workpath('sub2'))
test.run(chdir = 'sub2', arguments = '-U')
test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out')))
test.fail_test(not os.path.exists(test.workpath('sub2', 'bar.out')))
@@ -101,6 +105,7 @@ test.unlink(['sub2', 'bar.out'])
test.unlink(['sub2b', 'bar.out'])
test.unlink('bar.out')
+test.write('SConscript', """assert GetLaunchDir() == '%s'"""%test.workpath())
test.run(arguments='-U')
test.fail_test(not os.path.exists(test.workpath('sub1', 'foo.out')))
test.fail_test(os.path.exists(test.workpath('sub2', 'bar.out')))
@@ -113,6 +118,7 @@ test.unlink(['sub1', 'foo.out'])
test.unlink(['sub3', 'baz.out'])
test.unlink(['sub2', 'xxx.out'])
+test.write('SConscript', """assert GetLaunchDir() == '%s'"""%test.workpath('sub3'))
test.run(chdir = 'sub3', arguments='-U bar')
test.fail_test(os.path.exists(test.workpath('sub1', 'foo.out')))
test.fail_test(not os.path.exists(test.workpath('sub2', 'bar.out')))
diff --git a/test/option--implicit-cache.py b/test/option--implicit-cache.py
index 3460b2f..d6ca15c 100644
--- a/test/option--implicit-cache.py
+++ b/test/option--implicit-cache.py
@@ -27,6 +27,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import sys
import TestSCons
+import string
if sys.platform == 'win32':
_exe = '.exe'
@@ -266,4 +267,34 @@ main(int argc, char *argv[])
test.run(arguments = "--implicit-cache one%s"%_obj)
test.run(arguments = "--implicit-cache one%s"%_obj)
+# Test forcing of implicit caching:
+test.write(['include', 'foo.h'],
+r"""
+#define FOO_STRING "include/foo.h 3\n"
+#include "bar.h"
+""")
+
+test.run(arguments = "--implicit-cache " + args)
+
+test.write(['include', 'foo.h'],
+r"""
+#define FOO_STRING "include/foo.h 3\n"
+#include "baz.h"
+#include "bar.h"
+""")
+
+test.run(arguments = "--implicit-deps-unchanged " + variant_prog)
+assert string.find(test.stdout(), 'is up to date') == -1, test.stdout()
+
+test.write(['include', 'baz.h'],
+r"""
+#define BAZ_STRING "include/baz.h 2\n"
+""")
+
+test.run(arguments = "--implicit-deps-unchanged " + variant_prog)
+assert string.find(test.stdout(), 'is up to date') != -1, test.stdout()
+
+test.run(arguments = variant_prog)
+assert string.find(test.stdout(), 'is up to date') == -1, test.stdout()
+
test.pass_test()