fix(ci): resolve cross-platform test failures

- Sanity check script (check-codex-global-state.sh) now falls back to
  grep -E when ripgrep is not available, fixing the codex-hooks sync
  test on all CI platforms. Patterns converted to POSIX ERE for
  portability.
- Unicode safety test accepts both / and \ path separators so the
  executable-file assertion passes on Windows.
- Gacha test sets PYTHONUTF8=1 so Python uses UTF-8 stdout encoding on
  Windows instead of cp1252, preventing UnicodeEncodeError on box-drawing
  characters.
- Quoted-hook-path test skipped on Windows where NTFS disallows
  double-quote characters in filenames.
This commit is contained in:
Affaan Mustafa
2026-03-31 01:38:00 -04:00
parent e68233cd5d
commit d728312b58
4 changed files with 25 additions and 12 deletions

View File

@@ -89,7 +89,7 @@ if (
const result = runCheck(root, ['--write']);
assert.notStrictEqual(result.status, 0, result.stdout + result.stderr);
assert.match(result.stderr, /scripts\/sample\.js:1:23 emoji U\+1F680/);
assert.match(result.stderr, /scripts[/\\]sample\.js:1:23 emoji U\+1F680/);
assert.strictEqual(fs.readFileSync(scriptFile, 'utf8'), original);
})
)

View File

@@ -66,7 +66,11 @@ function makeHermeticCodexEnv(homeDir, codexDir, extraEnv = {}) {
let passed = 0;
let failed = 0;
if (
// Windows NTFS does not allow double-quote characters in file paths,
// so the quoted-path shell-injection test is only meaningful on Unix.
if (os.platform() === 'win32') {
console.log(' - install-global-git-hooks.sh quoted paths (skipped on Windows)');
} else if (
test('install-global-git-hooks.sh handles quoted hook paths without shell injection', () => {
const homeDir = createTempDir('codex-hooks-home-');
const weirdHooksDir = path.join(homeDir, 'git-hooks "quoted"');

View File

@@ -30,6 +30,7 @@ function runGacha(pythonBin, arg) {
return spawnSync(pythonBin, [SCRIPT, arg], {
encoding: 'utf8',
maxBuffer: 10 * 1024 * 1024,
env: { ...process.env, PYTHONUTF8: '1' },
});
}