.\" .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
- 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
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
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.")
__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()