summaryrefslogtreecommitdiffstats
path: root/test/option-q.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-06-12 15:28:38 (GMT)
committerSteven Knight <knight@baldmt.com>2003-06-12 15:28:38 (GMT)
commit823ab5a50f9856308ee9559f968d62409ad625da (patch)
treec24bc193f5a9acbceed0bb58b44768355f3ee945 /test/option-q.py
parent6c11c2362e17142f384a914d821d0e0cd021ecd2 (diff)
downloadSCons-823ab5a50f9856308ee9559f968d62409ad625da.zip
SCons-823ab5a50f9856308ee9559f968d62409ad625da.tar.gz
SCons-823ab5a50f9856308ee9559f968d62409ad625da.tar.bz2
Raise an error if SConf needs to do something but -n or -q is specified. (Christoph Wiedemann)
Diffstat (limited to 'test/option-q.py')
-rw-r--r--test/option-q.py80
1 files changed, 79 insertions, 1 deletions
diff --git a/test/option-q.py b/test/option-q.py
index e745760..449d5eb 100644
--- a/test/option-q.py
+++ b/test/option-q.py
@@ -28,6 +28,7 @@ import os.path
import string
import sys
+import TestCmd
import TestSCons
test = TestSCons.TestSCons()
@@ -72,5 +73,82 @@ test.fail_test(test.read('bbb.out') != "bbb.in\n")
test.run(arguments = '--question bbb.out', status = 0)
+
+# test -q in conjunction with Configure Tests
+# mostly copy&paste from test/option-n.py
+test.subdir('configure')
+test.match_func = TestCmd.match_re_dotall
+test.write('configure/aaa.in', 'Hello world')
+test.write('configure/SConstruct',
+"""def userAction(target,source,env):
+ import shutil
+ shutil.copyfile( str(source[0]), str(target[0]))
+
+def strAction(target,source,env):
+ return "cp " + str(source[0]) + " " + str(target[0])
+
+def CustomTest(context):
+ context.Message("Executing Custom Test ... " )
+ (ok, msg) = context.TryAction(Action(userAction,strAction),
+ "Hello World", ".in")
+ context.Result(ok)
+ return ok
+
+env = Environment(BUILDERS={'B' : Builder(action=Action(userAction,strAction))})
+
+conf = Configure( env,
+ custom_tests={'CustomTest':CustomTest},
+ conf_dir="config.test",
+ log_file="config.log")
+if not conf.CustomTest():
+ Exit(1)
+else:
+ env = conf.Finish()
+
+env.B(target='aaa.out', source='aaa.in')
+""")
+# test that conf_dir isn't created and an error is raised
+stderr=r"""
+scons: \*\*\* Cannot update configure test \(config\.test\) within a dry-run\.
+File \S+, line \S+, in \S+
+"""
+test.run(arguments="-q aaa.out",stderr=stderr,status=2,
+ chdir=test.workpath("configure"))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.log")))
+
+# test that targets are not built, if conf_dir exists.
+# verify that .cache and config.log are not created.
+# an error should be raised
+stderr=r"""
+scons: \*\*\* Cannot update configure test \(config\.test.conftest_0\.in\) within a dry-run\.
+File \S+, line \S+, in \S+
+"""
+test.subdir(['configure','config.test'])
+test.run(arguments="-q aaa.out",stderr=stderr,status=2,
+ chdir=test.workpath("configure"))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test",
+ ".cache")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test",
+ "conftest_0")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.test",
+ "conftest_0.in")))
+test.fail_test(os.path.exists(test.workpath("configure", "config.log")))
+
+# test that no error is raised, if all targets are up-to-date. In this
+# case .cache and config.log shouldn't be created
+stdout=test.wrap_stdout(build_str='cp aaa.in aaa.out\n',
+ read_str="""\
+Executing Custom Test ... ok
+""")
+test.run(stdout=stdout,arguments="aaa.out",status=0,chdir=test.workpath("configure"))
+cache1_mtime = os.path.getmtime(test.workpath("configure","config.test",".cache"))
+log1_mtime = os.path.getmtime(test.workpath("configure","config.log"))
+test.run(arguments="-q aaa.out",status=0,
+ chdir=test.workpath("configure"))
+cache2_mtime = os.path.getmtime(test.workpath("configure","config.test",".cache"))
+log2_mtime = os.path.getmtime(test.workpath("configure","config.log"))
+test.fail_test( cache1_mtime != cache2_mtime )
+test.fail_test( log1_mtime != log2_mtime )
+
test.pass_test()
-