aboutsummaryrefslogtreecommitdiff
path: root/tests/fruit_test_common.py
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2018-04-22 12:06:40 +0100
committerMarco Poletti <poletti.marco@gmail.com>2018-04-22 12:06:40 +0100
commit74305893f69ba901b68d88c67c0d085d933233d9 (patch)
tree8d079563b9c58dd1ce4d634243be6ae1bed701db /tests/fruit_test_common.py
parent0d23b1c916216ce3c7bc9f7b2eddcc5a02e65aba (diff)
downloadgoogle-fruit-74305893f69ba901b68d88c67c0d085d933233d9.tar.gz
Disable the check on the error message's line number in the test where we expect warnings.
Diffstat (limited to 'tests/fruit_test_common.py')
-rw-r--r--tests/fruit_test_common.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/fruit_test_common.py b/tests/fruit_test_common.py
index 27b8306..ac9b3bd 100644
--- a/tests/fruit_test_common.py
+++ b/tests/fruit_test_common.py
@@ -318,7 +318,8 @@ def expect_compile_error(
source_code,
test_params={},
ignore_deprecation_warnings=False,
- ignore_warnings=False):
+ ignore_warnings=False,
+ disable_error_line_number_check=False):
"""
Tests that the given source produces the expected error during compilation.
@@ -336,6 +337,8 @@ def expect_compile_error(
was provided).
:param ignore_deprecation_warnings: A boolean. If True, deprecation warnings will be ignored.
:param ignore_warnings: A boolean. If True, all warnings will be ignored.
+ :param disable_error_line_number_check: A boolean. If True, the test will not fail if there are other diagnostic
+ lines before the expected error.
"""
if '\n' in expected_fruit_error_regex:
raise Exception('expected_fruit_error_regex should not contain newlines')
@@ -444,7 +447,7 @@ def expect_compile_error(
# 6 is just a constant that works for both g++ (<=6.0.0 at least) and clang++ (<=4.0.0 at least).
# It might need to be changed.
- if actual_fruit_error_line_number > 6 or actual_static_assert_error_line_number > 6:
+ if not disable_error_line_number_check and (actual_fruit_error_line_number > 6 or actual_static_assert_error_line_number > 6):
raise Exception(textwrap.dedent('''\
The compilation failed with the expected message, but the error message contained too many lines before the relevant ones.
The error type was reported on line {actual_fruit_error_line_number} of the message (should be <=6).