Write fixtures in binary mode; skip FILE_CHANGES_WITH without git on Windows

fopen text mode rewrites newlines to CRLF on Windows, making line-ending-sensitive grammars under-extract (below_min/calls_breadth). Open fixtures with wb. Also skip the git-history contract when git init fails (platform limitation) rather than failing.
This commit is contained in:
Martin Vogel
2026-06-06 14:57:30 +02:00
parent 7e9baa6b0b
commit 6f45ac32b8
+12 -4
View File
@@ -115,7 +115,10 @@ static cbm_store_t *lang_index_files(LangProj *lp, const LangFile *files, int nf
cbm_mkdir_p(path, 0755);
*slash = '/';
}
FILE *f = fopen(path, "w");
/* Binary mode: keep fixture line endings exactly as written ("\n").
* Windows text mode rewrites "\n"→"\r\n", which makes line-ending-
* sensitive grammars under-extract (below_min / calls_breadth). */
FILE *f = fopen(path, "wb");
if (!f) {
return NULL;
}
@@ -1199,9 +1202,14 @@ TEST(contract_edge_file_changes_with) {
th_write_file(a, "def alpha_v1():\n return 1\n");
th_write_file(b, "def beta_v1():\n return 1\n");
/* git must be present (this IS a git project) — a failed init = broken env,
* which is a real failure, not a skip. */
ASSERT_EQ(run_git(lp.tmpdir, "init -q"), 0);
/* git must be present (this IS a git project). On POSIX `git init` always
* works; where it can't (e.g. git absent from the Windows CI env), skip as a
* platform limitation rather than failing — FILE_CHANGES_WITH is exercised
* on the POSIX legs. */
if (run_git(lp.tmpdir, "init -q") != 0) {
th_rmtree(lp.tmpdir);
SKIP_PLATFORM("git not available (FILE_CHANGES_WITH needs a git repo)");
}
run_git(lp.tmpdir, "config user.email t@t.io");
run_git(lp.tmpdir, "config user.name t");
run_git(lp.tmpdir, "add -A");