Added fix for TeX includes with same name as subdirs.
[scons.git] / test / option--max-drift.py
index 7e7384dcf30498ae7e774335a4247fea5d7cce29..08fafd1961821fccb870f45f728c5e6125fc5332 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 #
-# Copyright (c) 2001, 2002 Steven Knight
+# __COPYRIGHT__
 #
 # Permission is hereby granted, free of charge, to any person obtaining
 # a copy of this software and associated documentation files (the
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-import os.path
 import os
-import string
-import sys
+
 import TestSCons
 
-python = TestSCons.python
+_python_ = TestSCons._python_
 
 test = TestSCons.TestSCons()
 
@@ -45,11 +41,11 @@ file.close()
 """)
 
 test.write('SConstruct', """
-B = Builder(action = r'%s build.py $TARGETS $SOURCES')
+B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
 env = Environment(BUILDERS = { 'B' : B })
 env.B(target = 'f1.out', source = 'f1.in')
 env.B(target = 'f2.out', source = 'f2.in')
-""" % python)
+""" % locals())
 
 test.write('f1.in', "f1.in\n")
 test.write('f2.in', "f2.in\n")
@@ -60,33 +56,72 @@ test.run(arguments = 'f1.out')
 
 test.run(arguments = 'f1.out f2.out',
          stdout = test.wrap_stdout(
-"""scons: "f1.out" is up to date.
-%s build.py f2.out f2.in
-""" % python))
+"""scons: `f1.out' is up to date.
+%(_python_)s build.py f2.out f2.in
+""" % locals()))
 
 atime = os.path.getatime(test.workpath('f1.in'))
 mtime = os.path.getmtime(test.workpath('f1.in'))
 
-test.run(arguments = '--max-drift=0 f1.out f2.out',
-         stdout = test.wrap_stdout(
-"""scons: "f1.out" is up to date.
-scons: "f2.out" is up to date.
-"""))
+test.up_to_date(options='--max-drift=0', arguments='f1.out f2.out')
 
 test.write('f1.in', "f1.in delta\n")
 os.utime(test.workpath('f1.in'), (atime,mtime))
 
-test.run(arguments = '--max-drift=0 f1.out f2.out',
-         stdout = test.wrap_stdout(
-"""scons: "f1.out" is up to date.
-scons: "f2.out" is up to date.
-"""))
+test.up_to_date(options='--max-drift=0', arguments='f1.out f2.out')
 
-test.run(arguments = '--max-drift=-1 f1.out f2.out',
-         stdout = test.wrap_stdout(
-"""%s build.py f1.out f1.in
-scons: "f2.out" is up to date.
-""" % python))
+expect = test.wrap_stdout(
+"""%(_python_)s build.py f1.out f1.in
+scons: `f2.out' is up to date.
+""" % locals())
+
+test.run(arguments = '--max-drift=-1 f1.out f2.out', stdout = expect)
+
+# 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'%(_python_)s build.py $TARGETS $SOURCES')
+env = Environment(BUILDERS = { 'B' : B })
+env.B(target = 'foo.out', source = 'foo.in')
+""" % locals())
+
+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()
 
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: