Skip to content

Apply code review fixes for pre-compare feature#10

Open
mavam wants to merge 6 commits intomainfrom
topic/add-pre-compare-code-review-fixes
Open

Apply code review fixes for pre-compare feature#10
mavam wants to merge 6 commits intomainfrom
topic/add-pre-compare-code-review-fixes

Conversation

@mavam
Copy link
Copy Markdown
Member

@mavam mavam commented Jan 30, 2026

Summary

This PR addresses code review feedback on the pre-compare feature for normalizing test output before comparison with baselines. All 159 tests pass with these changes.

Key changes:

  • Made apply_pre_compare a public API for use by runners
  • Fixed transform application consistency in DiffRunner and ShellRunner
  • Standardized terminology and improved variable naming throughout
  • Added 11 new tests (8 integration, 3 parameterized unit tests)
  • Included usage example and comprehensive changelog entry

Architecture

The pre-compare feature transforms both actual output and baseline expectations before comparison, allowing tests to handle non-deterministic output like unordered result sets. Transforms only affect comparison—baseline files remain unchanged on disk and --update continues to store original output.

Test Coverage

  • Integration tests verify pre-compare works across all runner types (shell, diff, custom Python)
  • Unit tests use parameterization to cover edge cases (empty input, no newlines, sorted content)
  • All existing tests continue to pass (159 total)

Related PRs

🤖 Generated with Claude Code

mavam and others added 5 commits January 30, 2026 21:56
This is now in the project-local settings file.
Apply consistent pattern for pre-compare key normalization to handle both
hyphenated and underscored variants, matching the approach used for
package_dirs. This improves robustness of config key canonicalization.

Resolves: #18
Update all code comments and docstrings to consistently use
"pre-compare transforms" (hyphenated) when referring to the feature
conceptually, while `pre_compare` (underscored) continues to be used
for the actual config key and code elements. This improves clarity
between user-facing feature names and internal implementation details.

Fixes: #16

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Transforms intentionally use a hardcoded dict rather than the plugin
architecture (runners/fixtures). They are core comparison utilities with no
current extensibility need. This decision is now documented with a migration
path if custom transforms become necessary in the future.

Resolves: ARC-6
Introduces a `pre-compare` frontmatter option that normalizes test output
before comparison, allowing tests with non-deterministic ordering to pass
reliably.

Usage in TQL/shell/Python tests:
  ---
  pre-compare: [sort]
  ---

Or in test.yaml for directory-level configuration:
  pre-compare: [sort]

The initial transform is `sort`, which sorts output lines lexicographically.
Transforms apply only at comparison time - baselines store original output.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mavam mavam force-pushed the topic/add-pre-compare-code-review-fixes branch from a6eac94 to bc34fbb Compare January 30, 2026 21:50
Mypy correctly identifies statements after _raise_config_error() calls
as unreachable since the function is typed as NoReturn. Removed these
dead statements.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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