Repository navigation
test: give each test its own temporary directory - #154
Merged
Merged
Conversation
Tests in shell_integration.rs and curl_integration.rs used fixed host paths such as $TMPDIR/lsh_config_test. When two test runs share a host, they write, read, and delete the same directories, so tests fail at random. The grep binary fixture also deleted its directory before it started. Setup and cleanup errors were ignored. Add a small TestDir helper to each file. It creates a new directory named with the test name, the process ID, and a counter, and it removes the directory on drop. A failure to create or remove the directory now fails the test. The dangling-symlink test now binds a subdirectory, so its escape target stays inside the test directory and outside the mount.
zastrowm
approved these changes
Oct 16, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Twenty-three tests in
tests/shell_integration.rsandtests/curl_integration.rsuse fixed host paths such as$TMPDIR/lsh_config_test. The grep binary fixture, which 47 tests use, also deletes its directory before it starts. When two test runs share a host, they write, read, and delete the same directories, and random tests fail. Onmain(ef2fbca), 4 of 6 runs failed when two full suites ran at the same time. A different set of tests failed each time, for exampleconfig_file_with_binds_and_creds,bind_direct_write_back,curl_allowed_url_via_toml_config, and severalgrep_*tests.This PR adds a small
TestDirhelper to each of the two files. It creates a new directory named with the test name, the process ID, and a counter, and it removes the directory on drop. A failure to create or remove the directory now fails the test. Before, the tests ignored these errors. The dangling-symlink test now binds a subdirectory, so its escape target stays inside the test directory and outside the mount.No production code changes. No dependency is added.
Related Issues
None.
Documentation PR
Not applicable.
Type of Change
Other: test reliability.
Testing
cargo test --workspace --all-targets: 1805 passed, 0 failed. This is the same count asmain.Collision: three rounds of two full suites at the same time, each with its own
CARGO_TARGET_DIR.main: 4 of 6 runs failed (7, 3, 1, and 2 failing tests).bind_direct_write_backfailed because the host file was still empty after its fixed 50 ms sleep. Its directory is unique, so this is a separate timing problem. With the sleep set to 2 s for the experiment only, 6 of 6 runs passed. This PR does not change that test's timing.cargo clippy --workspace --all-targets: 14 warnings, the same asmain.cargo fmt --checkis clean.I ran the relevant test suites for the bindings I touched (
cargo test --workspace --all-targets,pytest tests/python,npm test)If I touched Rust, I ran
cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.