Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unordered compare diamond nodes #81

Merged
merged 2 commits into from
May 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ class Result:
expected: str
command: list[str]

def unordered_compare(out, expected):
if out == expected:
return True

sorted_out = out.split()
sorted_expected = expected.split()
sorted_out.sort()
sorted_expected.sort()

if len(sorted_out) != len(sorted_expected):
return False

for i in range(len(sorted_out)):
if sorted_out[i] != sorted_expected[i]:
return False

return True
ckyang0225 marked this conversation as resolved.
Show resolved Hide resolved

async def test(runner: str, case_: TestCase) -> Result:
cmd = [runner, case_['cps']] + case_['args']
Expand All @@ -77,7 +94,8 @@ async def test(runner: str, case_: TestCase) -> Result:
out = bout.decode().strip()
err = berr.decode().strip()

success = proc.returncode == case_.get('returncode', 0) and out == expected
# success = proc.returncode == case_.get('returncode', 0) and out == expected
success = proc.returncode == case_.get('returncode', 0) and unordered_compare(out, expected)
result = Status.PASS if success else Status.FAIL
returncode = proc.returncode
except asyncio.TimeoutError:
Expand Down
Loading