Files
codex/prs/bolinfest/study/PR-2648-study.md
2025-09-02 15:17:45 -07:00

3.2 KiB
Raw Blame History

DOs

  • End fixtures with a trailing newline: Prefer POSIX-style EOF newlines in JSON/text fixtures when they dont change semantics; it avoids brittle EOF-sensitive checks and matches common tooling expectations. (github.com)
*** Begin Patch
*** Update File: codex-rs/exec/tests/fixtures/sse_response_completed.json
@@
-]
+]
+
*** End Patch
  • Be explicit about reliability in PR descriptions: When refactoring tests, list the concrete changes that improve stability (e.g., shared Wiremock helper, deterministic response sequencing, consistent runtime settings) rather than saying “clean up.” (github.com)
## Summary
Refactor apply_patch E2E tests for clarity and stability.

## Why this is more reliable
- Use shared `run_e2e_exec_test` to sequence responses deterministically.
- Replace inline SSE with fixtures to reduce duplication.
- Align Tokio runtime settings across tests.
  • Normalize only whats incidental in assertions: If whitespace/newlines are not what youre testing, compare normalized strings to prevent accidental failures while still asserting the real behavior. (github.com)
let expected = include_str!("../fixtures/sse_response_completed.json");
let actual = std::fs::read_to_string(path)?;
assert_eq!(
  actual.trim_end_matches('\n'),
  expected.trim_end_matches('\n')
);
  • Address review feedback with focused commits: When a reviewer flags a safe formatting improvement (like EOF newlines), follow up with a small, targeted commit that does exactly that. (github.com)
git commit -m "tests(exec): add trailing newlines to SSE fixtures"

DONTs

  • Dont rely on “no newline at EOF” behavior: Tests shouldnt assume the last byte isnt a newline; theyll break once a formatter or editor adds it. (github.com)
// Brittle: fails if a trailing newline is later added.
let s = std::fs::read_to_string(".../sse_response_completed.json")?;
assert!(s.ends_with(']')); // Avoid EOF-structure assumptions
  • Dont ship vague PR rationales: “Clean up tests” without stating the specific reliability benefits forces reviewers to guess what changed and why its safer. Be concrete. (github.com)
# Bad
Refactor tests. Clean up and make more solid.

# Good
Extract Wiremock sequencing helper; move SSE to fixtures; align runtime settings for determinism.
  • Dont conflate formatting with semantics in test expectations: If the behavior under test is “final file content is X,” dont make the assertion fail on incidental whitespace differences unless thats intentional. (github.com)
// Prefer checking the meaningful content:
assert_eq!(actual.trim_end_matches('\n'), "Final text");