Scripts: restore caller directory after tests #776
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!776
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-776"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Bababoey7696 on GitHub · 2026-11-24 05:07 UTC · original
Bababoey7696:fix/test-location-pr→main· +16 −2 · 2 files · 1 commits · openscripts/test.ps1changes the current working directory to the repository root but does not restore the caller's original directory after execution.This PR uses
Push-Locationandtry/finallywithPop-Locationto 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
9f9770f.Regression run
Not tested
AI use
@milas6669 on GitHub · 2026-11-24 05:14 UTC · original
Test report on
c49a0805(PR head; basemain64b3f35,mainis nowd208e14, which does not touchscripts/).Tested
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/test-native-stderr.tests.ps1on this head: exit 0.test.ps1change: with this PR's test script andtest.ps1taken frommain, the run exits 1 withtest.ps1 changed the caller working directory.Not tested
pwsh(PowerShell 7)scripts/test.ps1run (it builds and runs the whole suite; the GPU was busy)cargo test: the PR changes only scriptsAI use
@DavidM1911 on GitHub · 2026-11-25 11:08 UTC · original
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 on GitHub · 2026-11-25 17:36 UTC · original · edited 2026-11-25 17:42 UTC
On
c49a080076cce5fc83bb4ca94070a7de44998f61, the caller got its original directory back, but Cargo sometimes ran in a different checkout. I put copies of the script undercheckout [A]\scripts, created a siblingcheckout 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 undercheckout 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 -LiteralPathkeeps 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.ps1also 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.