-
-
Notifications
You must be signed in to change notification settings - Fork 185
Any ordered tests #973
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
Merged
bencroker
merged 4 commits into
release-candidate
from
delaneyj/issue972-any-ordered-tests
Jul 8, 2025
Merged
Any ordered tests #973
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Usage: compare-sse.sh expected.txt actual.txt | ||
| # Compares two SSE files allowing fields to be in any order | ||
| # but preserving order within same prefix types | ||
|
|
||
| if [ $# -ne 2 ]; then | ||
| echo "Usage: $0 expected.txt actual.txt" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| expected="$1" | ||
| actual="$2" | ||
|
|
||
| if [ ! -f "$expected" ]; then | ||
| echo "Expected file not found: $expected" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "$actual" ]; then | ||
| echo "Actual file not found: $actual" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Use awk to parse and compare SSE events | ||
| awk ' | ||
| BEGIN { | ||
| RS = "\n\n\n" # Events separated by double newlines | ||
| FS = "\n" # Fields separated by single newlines | ||
| event_count_1 = 0 | ||
| event_count_2 = 0 | ||
| } | ||
|
|
||
| # Process first file (expected) | ||
| NR == FNR { | ||
| if (NF > 0) { | ||
| event_count_1++ | ||
| delete fields | ||
| delete field_order | ||
| field_count = 0 | ||
|
|
||
| # Parse fields and group by prefix | ||
| for (i = 1; i <= NF; i++) { | ||
| if ($i != "") { | ||
| field_count++ | ||
| # Extract prefix (everything before first colon) | ||
| prefix = $i | ||
| sub(/:.*/, "", prefix) | ||
|
|
||
| # Store field content | ||
| if (!(prefix in fields)) { | ||
| fields[prefix] = "" | ||
| field_order[prefix] = 0 | ||
| } | ||
| if (fields[prefix] != "") { | ||
| fields[prefix] = fields[prefix] "\n" | ||
| } | ||
| fields[prefix] = fields[prefix] $i | ||
| field_order[prefix]++ | ||
| } | ||
| } | ||
|
|
||
| # Store event data | ||
| for (prefix in fields) { | ||
| events_1[event_count_1, prefix] = fields[prefix] | ||
| event_field_count_1[event_count_1, prefix] = field_order[prefix] | ||
| } | ||
| } | ||
| next | ||
| } | ||
|
|
||
| # Process second file (actual) | ||
| { | ||
| if (NF > 0) { | ||
| event_count_2++ | ||
| delete fields | ||
| delete field_order | ||
| field_count = 0 | ||
|
|
||
| # Parse fields and group by prefix | ||
| for (i = 1; i <= NF; i++) { | ||
| if ($i != "") { | ||
| field_count++ | ||
| # Extract prefix | ||
| prefix = $i | ||
| sub(/:.*/, "", prefix) | ||
|
|
||
| # Store field content | ||
| if (!(prefix in fields)) { | ||
| fields[prefix] = "" | ||
| field_order[prefix] = 0 | ||
| } | ||
| if (fields[prefix] != "") { | ||
| fields[prefix] = fields[prefix] "\n" | ||
| } | ||
| fields[prefix] = fields[prefix] $i | ||
| field_order[prefix]++ | ||
| } | ||
| } | ||
|
|
||
| # Store event data | ||
| for (prefix in fields) { | ||
| events_2[event_count_2, prefix] = fields[prefix] | ||
| event_field_count_2[event_count_2, prefix] = field_order[prefix] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| END { | ||
| # Compare event counts | ||
| if (event_count_1 != event_count_2) { | ||
| print "Event count mismatch: expected " event_count_1 ", got " event_count_2 > "/dev/stderr" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Compare each event | ||
| for (e = 1; e <= event_count_1; e++) { | ||
| # Collect all prefixes from both events | ||
| delete all_prefixes | ||
| for (key in events_1) { | ||
| split(key, parts, SUBSEP) | ||
| if (parts[1] == e) { | ||
| all_prefixes[parts[2]] = 1 | ||
| } | ||
| } | ||
| for (key in events_2) { | ||
| split(key, parts, SUBSEP) | ||
| if (parts[1] == e) { | ||
| all_prefixes[parts[2]] = 1 | ||
| } | ||
| } | ||
|
|
||
| # Compare fields for each prefix | ||
| for (prefix in all_prefixes) { | ||
| key1 = e SUBSEP prefix | ||
| key2 = e SUBSEP prefix | ||
|
|
||
| # Check if prefix exists in both | ||
| if (!(key1 in events_1) && !(key2 in events_2)) { | ||
| continue | ||
| } | ||
|
|
||
| if (!(key1 in events_1)) { | ||
| print "Event " e ": missing prefix \"" prefix "\" in expected" > "/dev/stderr" | ||
| exit 1 | ||
| } | ||
|
|
||
| if (!(key2 in events_2)) { | ||
| print "Event " e ": missing prefix \"" prefix "\" in actual" > "/dev/stderr" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Compare field content | ||
| if (events_1[key1] != events_2[key2]) { | ||
| print "Event " e ": mismatch in \"" prefix "\" fields" > "/dev/stderr" | ||
| print "Expected:" > "/dev/stderr" | ||
| print events_1[key1] > "/dev/stderr" | ||
| print "Actual:" > "/dev/stderr" | ||
| print events_2[key2] > "/dev/stderr" | ||
| exit 1 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # All matches | ||
| exit 0 | ||
| } | ||
| ' "$expected" "$actual" |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous diff showed the file with differences. With this code the culprit is not visible.
On exit > 0 the $1 should be echoed to find out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try latest plz