summaryrefslogtreecommitdiffstats
path: root/test
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
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')
-rw-r--r--test/option-n.py76
-rw-r--r--test/option-q.py80
2 files changed, 154 insertions, 2 deletions
diff --git a/test/option-n.py b/test/option-n.py
index bccb785..86f4c3a 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()
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()
-