summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/ErrorsTests.py
diff options
context:
space:
mode:
authorFredrik Medley <fredrik.medley@autoliv.com>2018-03-29 13:40:06 (GMT)
committerFredrik Medley <fredrik.medley@autoliv.com>2018-04-05 20:24:02 (GMT)
commit5e5cccde062fe18290048ab4adb4b2270fdf6c94 (patch)
treefc1bbdb70247b7dc2cc3c5d22e23dc034748c2c3 /src/engine/SCons/ErrorsTests.py
parent20927b42ed4f0cb87f51287fa3b4b6cf915afcf8 (diff)
downloadSCons-5e5cccde062fe18290048ab4adb4b2270fdf6c94.zip
SCons-5e5cccde062fe18290048ab4adb4b2270fdf6c94.tar.gz
SCons-5e5cccde062fe18290048ab4adb4b2270fdf6c94.tar.bz2
Fix EnvironmentError printing bug
EnvironmentErrors does not need to have the attributes strerror or errno. This commit makes the code robust for such situation. One example of such EnvironmentError is CacheDir.py: raise SCons.Errors.EnvironmentError(msg) Signed-off-by: Fredrik Medley <fredrik.medley@autoliv.com>
Diffstat (limited to 'src/engine/SCons/ErrorsTests.py')
-rw-r--r--src/engine/SCons/ErrorsTests.py25
1 files changed, 25 insertions, 0 deletions
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)