From: stevenknight Date: Thu, 21 Feb 2002 22:30:24 +0000 (+0000) Subject: Add the -q option. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6eade073957aa9e9e69f766ee44d83c37ede0a43;p=scons.git Add the -q option. git-svn-id: http://scons.tigris.org/svn/scons/trunk@274 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index ef5b6644..461e8faf 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -445,13 +445,13 @@ any out-of-date target files, but do not execute the commands. .\" .ES .\" scons -p -q .\" .EE -.\" -.\" .TP -.\" -q, --question -.\" Do not run any commands, or print anything. Just return an exit -.\" status that is zero if the specified targets are already up to -.\" date, nonzero otherwise. -.\" + +.TP +-q, --question +Do not run any commands, or print anything. Just return an exit +status that is zero if the specified targets are already up to +date, non-zero otherwise. + .\" .TP .\" -r, -R, --no-builtin-rules, --no-builtin-variables .\" Clear the default construction variables. Construction diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 4643b9a3..33a4a40e 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -73,6 +73,8 @@ RELEASE 0.05 - - Fix the --debug=pdb option when run on Windows NT. + - Add support for the -q option. + From Steve Leblanc: - Add support for the -u option. diff --git a/src/RELEASE.txt b/src/RELEASE.txt index 358a3594..f257e844 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -98,7 +98,7 @@ RELEASE 0.04 - Wed, 30 Jan 2002 11:09:42 -0600 - No support yet for the following command-line options: -d -e -l --list-actions --list-derived --list-where - -o -p -q -r -R --random -w --write-filenames -W + -o -p -r -R --random -w --write-filenames -W --warn-undefined-variables Thank you for your interest, and please let us know how we can help diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 529729ea..84882f42 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -120,6 +120,16 @@ class CleanTask(SCons.Taskmaster.Task): except IndexError: pass +class QuestionTask(SCons.Taskmaster.Task): + """An SCons task for the -q (question) option.""" + def execute(self): + if self.targets[0].get_state() != SCons.Node.up_to_date: + global exit_status + exit_status = 1 + self.tm.stop() + + def executed(self): + pass # Global variables @@ -501,7 +511,11 @@ def options_init(): short = 'p', help = "Print internal environments/objects.") - Option(func = opt_not_yet, future = 1, + def opt_q(opt, arg): + global task_class + task_class = QuestionTask + + Option(func = opt_q, future = 1, short = 'q', long = ['question'], help = "Don't build; exit status says if up to date.") diff --git a/test/option-q.py b/test/option-q.py index 8d9fb1b8..6e72a261 100644 --- a/test/option-q.py +++ b/test/option-q.py @@ -24,19 +24,53 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import TestSCons +import os.path import string import sys +import TestSCons + test = TestSCons.TestSCons() -test.write('SConstruct', "") +python = sys.executable + +test.write('build.py', r""" +import sys +contents = open(sys.argv[2], 'rb').read() +file = open(sys.argv[1], 'wb') +file.write(contents) +file.close() +""") + +test.write('SConstruct', """ +B = Builder(name='B', action='%s build.py $TARGET $SOURCES') +env = Environment(BUILDERS = [B]) +env.B(target = 'aaa.out', source = 'aaa.in') +env.B(target = 'bbb.out', source = 'bbb.in') +""" % python) + +test.write('aaa.in', "aaa.in\n") +test.write('bbb.in', "bbb.in\n") + +test.run(arguments = '-q aaa.out', status = 1) + +test.fail_test(os.path.exists(test.workpath('aaa.out'))) + +test.run(arguments = 'aaa.out') + +test.fail_test(test.read('aaa.out') != "aaa.in\n") + +test.run(arguments = '-q aaa.out', status = 0) + +test.run(arguments = '--question bbb.out', status = 1) + +test.fail_test(os.path.exists(test.workpath('bbb.out'))) + +test.run(arguments = 'bbb.out') -test.run(arguments = '-q', - stderr = "Warning: the -q option is not yet implemented\n") +test.fail_test(test.read('bbb.out') != "bbb.in\n") -test.run(arguments = '--question', - stderr = "Warning: the --question option is not yet implemented\n") +test.run(arguments = '--question bbb.out', status = 0) test.pass_test()