Scripts: restore caller directory after tests #771

Open
Bababoey7696 wants to merge 1 commit from upstream-pr/776 into main
Bababoey7696 commented 2026-11-24 05:07:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Bababoey7696 on 2026-11-24T05:07:45Z.


scripts/test.ps1 changes the current working directory to the repository root but does not restore the caller's original directory after execution.

This PR uses Push-Location and try/finally with Pop-Location to preserve the caller's working directory.

What is in it

  • scripts/test.ps1: Restore the caller's working directory after running the build and tests.
  • scripts/test-native-stderr.tests.ps1: Run the test from outside the repository and verify that the original directory is restored.

Tested

  • GitHub Actions on Windows Server 2025.
  • Regression tests passed under Windows PowerShell 5.1 and PowerShell 7.
  • Confirmed that the regression test fails before the fix and passes afterward.
  • Windows workspace build and tests passed: 701 passed, 0 failed, 41 ignored.
  • GPU skip reports: 86 (no wave64), 2 (no GPU UMA).
  • Validation branch commit: 9f9770f.
  • Test run: https://github.com/Bababoey7696/xcl/actions/runs/45329542713

Regression run

  • Not required for this scripts-only change.

Not tested

  • Full test suite on a physical GPU.
  • Retail game execution.
  • Official CI on this PR's exact head commit (awaiting maintainer approval).

AI use

  • ChatGPT (GPT-6) assisted with identifying the issue, developing the fix and regression test, configuring validation workflows, and reviewing the test results.
  • The contributor reviewed the changes and performed the initial code edits.
<!-- greyfinch-sync:ivall/xcl:issue:5466472289 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/776). Originally posted by [Bababoey7696](https://github.com/Bababoey7696) on 2026-11-24T05:07:45Z. --- `scripts/test.ps1` changes the current working directory to the repository root but does not restore the caller's original directory after execution. This PR uses `Push-Location` and `try/finally` with `Pop-Location` to preserve the caller's working directory. **What is in it** - `scripts/test.ps1`: Restore the caller's working directory after running the build and tests. - `scripts/test-native-stderr.tests.ps1`: Run the test from outside the repository and verify that the original directory is restored. **Tested** - GitHub Actions on Windows Server 2025. - Regression tests passed under Windows PowerShell 5.1 and PowerShell 7. - Confirmed that the regression test fails before the fix and passes afterward. - Windows workspace build and tests passed: 701 passed, 0 failed, 41 ignored. - GPU skip reports: 86 (no wave64), 2 (no GPU UMA). - Validation branch commit: `9f9770f`. - Test run: https://github.com/Bababoey7696/xcl/actions/runs/45329542713 **Regression run** - Not required for this scripts-only change. **Not tested** - Full test suite on a physical GPU. - Retail game execution. - Official CI on this PR's exact head commit (awaiting maintainer approval). **AI use** - ChatGPT (GPT-6) assisted with identifying the issue, developing the fix and regression test, configuring validation workflows, and reviewing the test results. - The contributor reviewed the changes and performed the initial code edits.
milas6669 commented 2026-11-24 07:06:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by milas6669 on 2026-11-24T05:14:08Z.


Test report on c49a0805 (PR head; base main 64b3f35, main is now d208e14, which does not touch scripts/).

Tested

  • Intel i9-10900KF, Windows 11 Pro 10.0.26200, Windows PowerShell 5.1
  • powershell -NoProfile -ExecutionPolicy Bypass -File scripts/test-native-stderr.tests.ps1 on this head: exit 0.
  • The new check fails without the test.ps1 change: with this PR's test script and test.ps1 taken from main, the run exits 1 with test.ps1 changed the caller working directory.

Not tested

  • pwsh (PowerShell 7)
  • a real scripts/test.ps1 run (it builds and runs the whole suite; the GPU was busy)
  • cargo test: the PR changes only scripts

AI use

  • Claude Code, Claude Sonnet 5.5, ran the commands and wrote this report.
<!-- greyfinch-sync:ivall/xcl:comment:7122754329 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/776#issuecomment-7122754329). Originally posted by [milas6669](https://github.com/milas6669) on 2026-11-24T05:14:08Z. --- Test report on `c49a0805` (PR head; base `main` 64b3f35, `main` is now d208e14, which does not touch `scripts/`). **Tested** - Intel i9-10900KF, Windows 11 Pro 10.0.26200, Windows PowerShell 5.1 - `powershell -NoProfile -ExecutionPolicy Bypass -File scripts/test-native-stderr.tests.ps1` on this head: exit 0. - The new check fails without the `test.ps1` change: with this PR's test script and `test.ps1` taken from `main`, the run exits 1 with `test.ps1 changed the caller working directory.` **Not tested** - `pwsh` (PowerShell 7) - a real `scripts/test.ps1` run (it builds and runs the whole suite; the GPU was busy) - `cargo test`: the PR changes only scripts **AI use** - Claude Code, Claude Sonnet 5.5, ran the commands and wrote this report.
DavidM1911 commented 2026-11-25 11:09:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T11:08:49Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7160654819 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/776#issuecomment-7160654819). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T11:08:49Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
RavenCurseBurg commented 2026-11-25 18:04:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T17:36:15Z.


On c49a080076cce5fc83bb4ca94070a7de44998f61, the caller got its original directory back, but Cargo sometimes ran in a different checkout. I put copies of the script under checkout [A]\scripts, created a sibling checkout A\scripts, and called the bracketed script from a third directory. The native Cargo stand-in logged its actual working directory: both build and test ran under checkout A. A successful run returned 0. This reproduced under Windows PowerShell 5.1.26100.9711 and PowerShell 7.6.9.

Fix and regression test. Using Push-Location -LiteralPath keeps the checkout name literal. The regression checks the directory printed by native Cargo as well as the directory returned to the caller. It failed on this head and passed after the change in both shells.

On the patched script, I ran eight cases per shell (plain and bracketed checkouts, each with success, build exit 17, test exit 101, or missing Cargo). All 16 selected the expected directory and restored the caller. Build failure stopped before test. scripts/test-native-stderr.tests.ps1 also passed in both shells.

Windows 11 26100.9711, i7-13700, RTX 4060. Mock Cargo and temporary directories only. OpenAI Codex (GPT-6) ran the checks and prepared the patch.

<!-- greyfinch-sync:ivall/xcl:comment:7169739993 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/776#issuecomment-7169739993). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T17:36:15Z. --- On `c49a080076cce5fc83bb4ca94070a7de44998f61`, the caller got its original directory back, but Cargo sometimes ran in a different checkout. I put copies of the script under `checkout [A]\scripts`, created a sibling `checkout A\scripts`, and called the bracketed script from a third directory. The native Cargo stand-in logged its actual working directory: both build and test ran under `checkout A`. A successful run returned 0. This reproduced under Windows PowerShell 5.1.26100.9711 and PowerShell 7.6.9. [Fix and regression test](https://github.com/RavenCurseBurg/xcl/commit/de2547cea7512fda0d3a923d650220cc34ca0b28). Using `Push-Location -LiteralPath` keeps the checkout name literal. The regression checks the directory printed by native Cargo as well as the directory returned to the caller. It failed on this head and passed after the change in both shells. On the patched script, I ran eight cases per shell (plain and bracketed checkouts, each with success, build exit 17, test exit 101, or missing Cargo). All 16 selected the expected directory and restored the caller. Build failure stopped before test. `scripts/test-native-stderr.tests.ps1` also passed in both shells. Windows 11 26100.9711, i7-13700, RTX 4060. Mock Cargo and temporary directories only. OpenAI Codex (GPT-6) ran the checks and prepared the patch.
github-actions[bot] commented 2026-11-29 07:44:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:44:04Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252656767 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/776#issuecomment-7252656767). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:44:04Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 04:06:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:06:34Z.


Triage (#1607) – head c49a080

#2152 (duplicate group D145) wrapped scripts/test.ps1 in the same Push-Location / try / finally Pop-Location, but it is closed, so this is the only open PR for it. Main's test.ps1 still calls Set-Location.
No problems found in the diff. The new check in test-native-stderr.tests.ps1 covers the successful run only, not the early exit after a failed build. Main has since added a cargo bench step to test.ps1, so this needs a rebase.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300387763 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/776#issuecomment-7300387763). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:06:34Z. --- **Triage (#1607)** – head c49a080 #2152 (duplicate group D145) wrapped `scripts/test.ps1` in the same `Push-Location` / `try` / `finally Pop-Location`, but it is closed, so this is the only open PR for it. Main's `test.ps1` still calls `Set-Location`. No problems found in the diff. The new check in `test-native-stderr.tests.ps1` covers the successful run only, not the early `exit` after a failed build. Main has since added a `cargo bench` step to `test.ps1`, so this needs a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/776:upstream-pr/776'
git switch 'upstream-pr/776'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/776'
git switch 'upstream-pr/776'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/776'
git switch 'upstream-pr/776'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/776'
git switch 'main'
git merge --squash 'upstream-pr/776'
git switch 'main'
git merge --ff-only 'upstream-pr/776'
git switch 'main'
git merge 'upstream-pr/776'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!771
No description provided.