summaryrefslogtreecommitdiffstats
path: root/test/Deprecated/SourceSignatures
diff options
context:
space:
mode:
Diffstat (limited to 'test/Deprecated/SourceSignatures')
-rw-r--r--test/Deprecated/SourceSignatures/basic.py130
-rw-r--r--test/Deprecated/SourceSignatures/env.py101
-rw-r--r--test/Deprecated/SourceSignatures/implicit-cache.py98
-rw-r--r--test/Deprecated/SourceSignatures/no-csigs.py73
-rw-r--r--test/Deprecated/SourceSignatures/overrides.py59
-rw-r--r--test/Deprecated/SourceSignatures/switch-rebuild.py88
6 files changed, 549 insertions, 0 deletions
diff --git a/test/Deprecated/SourceSignatures/basic.py b/test/Deprecated/SourceSignatures/basic.py
new file mode 100644
index 0000000..5012296
--- /dev/null
+++ b/test/Deprecated/SourceSignatures/basic.py
@@ -0,0 +1,130 @@
+#!/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 os.path
+import re
+
+import TestSCons
+
+test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
+
+
+
+base_sconstruct_contents = """\
+SetOption('warn', 'no-deprecated-source-signatures')
+def build(env, target, source):
+ open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
+B = Builder(action = build)
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'f1.out', source = 'f1.in')
+env.B(target = 'f2.out', source = 'f2.in')
+env.B(target = 'f3.out', source = 'f3.in')
+env.B(target = 'f4.out', source = 'f4.in')
+"""
+
+def write_SConstruct(test, sigtype):
+ contents = base_sconstruct_contents
+ if sigtype:
+ contents = contents + ("\nSourceSignatures('%s')\n" % sigtype)
+ test.write('SConstruct', contents)
+
+
+
+write_SConstruct(test, 'timestamp')
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+test.write('f3.in', "f3.in\n")
+test.write('f4.in', "f4.in\n")
+
+test.run(arguments = 'f1.out f3.out',
+ stderr = TestSCons.deprecated_python_expr)
+
+test.run(arguments = 'f1.out f2.out f3.out f4.out',
+ stdout = re.escape(test.wrap_stdout("""\
+scons: `f1.out' is up to date.
+build(["f2.out"], ["f2.in"])
+scons: `f3.out' is up to date.
+build(["f4.out"], ["f4.in"])
+""")),
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+os.utime(test.workpath('f1.in'),
+ (os.path.getatime(test.workpath('f1.in')),
+ os.path.getmtime(test.workpath('f1.in'))+10))
+os.utime(test.workpath('f3.in'),
+ (os.path.getatime(test.workpath('f3.in')),
+ os.path.getmtime(test.workpath('f3.in'))+10))
+
+test.run(arguments = 'f1.out f2.out f3.out f4.out',
+ stdout = re.escape(test.wrap_stdout("""\
+build(["f1.out"], ["f1.in"])
+scons: `f2.out' is up to date.
+build(["f3.out"], ["f3.in"])
+scons: `f4.out' is up to date.
+""")),
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+# Switching to content signatures from timestamps should rebuild,
+# because we didn't record the content signatures last time.
+
+write_SConstruct(test, 'MD5')
+
+test.not_up_to_date(arguments = 'f1.out f2.out f3.out f4.out',
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.sleep()
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+test.write('f3.in', "f3.in\n")
+test.write('f4.in', "f4.in\n")
+
+test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
+
+
+
+test.touch('f1.in', os.path.getmtime(test.workpath('f1.in'))+10)
+test.touch('f3.in', os.path.getmtime(test.workpath('f3.in'))+10)
+
+test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
+
+
+
+write_SConstruct(test, None)
+
+test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
+
+
+
+test.pass_test()
diff --git a/test/Deprecated/SourceSignatures/env.py b/test/Deprecated/SourceSignatures/env.py
new file mode 100644
index 0000000..ec6d3d2
--- /dev/null
+++ b/test/Deprecated/SourceSignatures/env.py
@@ -0,0 +1,101 @@
+#!/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 use of env.SourceSignatures() correctly overrides the
+default behavior.
+"""
+
+import os
+import os.path
+import re
+
+import TestSCons
+
+test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
+
+base_sconstruct_contents = """\
+SetOption('warn', 'no-deprecated-source-signatures')
+def build(env, target, source):
+ open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
+B = Builder(action = build)
+env = Environment(BUILDERS = { 'B' : B })
+env2 = env.Clone()
+env2.SourceSignatures('%s')
+env.B(target = 'f1.out', source = 'f1.in')
+env.B(target = 'f2.out', source = 'f2.in')
+env2.B(target = 'f3.out', source = 'f3.in')
+env2.B(target = 'f4.out', source = 'f4.in')
+
+SourceSignatures('%s')
+"""
+
+def write_SConstruct(test, env_sigtype, default_sigtype):
+ contents = base_sconstruct_contents % (env_sigtype, default_sigtype)
+ test.write('SConstruct', contents)
+
+
+
+write_SConstruct(test, 'MD5', 'timestamp')
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+test.write('f3.in', "f3.in\n")
+test.write('f4.in', "f4.in\n")
+
+test.run(arguments = 'f1.out f3.out',
+ stderr = TestSCons.deprecated_python_expr)
+
+test.run(arguments = 'f1.out f2.out f3.out f4.out',
+ stdout = re.escape(test.wrap_stdout("""\
+scons: `f1.out' is up to date.
+build(["f2.out"], ["f2.in"])
+scons: `f3.out' is up to date.
+build(["f4.out"], ["f4.in"])
+""")),
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.sleep()
+
+test.touch('f1.in')
+test.touch('f3.in')
+
+test.run(arguments = 'f1.out f2.out f3.out f4.out',
+ stdout = re.escape(test.wrap_stdout("""\
+build(["f1.out"], ["f1.in"])
+scons: `f2.out' is up to date.
+scons: `f3.out' is up to date.
+scons: `f4.out' is up to date.
+""")),
+ stderr = TestSCons.deprecated_python_expr)
+
+test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
+
+
+
+test.pass_test()
diff --git a/test/Deprecated/SourceSignatures/implicit-cache.py b/test/Deprecated/SourceSignatures/implicit-cache.py
new file mode 100644
index 0000000..44c30ce
--- /dev/null
+++ b/test/Deprecated/SourceSignatures/implicit-cache.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__"
+
+"""
+Test the simultaneous use of implicit_cache and
+SourceSignatures('timestamp')
+"""
+
+import re
+
+import TestSCons
+
+test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
+
+test.write('SConstruct', """\
+SetOption('warn', 'no-deprecated-source-signatures')
+SetOption('implicit_cache', 1)
+SourceSignatures('timestamp')
+
+def build(env, target, source):
+ open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
+B = Builder(action = build)
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'both.out', source = 'both.in')
+""")
+
+both_out_both_in = re.escape(test.wrap_stdout('build(["both.out"], ["both.in"])\n'))
+
+
+
+test.write('both.in', "both.in 1\n")
+
+test.run(arguments = 'both.out',
+ stdout = both_out_both_in,
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.sleep(2)
+
+test.write('both.in', "both.in 2\n")
+
+test.run(arguments = 'both.out',
+ stdout = both_out_both_in,
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.sleep(2)
+
+test.write('both.in', "both.in 3\n")
+
+test.run(arguments = 'both.out',
+ stdout = both_out_both_in,
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.sleep(2)
+
+test.write('both.in', "both.in 4\n")
+
+test.run(arguments = 'both.out',
+ stdout = both_out_both_in,
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.sleep(2)
+
+test.up_to_date(arguments = 'both.out', stderr = None)
+
+
+
+test.pass_test()
diff --git a/test/Deprecated/SourceSignatures/no-csigs.py b/test/Deprecated/SourceSignatures/no-csigs.py
new file mode 100644
index 0000000..01d05da
--- /dev/null
+++ b/test/Deprecated/SourceSignatures/no-csigs.py
@@ -0,0 +1,73 @@
+
+#!/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 os.path
+
+import TestSCons
+import TestSConsign
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+
+test.write('SConstruct', """\
+SetOption('warn', 'no-deprecated-source-signatures')
+def build(env, target, source):
+ open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
+B = Builder(action = build)
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'f1.out', source = 'f1.in')
+env.B(target = 'f2.out', source = 'f2.in')
+SourceSignatures('timestamp')
+""")
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+
+test.run(arguments = '.',
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+expect = r"""=== .:
+SConstruct: None \d+ \d+
+f1.in: None \d+ \d+
+f1.out: \S+ \d+ \d+
+ f1.in: None \d+ \d+
+ \S+ \[build\(target, source, env\)\]
+f2.in: None \d+ \d+
+f2.out: \S+ \d+ \d+
+ f2.in: None \d+ \d+
+ \S+ \[build\(target, source, env\)\]
+"""
+
+test.run_sconsign(arguments = test.workpath('.sconsign'),
+ stdout = expect)
+
+
+
+test.pass_test()
diff --git a/test/Deprecated/SourceSignatures/overrides.py b/test/Deprecated/SourceSignatures/overrides.py
new file mode 100644
index 0000000..de1cc95
--- /dev/null
+++ b/test/Deprecated/SourceSignatures/overrides.py
@@ -0,0 +1,59 @@
+#!/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__"
+
+"""
+Make sure that SourceSignatures() works when overrides are used on a
+Builder call. (Previous implementations used methods that would stay
+bound to the underlying construction environment, which in this case
+meant ignoring the 'timestamp' setting and still using the underlying
+content signature.)
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
+
+test.write('SConstruct', """\
+SetOption('warn', 'no-deprecated-source-signatures')
+DefaultEnvironment().SourceSignatures('MD5')
+env = Environment()
+env.SourceSignatures('timestamp')
+env.Command('foo.out', 'foo.in', Copy('$TARGET', '$SOURCE'), FOO=1)
+""")
+
+test.write('foo.in', "foo.in 1\n")
+
+test.run(arguments = 'foo.out',
+ stderr = TestSCons.deprecated_python_expr)
+
+test.sleep()
+
+test.write('foo.in', "foo.in 1\n")
+
+test.not_up_to_date(arguments = 'foo.out',
+ stderr = TestSCons.deprecated_python_expr)
+
+test.pass_test()
diff --git a/test/Deprecated/SourceSignatures/switch-rebuild.py b/test/Deprecated/SourceSignatures/switch-rebuild.py
new file mode 100644
index 0000000..07b59fb
--- /dev/null
+++ b/test/Deprecated/SourceSignatures/switch-rebuild.py
@@ -0,0 +1,88 @@
+#!/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 switching SourceSignature() types no longer causes rebuilds.
+"""
+
+import re
+
+import TestSCons
+
+test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
+
+
+base_sconstruct_contents = """\
+SetOption('warn', 'no-deprecated-source-signatures')
+SourceSignatures('%s')
+
+def build(env, target, source):
+ open(str(target[0]), 'wt').write(open(str(source[0]), 'rt').read())
+B = Builder(action = build)
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'switch.out', source = 'switch.in')
+"""
+
+def write_SConstruct(test, sig_type):
+ contents = base_sconstruct_contents % sig_type
+ test.write('SConstruct', contents)
+
+
+write_SConstruct(test, 'MD5')
+
+test.write('switch.in', "switch.in\n")
+
+switch_out_switch_in = re.escape(test.wrap_stdout('build(["switch.out"], ["switch.in"])\n'))
+
+test.run(arguments = 'switch.out',
+ stdout = switch_out_switch_in,
+ stderr = TestSCons.deprecated_python_expr)
+
+test.up_to_date(arguments = 'switch.out', stderr = None)
+
+
+
+write_SConstruct(test, 'timestamp')
+
+test.up_to_date(arguments = 'switch.out', stderr = None)
+
+
+
+write_SConstruct(test, 'MD5')
+
+test.not_up_to_date(arguments = 'switch.out', stderr = None)
+
+
+
+test.write('switch.in', "switch.in 2\n")
+
+test.run(arguments = 'switch.out',
+ stdout = switch_out_switch_in,
+ stderr = TestSCons.deprecated_python_expr)
+
+
+
+test.pass_test()