Skip to content

Restore the working directory after each sync test - #1271

Merged
ericmj merged 1 commit into
mainfrom
restore-cwd-after-tests
Oct 12, 2026
Merged

ericmj merged 1 commit into
mainfrom
restore-cwd-after-tests

Conversation

@ericmj

@ericmj ericmj commented Oct 12, 2026

Copy link
Copy Markdown
Member

In https://github.com/hexpm/hex/actions/runs/38185790314 one audit test timed out and 290 tests failed after it. ExUnit kills a test that times out, so the File.cd!/2 in in_tmp/2 never changes back and the VM's working directory stays in the test's tmp directory. in_tmp/1 names the directory after the calling function, and every audit test calls it through with_test_package/3, so they all share one directory. The next audit test deletes the working directory, and every later File.cwd!/0 fails. When I reproduced it locally, that crashed Mix.ProjectStack, and the rest of the suite failed with ArgumentError because the Mix.State ETS table was gone.

This restores the working directory from an on_exit callback in the sync test setup, which runs even when the test is killed. With one audit test made to hang (--seed 0, 15 s timeout), main fails 116 of 837 tests and this branch fails only the hung one.

Going by that run's log, the timeout itself looks like the Mix.Sync.Lock deadlock fixed on Elixir main in elixir-lang/elixir#15765, which isn't in a release yet.

ExUnit kills a test that times out, so the File.cd!/2 in in_tmp/2 never
changes back and the VM's working directory stays in the test's tmp
directory. All audit tests share one in_tmp directory, so the next one
deleted the working directory, and every later File.cwd!/0 failed. One
timed out audit test failed 290 tests in
https://github.com/hexpm/hex/actions/runs/38185790314.

Restore the working directory from an on_exit callback, which runs even
when the test is killed.
@ericmj
ericmj merged commit 97a043b into main Oct 12, 2026
22 checks passed
@ericmj
ericmj deleted the restore-cwd-after-tests branch October 12, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant