From 6224396a0eb2d5d20b1a2cae49d64afdebca3e0c Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 21 Sep 2001 02:20:19 +0000 Subject: [PATCH] Error message if no SConstruct file. git-svn-id: http://scons.tigris.org/svn/scons/trunk@64 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- 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 49c8f21d..b6f2c68c 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 9dc41e65..51593eb9 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 34710a32..8837b62d 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 3c8663bc..f94ebe5c 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 -- 2.26.2