Skip to content

Commit 47cb5d5

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 47cb5d5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/lsp.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,12 @@ 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+
10881094
def expect_true(
10891095
self,
10901096
actual,
@@ -1567,16 +1573,14 @@ def test_remapping(self, solc: JsonRpcProcess) -> None:
15671573
published_diagnostics = self.wait_for_diagnostics(solc)
15681574
self.expect_equal(len(published_diagnostics), 2, "expected reports for two files")
15691575

1570-
report = published_diagnostics[0]
1571-
self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol")
1576+
report = self.expect_report(published_diagnostics, file_with_remapped_import_uri)
15721577
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))
1578+
self.expect_equal(len(diagnostics), 0, "no diagnostics")
15751579

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

15811585
def test_custom_includes_with_full_project(self, solc: JsonRpcProcess) -> None:
15821586
"""

0 commit comments

Comments
 (0)