From 02dfeb5427e790e8ee06c89fc267f7cdb5ab6370 Mon Sep 17 00:00:00 2001 From: Marenz Date: Mon, 25 Apr 2022 17:03:31 +0200 Subject: [PATCH] lsp.py: Trigger fatal error when importing outside of test dir --- test/lsp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/lsp.py b/test/lsp.py index 3217fb79b..c14fc6a4c 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -536,6 +536,10 @@ class FileTestRunner: self.suite.open_file_and_wait_for_diagnostics(self.solc, self.test_name) 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.suite.expect_equal( @@ -570,8 +574,7 @@ class FileTestRunner: marker=markers[expected_diagnostic.marker] ) - except Exception as e: - print(e) + except Exception: self.close_all_open_files() raise