mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
tests: Exclude lines from coverage
Exclude things like "raise NotImplementedError" and compiler bug handlers.
This commit is contained in:
parent
85150d397b
commit
1897478480
4 changed files with 15 additions and 12 deletions
6
.coveragerc
Normal file
6
.coveragerc
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[report]
|
||||||
|
exclude_lines =
|
||||||
|
pragma: no cover
|
||||||
|
raise AssertionError
|
||||||
|
raise NotImplementedError
|
||||||
|
raise CompilerBugError
|
|
@ -121,7 +121,7 @@ def assert_true(truth: bool, message:str=None):
|
||||||
raise CompilerBugError(message)
|
raise CompilerBugError(message)
|
||||||
|
|
||||||
|
|
||||||
def report_bug():
|
def report_bug(): # pragma: no cover
|
||||||
""" Report an error and ask people to report it. """
|
""" Report an error and ask people to report it. """
|
||||||
|
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|
|
@ -46,11 +46,11 @@ class TestSamples(unittest.TestCase):
|
||||||
raise MultipleErrors(ast.errors)
|
raise MultipleErrors(ast.errors)
|
||||||
|
|
||||||
actual = ast.generate()
|
actual = ast.generate()
|
||||||
if actual.strip() != expected.strip():
|
if actual.strip() != expected.strip(): # pragma: no cover
|
||||||
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
|
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
|
||||||
print("\n".join(diff))
|
print("\n".join(diff))
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
except PrintableError as e:
|
except PrintableError as e: # pragma: no cover
|
||||||
e.pretty_print(name + ".blp", blueprint)
|
e.pretty_print(name + ".blp", blueprint)
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ class TestSamples(unittest.TestCase):
|
||||||
actual = error_str(e)
|
actual = error_str(e)
|
||||||
elif isinstance(e, MultipleErrors):
|
elif isinstance(e, MultipleErrors):
|
||||||
actual = "\n".join([error_str(error) for error in e.errors])
|
actual = "\n".join([error_str(error) for error in e.errors])
|
||||||
else:
|
else: # pragma: no cover
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
|
|
||||||
if actual.strip() != expected.strip():
|
if actual.strip() != expected.strip(): # pragma: no cover
|
||||||
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
|
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
|
||||||
print("\n".join(diff))
|
print("\n".join(diff))
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
else:
|
else: # pragma: no cover
|
||||||
# Expected a compiler error but there wasn't one
|
# Expected a compiler error but there wasn't one
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
|
|
||||||
|
@ -101,11 +101,11 @@ class TestSamples(unittest.TestCase):
|
||||||
|
|
||||||
actual = decompiler.decompile(ui_path)
|
actual = decompiler.decompile(ui_path)
|
||||||
|
|
||||||
if actual.strip() != expected.strip():
|
if actual.strip() != expected.strip(): # pragma: no cover
|
||||||
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
|
diff = difflib.unified_diff(expected.splitlines(), actual.splitlines())
|
||||||
print("\n".join(diff))
|
print("\n".join(diff))
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
except PrintableError as e:
|
except PrintableError as e: # pragma: no cover
|
||||||
e.pretty_print(name + ".blp", blueprint)
|
e.pretty_print(name + ".blp", blueprint)
|
||||||
raise AssertionError()
|
raise AssertionError()
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TestTokenizer(unittest.TestCase):
|
||||||
for token, (type, token_str) in zip(tokens, expect):
|
for token, (type, token_str) in zip(tokens, expect):
|
||||||
self.assertEqual(token.type, type)
|
self.assertEqual(token.type, type)
|
||||||
self.assertEqual(str(token), token_str)
|
self.assertEqual(str(token), token_str)
|
||||||
except PrintableError as e:
|
except PrintableError as e: # pragma: no cover
|
||||||
e.pretty_print("<test input>", string)
|
e.pretty_print("<test input>", string)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -71,6 +71,3 @@ class TestTokenizer(unittest.TestCase):
|
||||||
(TokenType.EOF, ""),
|
(TokenType.EOF, ""),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
unittest.main()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue