From 635256859678b6b862b89d4c5ce890b4923e8394 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Fri, 21 Sep 2001 02:20:19 +0000 Subject: Error message if no SConstruct file. --- etc/TestSCons.py | 4 ++-- src/script/scons.py | 14 ++++++++------ test/SConstruct.py | 6 ++++++ test/errors.py | 14 +++++++++++--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/etc/TestSCons.py b/etc/TestSCons.py index 49c8f21..b6f2c68 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -94,7 +94,7 @@ class TestSCons(TestCmd.TestCmd): 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 ============" @@ -104,7 +104,7 @@ class TestSCons(TestCmd.TestCmd): 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 ============" diff --git a/src/script/scons.py b/src/script/scons.py index 9dc41e6..51593eb 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -82,7 +82,6 @@ def _scons_user_error(e): """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 @@ -499,11 +498,14 @@ def main(): 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 diff --git a/test/SConstruct.py b/test/SConstruct.py index 34710a3..8837b62 100644 --- a/test/SConstruct.py +++ b/test/SConstruct.py @@ -6,6 +6,12 @@ import TestSCons 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', """ diff --git a/test/errors.py b/test/errors.py index 3c8663b..f94ebe5 100644 --- a/test/errors.py +++ b/test/errors.py @@ -10,7 +10,9 @@ test.write('SConstruct1', """ 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 @@ -24,7 +26,10 @@ SyntaxError: invalid syntax 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 \? """) @@ -32,7 +37,10 @@ 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 -- cgit v0.12