diff options
author | Steven Knight <knight@baldmt.com> | 2003-06-12 15:28:38 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-06-12 15:28:38 (GMT) |
commit | 823ab5a50f9856308ee9559f968d62409ad625da (patch) | |
tree | c24bc193f5a9acbceed0bb58b44768355f3ee945 /test/option-n.py | |
parent | 6c11c2362e17142f384a914d821d0e0cd021ecd2 (diff) | |
download | SCons-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-n.py')
-rw-r--r-- | test/option-n.py | 76 |
1 files changed, 75 insertions, 1 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() |