lsp.py: Trigger fatal error when importing outside of test dir

This commit is contained in:
Marenz 2022-04-25 17:03:31 +02:00 committed by Mathias Baumann
parent 59e054bb9b
commit 02dfeb5427

View File

@ -536,6 +536,10 @@ class FileTestRunner:
self.suite.open_file_and_wait_for_diagnostics(self.solc, self.test_name) self.suite.open_file_and_wait_for_diagnostics(self.solc, self.test_name)
for diagnostics in published_diagnostics: for diagnostics in published_diagnostics:
if not diagnostics["uri"].startswith(self.suite.project_root_uri + "/"):
raise Exception(
f"'{self.test_name}.sol' imported file outside of test directory: '{diagnostics['uri']}'"
)
self.open_tests.append(diagnostics["uri"].replace(self.suite.project_root_uri + "/", "")[:-len(".sol")]) self.open_tests.append(diagnostics["uri"].replace(self.suite.project_root_uri + "/", "")[:-len(".sol")])
self.suite.expect_equal( self.suite.expect_equal(
@ -570,8 +574,7 @@ class FileTestRunner:
marker=markers[expected_diagnostic.marker] marker=markers[expected_diagnostic.marker]
) )
except Exception as e: except Exception:
print(e)
self.close_all_open_files() self.close_all_open_files()
raise raise