summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-02-04 04:44:14 (GMT)
committerSteven Knight <knight@baldmt.com>2002-02-04 04:44:14 (GMT)
commit52fe7f7c362cacb48f33be6928c27cfc0aa5b5e5 (patch)
tree7f55b7c678210ad4d91953f512e12ea5b1a4801f
parent918d875dbbf44d24ac4c8400b42b804afdb66d89 (diff)
downloadSCons-52fe7f7c362cacb48f33be6928c27cfc0aa5b5e5.zip
SCons-52fe7f7c362cacb48f33be6928c27cfc0aa5b5e5.tar.gz
SCons-52fe7f7c362cacb48f33be6928c27cfc0aa5b5e5.tar.bz2
Make scons return an error code (Anthony Roach)
-rw-r--r--etc/TestSCons.py8
-rw-r--r--src/engine/SCons/Script/__init__.py5
-rw-r--r--test/SConstruct.py2
-rw-r--r--test/dependency-cycle.py2
-rw-r--r--test/errors.py6
5 files changed, 15 insertions, 8 deletions
diff --git a/etc/TestSCons.py b/etc/TestSCons.py
index 956b454..14c2e0b 100644
--- a/etc/TestSCons.py
+++ b/etc/TestSCons.py
@@ -68,7 +68,7 @@ class TestSCons(TestCmd.TestCmd):
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
@@ -82,6 +82,10 @@ class TestSCons(TestCmd.TestCmd):
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 = "").
"""
@@ -93,7 +97,7 @@ class TestSCons(TestCmd.TestCmd):
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()
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 842e7ee..93ba795 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -136,6 +136,7 @@ def _scons_syntax_error(e):
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
@@ -149,6 +150,7 @@ def _scons_user_error(e):
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
@@ -169,7 +171,7 @@ def _scons_other_errors():
"""
print 'other errors'
traceback.print_exc()
-
+ sys.exit(2)
#
@@ -700,6 +702,7 @@ def main():
pass
except KeyboardInterrupt:
print "Build interrupted."
+ sys.exit(1)
except SyntaxError, e:
_scons_syntax_error(e)
except UserError, e:
diff --git a/test/SConstruct.py b/test/SConstruct.py
index 60df1e9..de5b72e 100644
--- a/test/SConstruct.py
+++ b/test/SConstruct.py
@@ -33,7 +33,7 @@ test.run(stdout = "",
stderr = r"""
SCons error: No SConstruct file found.
File "\S+", line \d+, in \S+
-""")
+""", status=2)
test.match_func = TestCmd.match_exact
diff --git a/test/dependency-cycle.py b/test/dependency-cycle.py
index abdd50d..3be8da4 100644
--- a/test/dependency-cycle.py
+++ b/test/dependency-cycle.py
@@ -50,7 +50,7 @@ f1(void)
test.run(arguments = ".", stdout = "", stderr=r"""
SCons error: Dependency cycle: .*foo1.* -> .*foo3.* -> .*foo2.* -> .*foo1.* -> \.
.*
-""")
+""", status=2)
test.pass_test()
diff --git a/test/errors.py b/test/errors.py
index f8c5506..1f582f7 100644
--- a/test/errors.py
+++ b/test/errors.py
@@ -43,7 +43,7 @@ test.run(arguments='-f SConstruct1',
SyntaxError: invalid syntax
-""")
+""", status=2)
test.write('SConstruct2', """
@@ -57,7 +57,7 @@ test.run(arguments='-f 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")
@@ -77,6 +77,6 @@ test.run(arguments='-f SConstruct3',
File "SConstruct3", line \d+, in \?
raise InternalError, 'error inside'
InternalError: error inside
-""")
+""", status=2)
test.pass_test()