Skip to content

Commit d014bf6

Browse files
authored
test: make CLI goldens timezone- and CRLF-independent, gate scale test to Unix (#509)
Follow-up to #508. With release builds and `--no-fail-fast`, the Windows run showed exactly two remaining failures out of the full suite. ## cli_simplify goldens The fixture commits with `GIT_AUTHOR_DATE=@1700000000` and no offset, so git stamps the machine's local timezone into each commit and the SHAs change with it. The goldens were generated at +0530, so the test only passed on machines in that zone. It failed on the UTC Windows runner and on a US-timezone Mac. The fixture now pins `+0530`, which matches the existing goldens without regenerating them. Golden files are also read with CRLF normalized, since a Windows checkout converts them. Verified locally: 15/15 pass with TZ unset (America/Los_Angeles), TZ=UTC and TZ=America/New_York. ## arch_diff_scale The test exists to hold arch-diff under 1 GB on a 50k-file repo, and it reads peak memory with `ps`, which Windows does not have (the run reported `peak 0 MB`). Generating the 50k files also took 465s on the Windows filesystem. Gated to `#[cfg(unix)]`, matching how the memory-budget test in arch_diff_review was gated.
1 parent dc2cc4d commit d014bf6

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to sem are documented in this file.
77
### Changed
88

99
- **Windows CI runs the test suite against release builds and reports every failure.** The wall-time and scale tests are calibrated for optimized binaries, so the debug build on the Windows runner overran them and failed main on four pushes in a row, each time on a different test because `cargo test` stopped at the first failing binary. Tests now build in release on the same target as the build step, and `--no-fail-fast` shows all failures at once.
10+
- **The CLI golden tests pass in every timezone and on Windows.** The fixture committed with a bare Unix timestamp, so git stamped the machine's local timezone into each commit and the SHAs in the goldens only matched machines set to +0530; the fixture now pins that offset. The comparison also ignores the CRLF line endings a Windows checkout gives the golden files. The 50k-file memory-bound test runs only on Unix, since it reads peak memory with `ps`, which Windows does not have.
1011

1112
- TS/JS import edits preserve exact UTF-8 byte ranges and surrounding same-line code. Duplicate detection uses parsed declarations, and unavailable/invalid parsing refuses edits without changing the file rather than falling back to text matching.
1213

‎crates/sem-cli/tests/arch_diff_scale.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ fn run_bounded(dir: &Path, max_mb: u64, max_secs: u64) -> Result<(u64, f64, Stri
120120
}
121121
}
122122

123+
// Peak memory is read with ps(1), which Windows lacks, so the bound this test
124+
// exists to hold cannot be measured there.
125+
#[cfg(unix)]
123126
#[test]
124127
fn a_tiny_change_in_a_50k_file_repo_stays_under_a_gigabyte() {
125128
let tmp = tempfile::tempdir().unwrap();

‎crates/sem-cli/tests/cli_simplify.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ fn fixture() -> TempDir {
5353
)
5454
.unwrap();
5555
git(r, &["add", "-A"], None);
56-
git(r, &["commit", "-qm", "init"], Some("@1700000000"));
56+
git(r, &["commit", "-qm", "init"], Some("@1700000000 +0530"));
5757
fs::write(
5858
r.join("src/config.py"),
5959
"def parse_config(text):\n pairs = [line.split(\"=\", 1) for line in text.splitlines() if line]\n return dict(pairs)\n\n\ndef load(path):\n with open(path) as f:\n return parse_config(f.read())\n\n\ndef main():\n print(load(\"app.cfg\"))\n",
6060
)
6161
.unwrap();
6262
git(r, &["add", "-A"], None);
63-
git(r, &["commit", "-qm", "change"], Some("@1700000100"));
63+
git(r, &["commit", "-qm", "change"], Some("@1700000100 +0530"));
6464
dir
6565
}
6666

@@ -389,8 +389,10 @@ fn goldens_old_invocations_and_their_new_spellings() {
389389
fs::write(&path, normalize(&out.stdout, repo.path())).unwrap();
390390
continue;
391391
}
392+
// A Windows checkout may convert the goldens to CRLF; sem prints LF.
392393
let golden = fs::read_to_string(&path)
393-
.unwrap_or_else(|_| panic!("missing golden {}", path.display()));
394+
.unwrap_or_else(|_| panic!("missing golden {}", path.display()))
395+
.replace("\r\n", "\n");
394396
for argv in std::iter::once(*old).chain(news.iter().copied()) {
395397
let out = sem(repo.path(), cache.path(), argv);
396398
let got = normalize(&out.stdout, repo.path());
@@ -795,7 +797,7 @@ fn impact_diff_tests_in_a_js_workspace_is_the_module_graph_selection() {
795797
)
796798
.unwrap();
797799
git(r, &["add", "-A"], None);
798-
git(r, &["commit", "-qm", "init"], Some("@1700000000"));
800+
git(r, &["commit", "-qm", "init"], Some("@1700000000 +0530"));
799801
fs::write(
800802
r.join("src/math.ts"),
801803
"export function add(a: number, b: number) { return b + a; }\n",

0 commit comments

Comments
 (0)