fix: silently skip duplicate TestFiles.add() instead of raising#2133
Merged
KRRT7 merged 5 commits intocf-fix-concurrency-measurementfrom May 7, 2026
Merged
fix: silently skip duplicate TestFiles.add() instead of raising#2133KRRT7 merged 5 commits intocf-fix-concurrency-measurementfrom
KRRT7 merged 5 commits intocf-fix-concurrency-measurementfrom
Conversation
5 tasks
The previous implementation used `if test_file not in self.test_files` which performs O(n) equality comparison across all TestFile objects. Replace with a `_seen_paths` set keyed on `instrumented_behavior_file_path` for O(1) deduplication lookups.
Java test discovery adds the same instrumented_behavior_file_path with different fields. The old Pydantic __eq__ treated them as different; the set-based dedup correctly identifies them as the same test file. Since get_test_type_by_instrumented_file_path() returns on first path match anyway, duplicates by path are dead weight. Silent skip (first write wins) is both correct and O(1).
When the test subprocess exits non-zero and produces no JUnit XML, log the return code and stdout/stderr at WARNING level so the root cause is visible in CI logs. Previously this was a generic "No test results found" message that made Windows CI flakes impossible to diagnose. Also fixes pre-existing mypy strict errors in parse_xml.py: - Add return type to _parse_func - Type CompletedProcess[str] (subprocess uses text=True) - Parameterize generic types (tuple, re.Match) - Remove dead .decode() branches (stdout is already str)
6734877 to
9459c5a
Compare
3 tasks
Collaborator
Author
|
Superseded by #2144 (same commit, rebased onto the linear stack). |
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.
Parent PR
#2132 — perf: targeted performance improvements for E2E pipeline hot path
Summary
Changes
TestFiles.add()duplicate handling from raisingValueErrorto silently skipping (first-write-wins). Fixes Java e2e test failures where test discovery adds the sameinstrumented_behavior_file_pathwith different metadata fields.Problem
The set-based dedup introduced in #2130 correctly identifies duplicate test files by path. However, it raised
ValueErroron duplicates — which breaks Java test discovery where the same path appears multiple times with varying metadata.Since
get_test_type_by_instrumented_file_path()returns on first path match anyway, duplicates by path are dead weight. Raising is both incorrect (existing callers never expected it) and unnecessary.Changes
codeflash/models/models.py: RemoveValueErrorraise inadd(), silently return when path already in_seen_pathstests/test_test_files_add.py: Update test fromtest_add_duplicate_raises→test_add_duplicate_is_noopKey design decisions
TestFileadded for a given path is kept; subsequent adds with the same path are silently discarded. This matches the existing lookup semantics.Test plan
test_add_duplicate_is_noopverifies silent skip on duplicate pathtest_add_unique_test_filepassestest_add_many_files_performancepasses (100 files, O(1) per add)