Skip to content

Commit 7421ec8

Browse files
committed
fix(ios): keep the -Werror gate compiles out of test-case wall time
The bridge and fold-helper warning-gate tests ran their real clang -Werror compile inline in the test body, so the slow-test reporter charged the compile against the 2.5s unit budget and failed CI on a cold runner (the fold-helper compile alone took 12.36s). Move each compile into beforeAll, matching this file's other real-compile describe blocks, so the test body only asserts the captured result and the compile's wall time is not tracked as test-case duration.
1 parent 3d9cf09 commit 7421ec8

2 files changed

Lines changed: 55 additions & 48 deletions

File tree

‎packages/platform-apple/src/foldable/fold-helper-cache.test.ts‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'node:assert/strict';
22
import { readFile, rm, writeFile } from 'node:fs/promises';
33
import path from 'node:path';
4-
import { describe, test } from 'vitest';
4+
import { beforeAll, describe, test } from 'vitest';
55
import { runCmd } from '@agent-device/host-kit/command';
66
import { mkdtempForTest } from '../__tests__/tmp-dir.ts';
77
import { execKillTimeoutError } from '../snapshot-source/__tests__/exec-timeout-fixture.ts';
@@ -122,26 +122,30 @@ test('a compile exec killed at its budget reports the fold-helper build, not the
122122
// this is the gate that keeps a new Fold.m warning from passing CI unnoticed. It runs the
123123
// production argv (`buildFoldHelperCompileArgv`) against the real iphonesimulator SDK with
124124
// -Werror appended, so a warning fails here instead of nowhere.
125+
//
126+
// The compile runs in beforeAll, not in the test body: it is a real clang invocation (see the
127+
// unit slow-test budget in docs/agents/testing.md), and the snapshot-bridge sibling gate in
128+
// native-runtime.test.ts keeps its compile out of test-case wall time the same way.
125129
describe.skipIf(process.platform !== 'darwin')('fold helper warning gate', () => {
126-
test(
127-
'the production fold helper argv compiles clean under -Werror',
128-
async () => {
129-
const sourceRoot = path.resolve(import.meta.dirname, '../../../../apple/fold-helper');
130-
const binary = path.join(await mkdtempForTest('fold-helper-werror-'), 'fold-helper');
131-
const argv = buildFoldHelperCompileArgv({ sourceRoot, outputPath: binary });
132-
const wextraIndex = argv.indexOf('-Wextra');
133-
assert.ok(wextraIndex >= 0, 'the production argv carries -Wextra');
134-
const werrorArgv = [
135-
...argv.slice(0, wextraIndex + 1),
136-
'-Werror',
137-
...argv.slice(wextraIndex + 1),
138-
];
139-
const compiled = await runCmd('xcrun', werrorArgv, {
140-
allowFailure: true,
141-
timeoutMs: FOLD_HELPER_BUILD_TIMEOUT_MS,
142-
});
143-
assert.equal(compiled.exitCode, 0, compiled.stderr);
144-
},
145-
FOLD_HELPER_BUILD_TIMEOUT_MS + 30_000,
146-
);
130+
let compiled: { exitCode: number; stderr: string };
131+
beforeAll(async () => {
132+
const sourceRoot = path.resolve(import.meta.dirname, '../../../../apple/fold-helper');
133+
const binary = path.join(await mkdtempForTest('fold-helper-werror-'), 'fold-helper');
134+
const argv = buildFoldHelperCompileArgv({ sourceRoot, outputPath: binary });
135+
const wextraIndex = argv.indexOf('-Wextra');
136+
assert.ok(wextraIndex >= 0, 'the production argv carries -Wextra');
137+
const werrorArgv = [
138+
...argv.slice(0, wextraIndex + 1),
139+
'-Werror',
140+
...argv.slice(wextraIndex + 1),
141+
];
142+
compiled = await runCmd('xcrun', werrorArgv, {
143+
allowFailure: true,
144+
timeoutMs: FOLD_HELPER_BUILD_TIMEOUT_MS,
145+
});
146+
}, FOLD_HELPER_BUILD_TIMEOUT_MS + 30_000);
147+
148+
test('the production fold helper argv compiles clean under -Werror', () => {
149+
assert.equal(compiled.exitCode, 0, compiled.stderr);
150+
});
147151
});

‎packages/platform-apple/src/snapshot-source/native-runtime.test.ts‎

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -99,32 +99,35 @@ const recoveryFixture = JSON.parse(readFileSync(recoveryFixturePath, 'utf8')) as
9999
// production argv (`buildSnapshotBridgeCompileArgv`) against the real iphonesimulator SDK with
100100
// -Werror appended, so a warning fails here instead of nowhere.
101101
describe.skipIf(process.platform !== 'darwin')('bridge warning gate', () => {
102-
test(
103-
'the production bridge argv compiles clean under -Werror',
104-
async () => {
105-
const nativeRoot = path.resolve(import.meta.dirname, '../../../../apple/snapshot-bridge');
106-
const binary = path.join(await mkdtempForTest('snapshot-bridge-werror-'), 'snapshot-bridge');
107-
const architecture = process.arch === 'arm64' ? 'arm64' : 'x86_64';
108-
const argv = buildSnapshotBridgeCompileArgv({
109-
architecture,
110-
sourceRoot: nativeRoot,
111-
outputPath: binary,
112-
});
113-
const wextraIndex = argv.indexOf('-Wextra');
114-
assert.ok(wextraIndex >= 0, 'the production argv carries -Wextra');
115-
const werrorArgv = [
116-
...argv.slice(0, wextraIndex + 1),
117-
'-Werror',
118-
...argv.slice(wextraIndex + 1),
119-
];
120-
const compiled = await runCmd('xcrun', werrorArgv, {
121-
allowFailure: true,
122-
timeoutMs: BUILD_TIMEOUT_MS,
123-
});
124-
assert.equal(compiled.exitCode, 0, compiled.stderr);
125-
},
126-
COMPILE_HOOK_TIMEOUT_MS,
127-
);
102+
// The compile runs in beforeAll, not in the test body: it is a real clang invocation (see the
103+
// unit slow-test budget in docs/agents/testing.md), and this file's other describe blocks
104+
// already keep their compiles out of test-case wall time the same way.
105+
let compiled: { exitCode: number; stderr: string };
106+
beforeAll(async () => {
107+
const nativeRoot = path.resolve(import.meta.dirname, '../../../../apple/snapshot-bridge');
108+
const binary = path.join(await mkdtempForTest('snapshot-bridge-werror-'), 'snapshot-bridge');
109+
const architecture = process.arch === 'arm64' ? 'arm64' : 'x86_64';
110+
const argv = buildSnapshotBridgeCompileArgv({
111+
architecture,
112+
sourceRoot: nativeRoot,
113+
outputPath: binary,
114+
});
115+
const wextraIndex = argv.indexOf('-Wextra');
116+
assert.ok(wextraIndex >= 0, 'the production argv carries -Wextra');
117+
const werrorArgv = [
118+
...argv.slice(0, wextraIndex + 1),
119+
'-Werror',
120+
...argv.slice(wextraIndex + 1),
121+
];
122+
compiled = await runCmd('xcrun', werrorArgv, {
123+
allowFailure: true,
124+
timeoutMs: BUILD_TIMEOUT_MS,
125+
});
126+
}, COMPILE_HOOK_TIMEOUT_MS);
127+
128+
test('the production bridge argv compiles clean under -Werror', () => {
129+
assert.equal(compiled.exitCode, 0, compiled.stderr);
130+
});
128131
});
129132

130133
describe.skipIf(process.platform !== 'darwin')(

0 commit comments

Comments
 (0)