summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/Errors.py11
-rw-r--r--src/engine/SCons/ErrorsTests.py25
2 files changed, 30 insertions, 6 deletions
diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py
index dae20b2..3746d5d 100644
--- a/src/engine/SCons/Errors.py
+++ b/src/engine/SCons/Errors.py
@@ -190,14 +190,13 @@ def convert_to_BuildError(status, exc_info=None):
# error, which might be different from the target being built
# (for example, failure to create the directory in which the
# target file will appear).
- try:
- filename = status.filename
- except AttributeError:
- filename = None
+ filename = getattr(status, 'filename', None)
+ strerror = getattr(status, 'strerror', str(status))
+ errno = getattr(status, 'errno', 2)
buildError = BuildError(
- errstr=status.strerror,
- status=status.errno,
+ errstr=strerror,
+ status=errno,
exitstatus=2,
filename=filename,
exc_info=exc_info)
diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py
index c38158d..7819580 100644
--- a/src/engine/SCons/ErrorsTests.py
+++ b/src/engine/SCons/ErrorsTests.py
@@ -23,6 +23,8 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import errno
+import os
import sys
import unittest
@@ -100,6 +102,29 @@ class ErrorsTestCase(unittest.TestCase):
except SCons.Errors.ExplicitExit as e:
assert e.node == "node"
+ def test_convert_EnvironmentError_to_BuildError(self):
+ """Test the convert_to_BuildError function on EnvironmentError
+ exceptions.
+ """
+ ee = SCons.Errors.EnvironmentError("test env error")
+ be = SCons.Errors.convert_to_BuildError(ee)
+ assert be.errstr == "test env error"
+ assert be.status == 2
+ assert be.exitstatus == 2
+ assert be.filename is None
+
+ def test_convert_OSError_to_BuildError(self):
+ """Test the convert_to_BuildError function on OSError
+ exceptions.
+ """
+ ose = OSError(7, 'test oserror')
+ be = SCons.Errors.convert_to_BuildError(ose)
+ assert be.errstr == 'test oserror'
+ assert be.status == 7
+ assert be.exitstatus == 2
+ assert be.filename is None
+
+
if __name__ == "__main__":
suite = unittest.makeSuite(ErrorsTestCase, 'test_')
TestUnit.run(suite)