Skip to content

Commit 4255653

Browse files
chrisfarmsMarenz
authored andcommitted
lsp: add expect_report helper to lsp tests
ordering of reports returned appears to be different in ci tests than local (arch dependent?). avoid expecting reports in exact order by using expect_report(uri) helper
1 parent 35496d8 commit 4255653

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/lsp.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,13 @@ def open_file_and_wait_for_diagnostics(
10851085
)
10861086
return self.wait_for_diagnostics(solc_process)
10871087

1088+
def expect_report(self, published_diagnostics, uri):
1089+
for report in published_diagnostics:
1090+
if report['uri'] == uri:
1091+
return report
1092+
self.expect_true(False, f"expected ${uri} in published_diagnostics")
1093+
return None
1094+
10881095
def expect_true(
10891096
self,
10901097
actual,
@@ -1567,16 +1574,14 @@ def test_remapping(self, solc: JsonRpcProcess) -> None:
15671574
published_diagnostics = self.wait_for_diagnostics(solc)
15681575
self.expect_equal(len(published_diagnostics), 2, "expected reports for two files")
15691576

1570-
report = published_diagnostics[0]
1571-
self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol")
1577+
report = self.expect_report(published_diagnostics, file_with_remapped_import_uri)
15721578
diagnostics = report['diagnostics']
1573-
self.expect_equal(len(diagnostics), 1, "no diagnostics")
1574-
self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62))
1579+
self.expect_equal(len(diagnostics), 0, "no diagnostics")
15751580

1576-
report = published_diagnostics[1]
1577-
self.expect_equal(report['uri'], file_with_remapped_import_uri)
1581+
report = self.expect_report(published_diagnostics, f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol")
15781582
diagnostics = report['diagnostics']
1579-
self.expect_equal(len(diagnostics), 0, "no diagnostics")
1583+
self.expect_equal(len(diagnostics), 1, "no diagnostics")
1584+
self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62))
15801585

15811586
def test_custom_includes_with_full_project(self, solc: JsonRpcProcess) -> None:
15821587
"""

0 commit comments

Comments
 (0)