summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-02-21 22:30:24 (GMT)
committerSteven Knight <knight@baldmt.com>2002-02-21 22:30:24 (GMT)
commit514955d91597edc49a05e5260caaca8db7506ab7 (patch)
treedd3154bcbb6b4bc9a5b37c42ebf5d481480b528a
parent53bf767e4ba2810d5880d319cc9ac2bf4d4f2590 (diff)
downloadSCons-514955d91597edc49a05e5260caaca8db7506ab7.zip
SCons-514955d91597edc49a05e5260caaca8db7506ab7.tar.gz
SCons-514955d91597edc49a05e5260caaca8db7506ab7.tar.bz2
Add the -q option.
-rw-r--r--doc/man/scons.114
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/RELEASE.txt2
-rw-r--r--src/engine/SCons/Script/__init__.py16
-rw-r--r--test/option-q.py46
5 files changed, 65 insertions, 15 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index ef5b664..461e8fa 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 4643b9a..33a4a40 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 358a359..f257e84 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 529729e..84882f4 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 8d9fb1b..6e72a26 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()