Update regression tests to match changes in runtest.py
[scons.git] / test / timestamp-fallback.py
index 9ea515c43b42dd73f3430f87dae8478651650db6..6b10033528a30ad1d110cbb6344078b5664821fc 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+"""
+Verify falling back to 'timestamp' behavior if there is no native
+hashlib and no underlying md5 module available.
+"""
+
 import imp
 import os
-import os.path
 
 import TestSCons
 
 test = TestSCons.TestSCons()
 
+try:
+    file, name, desc = imp.find_module('hashlib')
+except ImportError:
+    pass
+else:
+    msg = "This version of Python has a 'hashlib' module.\n" + \
+          "Skipping test of falling back to timestamps.\n"
+    test.skip_test(msg)
+
 try:
     file, name, desc = imp.find_module('md5')
 except ImportError:
     pass
 else:
     if desc[2] == imp.C_BUILTIN:
-       print "The 'md5' module is built in to this version of Python."
-       print "Cannot test falling back to timestamps."
-        test.no_result(1);
+        msg = "The 'md5' module is built in to this version of Python.\n" + \
+              "Cannot test falling back to timestamps.\n"
+        test.skip_test(msg)
 
 test.write('md5.py', r"""
 raise ImportError
@@ -49,10 +62,11 @@ raise ImportError
 os.environ['PYTHONPATH'] = test.workpath('.')
 
 test.write('SConstruct', """
+DefaultEnvironment(tools=[])
 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 = Environment(tools = [], 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')
@@ -64,15 +78,17 @@ 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')
+test.run(arguments = 'f1.out f3.out',
+         stderr = None)
 
 test.run(arguments = 'f1.out f2.out f3.out f4.out',
          stdout = 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")
-"""))
+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 = None)
 
 os.utime(test.workpath('f1.in'), 
          (os.path.getatime(test.workpath('f1.in')),
@@ -83,12 +99,18 @@ os.utime(test.workpath('f3.in'),
 
 test.run(arguments = 'f1.out f2.out f3.out f4.out',
          stdout = 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.
-"""))
+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 = None)
 
 
 test.pass_test()
 
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: