print "STDERR ============"
print self.stderr()
raise TestFailed
- if stdout and not self.match(self.stdout(), stdout):
+ if not stdout is None and not self.match(self.stdout(), stdout):
print "Expected STDOUT =========="
print stdout
print "Actual STDOUT ============"
print "STDERR ==================="
print stderr
raise TestFailed
- if stderr and not self.match(self.stderr(), stderr):
+ if not stderr is None and not self.match(self.stderr(), stderr):
print "Expected STDERR =========="
print stderr
print "Actual STDERR ============"
"""Handle user errors. Print out a message and a description of the
error, along with the line number and routine where it occured.
"""
- print 'user error'
etype, value, tb = sys.exc_info()
while tb.tb_next is not None:
tb = tb.tb_next
Scripts.append(file)
break
- if local_help and not Scripts:
- # They specified -h, but there's no SConstruct. Give them
- # the options usage before we try to read it and fail.
- PrintUsage()
- sys.exit(0)
+ if not Scripts:
+ if local_help:
+ # There's no SConstruct, but they specified -h. Give them
+ # the options usage before we try to read it and fail.
+ PrintUsage()
+ sys.exit(0)
+ else:
+ raise UserError, "No SConstruct file found."
# XXX The commented-out code here adds any "scons" subdirs in anything
# along sys.path to sys.path. This was an attempt at setting up things
test = TestSCons.TestSCons()
+test.run(stdout = "",
+ stderr = """
+SCons error: No SConstruct file found.
+File "\S+scons(\.py)?", line \d+, in main
+""")
+
wpath = test.workpath()
test.write('sconstruct', """
a ! x
""")
-test.run(arguments='-f SConstruct1', stderr = """ File "SConstruct1", line 2
+test.run(arguments='-f SConstruct1',
+ stdout = "",
+ stderr = """ File "SConstruct1", line 2
a ! x
test.write('SConstruct2', """
raise UserError, 'Depends() require both sources and targets.'
""")
-test.run(arguments='-f SConstruct2', stderr = """
+
+test.run(arguments='-f SConstruct2',
+ stdout = "",
+ stderr = """
SCons error: Depends\(\) require both sources and targets.
File "SConstruct2", line 2, in \?
""")
test.write('SConstruct3', """
raise InternalError, 'error inside'
""")
-test.run(arguments='-f SConstruct3', stderr = r"""Traceback \((most recent call|innermost) last\):
+
+test.run(arguments='-f SConstruct3',
+ stdout = "other errors\n",
+ stderr = r"""Traceback \((most recent call|innermost) last\):
File ".*scons(\.py)?", line \d+, in \?
main\(\)
File ".*scons(\.py)?", line \d+, in main