-
Notifications
You must be signed in to change notification settings - Fork 10
DEV-6897 Fix termination bug in rust #172
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
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e651b08
fix(rust): unallow exit
6c04486
use mapfile
eedb551
add isolate.sh to Dockerfile
7ed5acf
change isolate.sh folder on Dockerfile
b60e413
change isolate.sh folder on Dockerfile
a5b31a6
change runner path
e8a8aeb
not a relative path..
3b0f382
changed paths again. i love docker
a2abf2f
should work now - didn't take should_panic tests in consideration
1b4d39b
fix(rust-tests): add logging if some tests aren't ran
pedrodesu 4720a55
fix(rust-tests): escape backticks on isolate.sh
pedrodesu 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #!/usr/bin/env bash | ||
| # Use: | ||
| # cargo --config 'target."cfg(all())".runner="./isolate.sh"' test [args] | ||
|
|
||
| set -u | ||
|
|
||
| bin="${1:-}"; shift || true | ||
| [[ -n "${bin:-}" ]] || { echo "[wrapper] missing test binary" >&2; exit 2; } | ||
|
|
||
| # Strip Cargo-only flags that confuse the test binary (e.g., --message-format) | ||
| filter_args() { | ||
| local -a out=(); local skip=0 | ||
| for a in "$@"; do | ||
| if [[ $skip -eq 1 ]]; then skip=0; continue; fi | ||
| case "$a" in | ||
| --message-format|--format) skip=1 ;; # drop the next token | ||
| --message-format=*|--format=*) ;; # drop inline forms | ||
| *) out+=("$a") ;; | ||
| esac | ||
| done | ||
| printf '%s\n' "${out[@]}" | ||
| } | ||
| mapfile -t filtered < <(filter_args "$@") | ||
|
|
||
| tmpdir="$(mktemp -d -t strictwrap.XXXXXX)"; trap 'rm -rf "$tmpdir"' EXIT | ||
| expected="$tmpdir/expected.txt" | ||
| actual="$tmpdir/actual.txt" | ||
| logfile="$tmpdir/run.out" | ||
|
|
||
| # 1) Ask the harness which tests it *will* run (respects filters in "$@") | ||
| if ! "$bin" --list "${filtered[@]}" >"$tmpdir/list.txt" 2>/dev/null; then | ||
| echo "[wrapper] unable to list tests; cannot verify harness" >&2 | ||
| exit 1 | ||
| fi | ||
| # Lines look like: `path::to::name: test` (sometimes with " (ignored)") | ||
| awk -F': test' '/: test/{print $1}' "$tmpdir/list.txt" | sed 's/[[:space:]]*$//' > "$expected" | ||
|
|
||
| # 2) Run the suite normally and capture output + real exit code | ||
| ( | ||
| "$bin" "${filtered[@]}" 2>&1 | ||
| echo "__RC__$?" | ||
| ) | tee "$logfile" >/dev/null | ||
| rc="$(awk -F'__RC__' '/__RC__/ {v=$2} END{print v+0}' "$logfile")" | ||
|
|
||
| # 3) Collect tests that actually produced a result line: | ||
| # Matches lines like: `test foo::bar ... ok|ignored|FAILED` | ||
| # Normalize names by stripping the " - should panic[ with `...`]" suffix. | ||
| awk ' | ||
| /^test[[:space:]][^ ]/ { | ||
| line=$0 | ||
| sub(/^test[[:space:]]+/, "", line) # drop leading "test " | ||
| sub(/[[:space:]]+\.\.\..*$/, "", line) # drop " ... ok/FAILED/ignored" | ||
| # Remove should_panic annotation added to pretty output: | ||
| sub(/[[:space:]]+- should panic( with `[^`]*`)?$/, "", line) | ||
| print line | ||
| } | ||
| ' "$logfile" | sed 's/[[:space:]]*$//' > "$actual" | ||
|
|
||
| # 4) Decide: require (a) rc==0, (b) final summary ok, (c) every expected test appeared | ||
| if [[ "$rc" -eq 0 ]] && grep -Eq '^test result: ok\.' "$logfile"; then | ||
| sort -u "$expected" -o "$expected" | ||
| sort -u "$actual" -o "$actual" | ||
| # If no tests were expected (filters matched none), that's fine too. | ||
| if comm -23 "$expected" "$actual" | read -r _; then | ||
| # there were missing tests → failure | ||
| echo "Some tests weren't ran for the exercise \`$EXERCISE\`. Perhaps the solution forcefully exits?" | ||
| exit 1 | ||
| else | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| exit 1 | ||
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.
Uh oh!
There was an error while loading. Please reload this page.