Skip to content

Commit 396d727

Browse files
fix(test): rebase onto v0.2.0 and harden empty-code --out cleanup
- Resolve rebase conflicts: keep atomic temp-file --out writes from main while rejecting empty inline code with VALIDATION_ERROR (exit 5) - abortOutputFile: wait for stream close before unlinking tmpPath - BOM test: use .py code-file (assertPythonCodeFile from v0.2.0) - CI: build before test + fileParallelism false (dist/ race flake)
1 parent 9fbb29e commit 396d727

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
cache: 'npm'
6161

6262
- run: npm ci
63+
- run: npm run build
6364
- run: npm test
6465
env:
6566
CI: true

src/commands/test.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ describe('runCodePut', () => {
17081708
it('strips a UTF-8 BOM from --code-file before uploading (Windows PowerShell 5.1 default)', async () => {
17091709
const { credentialsPath } = makeCreds();
17101710
const dir = mkdtempSync(join(tmpdir(), 'cli-p4-bom-'));
1711-
const codeFile = join(dir, 'updated.spec.ts');
1711+
const codeFile = join(dir, 'updated.py');
17121712
writeFileSync(codeFile, '\uFEFF' + 'updated body', 'utf8');
17131713
let seenBody: unknown;
17141714
const fetchImpl = makeFetch((_url, init) => {

src/commands/test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8011,7 +8011,14 @@ async function closeOutputFile(sink: FileSink, commit: boolean): Promise<void> {
80118011

80128012
/** Tear down an opened `--out` sink without leaving a zero-byte artifact. */
80138013
async function abortOutputFile(sink: FileSink): Promise<void> {
8014-
sink.stream.destroy();
8014+
await new Promise<void>(resolve => {
8015+
if (sink.stream.destroyed) {
8016+
resolve();
8017+
return;
8018+
}
8019+
sink.stream.once('close', () => resolve());
8020+
sink.stream.destroy();
8021+
});
80158022
await unlink(sink.tmpPath).catch(() => undefined);
80168023
}
80178024

vitest.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ export default defineConfig({
44
test: {
55
include: ['src/**/*.{test,spec}.ts', 'test/**/*.{test,spec}.ts'],
66
exclude: ['test/dev-e2e/**', 'test/e2e/**', 'node_modules/**', 'dist/**'],
7+
// Subprocess/snapshot suites each run `npm run build` in beforeAll; parallel
8+
// file workers can race on dist/ and produce a stale binary (exit 1 vs 5 flakes).
9+
fileParallelism: false,
710
coverage: {
811
provider: 'v8',
912
reporter: ['text', 'text-summary', 'json-summary', 'html'],

0 commit comments

Comments
 (0)