Skip to content

petri: remove stale test markers before running test#3785

Open
jstarks wants to merge 1 commit into
microsoft:mainfrom
jstarks:clear_markers
Open

petri: remove stale test markers before running test#3785
jstarks wants to merge 1 commit into
microsoft:mainfrom
jstarks:clear_markers

Conversation

@jstarks

@jstarks jstarks commented Jun 19, 2026

Copy link
Copy Markdown
Member

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.

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.
@jstarks jstarks requested a review from a team as a code owner June 19, 2026 23:43
Copilot AI review requested due to automatic review settings June 19, 2026 23:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread petri/src/tracing.rs
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 thread petri/src/tracing.rs
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()),
}
}
@github-actions

Copy link
Copy Markdown

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.

2 participants