summaryrefslogtreecommitdiff
path: root/test/option-n.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-06-12 15:28:38 +0000
committerSteven Knight <knight@baldmt.com>2003-06-12 15:28:38 +0000
commit823ab5a50f9856308ee9559f968d62409ad625da (patch)
treec24bc193f5a9acbceed0bb58b44768355f3ee945 /test/option-n.py
parent6c11c2362e17142f384a914d821d0e0cd021ecd2 (diff)
downloadscons-823ab5a50f9856308ee9559f968d62409ad625da.tar.gz
Raise an error if SConf needs to do something but -n or -q is specified. (Christoph Wiedemann)
Diffstat (limited to 'test/option-n.py')
-rw-r--r--test/option-n.py76
1 files changed, 75 insertions, 1 deletions
diff --git a/test/option-n.py b/test/option-n.py
index bccb785b..86f4c3ab 100644
--- a/test/option-n.py
+++ b/test/option-n.py
@@ -32,13 +32,18 @@ This test verifies:
installed when -n is used;
4) that source files don't get duplicated in a BuildDir
when -n is used.
+ 5) that Configure calls don't build any files. If a file
+ needs to be build (i.e. is not up-to-date), a ConfigureError
+ is raised.
"""
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import os
import os.path
import string
import sys
+import TestCmd
import TestSCons
python = TestSCons.python
@@ -155,5 +160,74 @@ test.fail_test(not os.path.exists(test.workpath('install', 'f3.in')))
test.run(arguments = '-n build')
test.fail_test(os.path.exists(test.workpath('build', 'f4.in')))
-test.pass_test()
+# test Configure-calls in conjunction with -n
+test.subdir('configure')
+test.match_func = TestCmd.match_re_dotall
+test.write('configure/SConstruct',
+"""def CustomTest(context):
+ 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])
+ context.Message("Executing Custom Test ... " )
+ (ok, msg) = context.TryAction(Action(userAction,strAction),
+ "Hello World", ".in")
+ context.Result(ok)
+ return ok
+
+env = Environment()
+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()
+""")
+# 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="-n",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="-n",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='scons: "." is up to date.\n',
+ read_str="""\
+Executing Custom Test ... ok
+""")
+test.run(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(stdout=stdout,arguments="-n",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()