apply(TestCmd.TestCmd.__init__, [self], kw)
os.chdir(self.workdir)
- def run(self, stdout = None, stderr = '', **kw):
+ def run(self, stdout = None, stderr = '', status = 0, **kw):
"""Runs SCons.
This is the same as the base TestCmd.run() method, with
the command. A value of None means
don't test error output.
+ status The expected exit status from the
+ command.
+
+
By default, this does not test standard output (stdout = None),
and expects that error output is empty (stderr = "").
"""
print "STDERR ============"
print self.stderr()
raise
- if self.status:
+ if self.status>>8 != status:
print "%s returned %d" % (self.program, self.status >> 8)
print "STDERR ============"
print self.stderr()
lines = traceback.format_exception_only(etype, value)
for line in lines:
sys.stderr.write(line+'\n')
+ sys.exit(2)
def _scons_user_error(e):
"""Handle user errors. Print out a message and a description of the
routine = tb.tb_frame.f_code.co_name
sys.stderr.write("\nSCons error: %s\n" % value)
sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine))
+ sys.exit(2)
def _scons_user_warning(e):
"""Handle user warnings. Print out a message and a description of
"""
print 'other errors'
traceback.print_exc()
-
+ sys.exit(2)
#
pass
except KeyboardInterrupt:
print "Build interrupted."
+ sys.exit(1)
except SyntaxError, e:
_scons_syntax_error(e)
except UserError, e:
stderr = r"""
SCons error: No SConstruct file found.
File "\S+", line \d+, in \S+
-""")
+""", status=2)
test.match_func = TestCmd.match_exact
test.run(arguments = ".", stdout = "", stderr=r"""
SCons error: Dependency cycle: .*foo1.* -> .*foo3.* -> .*foo2.* -> .*foo1.* -> \.
.*
-""")
+""", status=2)
test.pass_test()
SyntaxError: invalid syntax
-""")
+""", status=2)
test.write('SConstruct2', """
stderr = """
SCons error: Depends\(\) require both sources and targets.
File "SConstruct2", line 4, in \?
-""")
+""", status=2)
test.write('SConstruct3', """
assert not globals().has_key("InternalError")
File "SConstruct3", line \d+, in \?
raise InternalError, 'error inside'
InternalError: error inside
-""")
+""", status=2)
test.pass_test()