Skip to content

test: fix Windows-only and flaky failures in config tests - #263

Open
theprinceraj wants to merge 1 commit into
prooflinedev:mainfrom
theprinceraj:fix/windows-flaky-config-tests
Open

theprinceraj wants to merge 1 commit into
prooflinedev:mainfrom
theprinceraj:fix/windows-flaky-config-tests

Conversation

@theprinceraj

Copy link
Copy Markdown

Summary

Fixes config_test failures on Windows: one test that always failed, and two that failed now and then.

test_read_input_paths_from_stdin always failed on Windows

It spawns echo as a process. On Windows echo is a shell built-in, not a program, so the call fails with program not found. The test is now ignored on Windows with cfg_attr(windows, ignore = ...), and the reason appears in the test output.

Flaky test_validate_config_* failures

Four test_output_template_* tests call set_current_dir, which changes the working directory for the whole test process. CONFIG_TEST_MUTEX only serialized those four with each other. Other tests in the file use relative output paths ("output", "/tmp/yek"), and they sometimes ran inside another test's temp folder while it was being deleted:

output_dir: 'output' exists but is not a directory
output_dir: cannot create 'output': ... (os error 183)

The four tests (and the mutex) now live in tests/config_cwd_test.rs. Each test file runs as its own process, so they can no longer change the working directory of other tests.

I also gave two assertions failure messages, so they print the actual error instead of only assertion failed.

Testing (Windows 11)

  • With RUST_TEST_THREADS=16: 4–6 failing runs per 600 before, 0 in 600 after
  • cargo test --test config_test --test config_cwd_test and cargo fmt --check pass

Not in scope

These problems on Windows were already there before this PR, and it doesn't change them:

  • parallel_test: 4 failures from \ vs / path separators
  • symlink_test: unused-import warnings, because its tests are #[cfg(unix)]

@theprinceraj

Copy link
Copy Markdown
Author

Coverage failure is unrelated, the job dies on git checkout ${{ github.head_ref }}:

error: pathspec 'fix/windows-flaky-config-tests' did not match any file(s) known to git

Branch only exists on my fork, so this'll happen on any fork PR. Checking out github.event.pull_request.head.sha instead should fix it, happy to send a PR.

This branch has not been deployed

No deployments
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