summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-05-07 19:19:41 (GMT)
committerSteven Knight <knight@baldmt.com>2005-05-07 19:19:41 (GMT)
commit730081593efc2ac5c17def1650ad0b39c4d0e72a (patch)
tree3379689db64e402fa4720e60ce7ecd1f307ad762 /test
parentd629cdf3f3b332a1b3c9c9fa550c90b8dd710766 (diff)
downloadSCons-730081593efc2ac5c17def1650ad0b39c4d0e72a.zip
SCons-730081593efc2ac5c17def1650ad0b39c4d0e72a.tar.gz
SCons-730081593efc2ac5c17def1650ad0b39c4d0e72a.tar.bz2
Make SConsignFile() behavior the default.
Diffstat (limited to 'test')
-rw-r--r--test/Configure.py1
-rw-r--r--test/Repository/SConsignFile.py61
-rw-r--r--test/option-n.py2
-rw-r--r--test/sconsign/corrupt.py100
-rw-r--r--test/sconsign/nonwritable.py (renamed from test/sconsign.py)69
-rw-r--r--test/sconsign/old.py (renamed from test/old-sconsign.py)9
-rw-r--r--test/sconsign/script.py (renamed from test/sconsign-script.py)17
-rw-r--r--test/subdivide.py7
8 files changed, 221 insertions, 45 deletions
diff --git a/test/Configure.py b/test/Configure.py
index 515ae70..83155bb 100644
--- a/test/Configure.py
+++ b/test/Configure.py
@@ -509,6 +509,7 @@ int main() {
os.path.join("build", "sub", "SConscript"))
shutil.rmtree(test.workpath(work_dir, ".sconf_temp"))
+ os.unlink(test.workpath(work_dir, ".sconsign.dblite"))
# now with SConscriptChdir(1)
test.run(chdir=work_dir, arguments='chdir=yes')
diff --git a/test/Repository/SConsignFile.py b/test/Repository/SConsignFile.py
new file mode 100644
index 0000000..9643cb8
--- /dev/null
+++ b/test/Repository/SConsignFile.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that the Repository option works when recording signature
+information in an SConsignFile().
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('repository', 'work')
+
+SConstruct_contents = """\
+SConsignFile('sconsignfile')
+env = Environment()
+result = env.Command('file.out', 'file.in', Copy("$TARGET", "$SOURCE"))
+Default(result)
+"""
+
+test.write(['repository', 'SConstruct'], SConstruct_contents)
+
+test.write(['repository', 'file.in'], "repository/file.in\n")
+
+test.run(chdir='repository')
+
+test.must_match(['repository', 'file.out'], "repository/file.in\n")
+
+test.write(['work', 'SConstruct'], SConstruct_contents)
+
+test.run(chdir='work',
+ arguments='-Y ../repository -n --debug=explain',
+ stdout=test.wrap_stdout("scons: `file.out' is up to date.\n"))
+
+test.must_not_exist(['work', 'file.out'])
+
+test.pass_test()
diff --git a/test/option-n.py b/test/option-n.py
index aa0b8f2..769c4dd 100644
--- a/test/option-n.py
+++ b/test/option-n.py
@@ -120,7 +120,7 @@ test.fail_test(not os.path.exists(test.workpath('f1.out')))
expect = test.wrap_stdout("""\
%s build.py f1.out
""" % python)
-test.unlink('.sconsign')
+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)
diff --git a/test/sconsign/corrupt.py b/test/sconsign/corrupt.py
new file mode 100644
index 0000000..fd46de4
--- /dev/null
+++ b/test/sconsign/corrupt.py
@@ -0,0 +1,100 @@
+#!/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__"
+
+"""
+Test that we get proper warnings when .sconsign* files are corrupt.
+"""
+
+import os
+import TestSCons
+import TestCmd
+import cPickle
+
+test = TestSCons.TestSCons(match = TestCmd.match_re)
+
+test.subdir('work1', ['work1', 'sub'],
+ 'work2', ['work2', 'sub'])
+
+work1__sconsign_dblite = test.workpath('work1', '.sconsign.dblite')
+work2_sub__sconsign = test.workpath('work2', 'sub', '.sconsign')
+
+SConstruct_contents = """\
+def build1(target, source, env):
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+ return None
+
+B1 = Builder(action = build1)
+env = Environment(BUILDERS = { 'B1' : B1})
+env.B1(target = 'sub/foo.out', source = 'foo.in')
+"""
+
+
+
+test.write(['work1', 'SConstruct'], SConstruct_contents)
+
+test.write(['work1', 'foo.in'], "work1/foo.in\n")
+
+stderr = '''
+scons: warning: Ignoring corrupt .sconsign file: \.sconsign\.dblite
+.*
+'''
+
+stdout = test.wrap_stdout('build1\(\["sub.foo\.out"\], \["foo\.in"\]\)\n')
+
+test.write(work1__sconsign_dblite, 'not:a:sconsign:file')
+test.run(chdir='work1', arguments='.', stderr=stderr, stdout=stdout)
+
+test.write(work1__sconsign_dblite, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+test.run(chdir='work1', arguments='.', stderr=stderr, stdout=stdout)
+
+
+
+# Test explicitly using a .sconsign file in each directory.
+
+SConstruct_contents = """\
+SConsignFile(None)
+""" + SConstruct_contents
+
+test.write(['work2', 'SConstruct'], SConstruct_contents)
+
+test.write(['work2', 'foo.in'], "work2/foo.in\n")
+
+stderr = '''
+scons: warning: Ignoring corrupt .sconsign file: sub.\.sconsign
+.*
+'''
+
+stdout = test.wrap_stdout('build1\(\["sub.foo\.out"\], \["foo\.in"\]\)\n')
+
+test.write(work2_sub__sconsign, 'not:a:sconsign:file')
+test.run(chdir='work2', arguments='.', stderr=stderr, stdout=stdout)
+
+test.write(work2_sub__sconsign, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+test.run(chdir='work2', arguments='.', stderr=stderr, stdout=stdout)
+
+
+
+test.pass_test()
diff --git a/test/sconsign.py b/test/sconsign/nonwritable.py
index e9a6609..9ad679c 100644
--- a/test/sconsign.py
+++ b/test/sconsign/nonwritable.py
@@ -24,6 +24,10 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""
+Test that things still work when a .sconsign* file is not writable.
+"""
+
import os
import TestSCons
import TestCmd
@@ -31,9 +35,21 @@ import cPickle
test = TestSCons.TestSCons(match = TestCmd.match_re)
-test.subdir('sub1', 'sub2', 'sub3')
-
-test.write('SConstruct', """
+test.subdir('work1',
+ ['work1', 'sub1'],
+ ['work1', 'sub2'],
+ ['work1', 'sub3'],
+ 'work2',
+ ['work2', 'sub1'],
+ ['work2', 'sub2'],
+ ['work2', 'sub3'])
+
+work1__sconsign_dblite = test.workpath('work1', '.sconsign.dblite')
+work2_sub1__sconsign = test.workpath('work2', 'sub1', '.sconsign')
+work2_sub2__sconsign = test.workpath('work2', 'sub2', '.sconsign')
+work2_sub3__sconsign = test.workpath('work2', 'sub3', '.sconsign')
+
+SConstruct_contents = """\
def build1(target, source, env):
open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
return None
@@ -52,48 +68,37 @@ env = Environment(BUILDERS = { 'B1' : B1, 'B2' : B2 })
env.B1(target = 'sub1/foo.out', source = 'foo.in')
env.B2(target = 'sub2/foo.out', source = 'foo.in')
env.B2(target = 'sub3/foo.out', source = 'foo.in')
-""")
+"""
-test.write('foo.in', "foo.in\n")
-sub1__sconsign = test.workpath('sub1', '.sconsign')
-sub2__sconsign = test.workpath('sub2', '.sconsign')
-sub3__sconsign = test.workpath('sub3', '.sconsign')
-cPickle.dump({}, open(sub1__sconsign, 'wb'), 1)
-cPickle.dump({}, open(sub2__sconsign, 'wb'), 1)
+test.write(['work1', 'SConstruct'], SConstruct_contents)
-os.chmod(sub1__sconsign, 0444)
+test.write(['work1', 'foo.in'], "work1/foo.in\n")
-test.run(arguments = '.')
+test.write(work1__sconsign_dblite, "")
-test.fail_test(test.read(sub1__sconsign) == "")
-test.fail_test(test.read(sub2__sconsign) == "")
+os.chmod(work1__sconsign_dblite, 0444)
-os.chmod(sub1__sconsign, 0666)
+test.run(chdir='work1', arguments='.')
-test.write('SConstruct', """
-def build1(target, source, env):
- open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
- return None
-B1 = Builder(action = build1)
-env = Environment(BUILDERS = { 'B1' : B1})
-env.B1(target = 'sub1/foo.out', source = 'foo.in')
-""")
-stderr = '''
-scons: warning: Ignoring corrupt .sconsign file: sub1.\.sconsign
-.*
-'''
+SConstruct_contents = """\
+SConsignFile(None)
+""" + SConstruct_contents
+
+test.write(['work2', 'SConstruct'], SConstruct_contents)
+
+test.write(['work2', 'foo.in'], "work2/foo.in\n")
+
+cPickle.dump({}, open(work2_sub1__sconsign, 'wb'), 1)
+cPickle.dump({}, open(work2_sub2__sconsign, 'wb'), 1)
-stdout = test.wrap_stdout('build1\(\["sub1.foo\.out"\], \["foo\.in"\]\)\n')
+os.chmod(work2_sub1__sconsign, 0444)
-test.write(sub1__sconsign, 'not:a:sconsign:file')
-test.run(arguments = '.', stderr=stderr, stdout=stdout)
+test.run(chdir='work2', arguments='.')
-test.write(sub1__sconsign, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
-test.run(arguments = '.', stderr=stderr, stdout=stdout)
test.pass_test()
diff --git a/test/old-sconsign.py b/test/sconsign/old.py
index 6c057dd..703a924 100644
--- a/test/old-sconsign.py
+++ b/test/sconsign/old.py
@@ -113,8 +113,11 @@ for key, val in old_db.items():
db.sync()
""")
+
+
# Now generate a simple .sconsign file for a simple build.
test.write(['src1', 'SConstruct'], """\
+SConsignFile(None)
import os
def cat(env, source, target):
target = str(target[0])
@@ -154,10 +157,10 @@ for sconsign in sconsign_list:
test.up_to_date(chdir='src1', arguments='.')
+
+
# Now do the same with SConsignFile().
test.write(['src2', 'SConstruct'], """\
-SConsignFile()
-
import os
def cat(env, source, target):
target = str(target[0])
@@ -189,4 +192,6 @@ for sconsign in sconsign_list:
test.up_to_date(chdir='src2', arguments='.')
+
+
test.pass_test()
diff --git a/test/sconsign-script.py b/test/sconsign/script.py
index 7a24aef..9758d5a 100644
--- a/test/sconsign-script.py
+++ b/test/sconsign/script.py
@@ -74,6 +74,7 @@ test.subdir('work1', ['work1', 'sub1'], ['work1', 'sub2'],
'work2', ['work2', 'sub1'], ['work2', 'sub2'])
test.write(['work1', 'SConstruct'], """
+SConsignFile(None)
env1 = Environment(PROGSUFFIX = '.exe', OBJSUFFIX = '.obj')
env1.Program('sub1/hello.c')
env2 = env1.Copy(CPPPATH = ['sub2'])
@@ -221,18 +222,18 @@ test.run(chdir = 'work1', arguments = '. --max-drift=1 --debug=stacktrace')
test.run_sconsign(arguments = "-e hello.exe -e hello.obj work1/sub1/.sconsign",
stdout = """\
-hello.exe: None \d+ None
- hello.obj: \d+
-hello.obj: None \d+ None
- hello.c: \d+
+hello.exe: None \S+ None
+ hello.obj: \S+
+hello.obj: None \S+ None
+ hello.c: \S+
""")
test.run_sconsign(arguments = "-e hello.exe -e hello.obj -r work1/sub1/.sconsign",
stdout = """\
-hello.exe: None \d+ None
- hello.obj: \d+
-hello.obj: None \d+ None
- hello.c: \d+
+hello.exe: None \S+ None
+ hello.obj: \S+
+hello.obj: None \S+ None
+ hello.c: \S+
""")
diff --git a/test/subdivide.py b/test/subdivide.py
index f6aa4f1..18219bf 100644
--- a/test/subdivide.py
+++ b/test/subdivide.py
@@ -25,8 +25,9 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Verify that rebuilds do not occur when TargetSignatures()
-content is used to subdivide a dependency tree.
+Verify that rebuilds do not occur when SConsignFile(None) is used to
+put a .sconsign file in each directory, and TargetSignatures('content')
+is used to subdivide a dependency tree.
"""
import os.path
@@ -46,6 +47,7 @@ test = TestSCons.TestSCons()
test.subdir('src', ['src', 'sub'])
test.write('SConstruct', """\
+SConsignFile(None)
TargetSignatures('content')
env = Environment()
env.SConscript('src/SConstruct', exports=['env'])
@@ -53,6 +55,7 @@ env.Object('foo.c')
""")
test.write(['src', 'SConstruct'], """\
+SConsignFile(None)
TargetSignatures('content')
env = Environment()
p = env.Program('prog', ['main.c', '../foo%s', 'sub/bar.c'])