petri: remove stale test markers before running test#3785
Open
jstarks wants to merge 1 commit into
Open
Conversation
If a test results directory is reused (e.g., when running tests interactively), its test markers (such as petri.passed) can be stale and confuse tools, people, and agents. Clear them before running the test.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents confusion from stale Petri test-result marker files (e.g. petri.passed) when a test output directory is reused across interactive runs by clearing those markers before executing a test.
Changes:
- Added a helper to remove known Petri result marker files from a test output directory.
- Switched marker filenames in result logging to shared constants and added a unit test for marker cleanup.
- Invoked marker cleanup at the start of test execution (after resolving artifacts, before tracing init).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
petri/src/tracing.rs |
Introduces marker filename constants + clear_test_result_markers, updates result logging to use constants, and adds a unit test for cleanup. |
petri/src/test.rs |
Calls marker cleanup on the test output directory before initializing tracing and running the test. |
| const TEST_RESULT_MARKERS: &[&str] = &[PETRI_PASSED, PETRI_FAILED_UNSTABLE, PETRI_FAILED]; | ||
|
|
||
| /// Clears stale Petri test result markers from a test output directory. | ||
| pub fn clear_test_result_markers(root_path: &Path) -> anyhow::Result<()> { |
Comment on lines
+35
to
+42
| for &marker in TEST_RESULT_MARKERS { | ||
| let path = root_path.join(marker); | ||
| match fs_err::remove_file(&path) { | ||
| Ok(()) => {} | ||
| Err(err) if err.kind() == std::io::ErrorKind::NotFound => {} | ||
| Err(err) => return Err(err.into()), | ||
| } | ||
| } |
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.
If a test results directory is reused (e.g., when running tests
interactively), its test markers (such as petri.passed) can be stale
and confuse tools, people, and agents. Clear them before running the
test.