diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/test_errors.py | 40 | ||||
-rw-r--r-- | test/unit/test_features.py | 2 | ||||
-rw-r--r-- | test/unit/test_parsing_error.py | 19 |
3 files changed, 41 insertions, 20 deletions
diff --git a/test/unit/test_errors.py b/test/unit/test_errors.py new file mode 100644 index 000000000..15c5a44e6 --- /dev/null +++ b/test/unit/test_errors.py @@ -0,0 +1,40 @@ +import os + +from scripts.test import shared +from . import utils + + +class ErrorsTest(utils.BinaryenTestCase): + def test_parsing_error_msg(self): + module = ''' +(module + (func $foo + (abc) + ) +) +''' + p = shared.run_process(shared.WASM_OPT + ['--print', '-o', os.devnull], + input=module, check=False, capture_output=True) + self.assertNotEqual(p.returncode, 0) + self.assertIn("parse exception: abc (at 4:4)", p.stderr) + + def test_validation_error_msg(self): + def test(args=[], extra_expected=None): + module = ''' +(module + (memory (shared 10 20)) +) +''' + p = shared.run_process(shared.WASM_OPT + ['-o', os.devnull] + args, + input=module, check=False, capture_output=True) + self.assertNotEqual(p.returncode, 0) + self.assertIn('memory is shared, but atomics are disabled', p.stderr) + if extra_expected: + self.assertIn(extra_expected, p.stdout) + + test() + # when the user asks to print the module, we print it even if it is + # invalid, for debugging (otherwise, an invalid module would not reach + # the stage of runnning passes, and print is a pass, so nothing would + # be printed) + test(['--print'], '(module') diff --git a/test/unit/test_features.py b/test/unit/test_features.py index e0a3064d5..e77468366 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -10,7 +10,7 @@ class FeatureValidationTest(utils.BinaryenTestCase): ['--mvp-features', '--print', '-o', os.devnull], input=module, check=False, capture_output=True) self.assertIn(error, p.stderr) - self.assertIn('Fatal: error in validating input', p.stderr) + self.assertIn('Fatal: error validating input', p.stderr) self.assertNotEqual(p.returncode, 0) p = shared.run_process( shared.WASM_OPT + ['--mvp-features', '--print', '-o', os.devnull] + diff --git a/test/unit/test_parsing_error.py b/test/unit/test_parsing_error.py deleted file mode 100644 index c9128045e..000000000 --- a/test/unit/test_parsing_error.py +++ /dev/null @@ -1,19 +0,0 @@ -import os - -from scripts.test import shared -from . import utils - - -class ParsingErrorTest(utils.BinaryenTestCase): - def test_parsing_error_msg(self): - module = ''' -(module - (func $foo - (abc) - ) -) -''' - p = shared.run_process(shared.WASM_OPT + ['--print', '-o', os.devnull], - input=module, check=False, capture_output=True) - self.assertNotEqual(p.returncode, 0) - self.assertIn("parse exception: abc (at 4:4)", p.stderr) |