Skip to content

Commit faf6ee6

Browse files
committed
test(apple-runner): share the runner-requests fixture check with root tests
Export the fixture reader as @agent-device/platform-apple/runner/requests-fixtures so root producers pin requests through the same commandId normalization, and derive the request-literal guard's sources from the producers the fixture declares. Refs #2881
1 parent bbdf442 commit faf6ee6

11 files changed

Lines changed: 41 additions & 64 deletions

‎.oxfmtrc.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"**/*.md",
1212
"scripts/maestro-conformance/corpus/**",
1313
"fallow-baselines/**",
14+
// One entry per line, so each pinned runner request changes as one reviewable diff line.
1415
"contracts/fixtures/runner-requests.json"
1516
]
1617
}

‎packages/platform-apple/package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
"types": "./src/runner-operations-facade.ts",
6565
"default": "./src/runner-operations-facade.ts"
6666
},
67+
"./runner/requests-fixtures": {
68+
"types": "./src/runner/runner-requests.fixtures.ts",
69+
"default": "./src/runner/runner-requests.fixtures.ts"
70+
},
6771
"./runner/test-host": {
6872
"types": "./src/runner/test-host.ts",
6973
"default": "./src/runner/test-host.ts"

‎packages/platform-apple/src/__tests__/runner-requests.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
MACOS_DEVICE,
1717
TVOS_SIMULATOR,
1818
} from '../runner/__tests__/device-fixtures.ts';
19-
import { assertProducedRunnerRequests } from '../runner/__tests__/runner-requests-fixture.ts';
19+
import { assertProducedRunnerRequests } from '../runner/runner-requests.fixtures.ts';
2020
import {
2121
recordingRunnerProvider,
2222
singlePointerPanPlan,

‎packages/platform-apple/src/runner/__tests__/runner-contract.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import { disposeRunnerSession } from '../runner-disposal.ts';
1010
import { buildRunnerLease, writeRunnerLease } from '../runner-lease.ts';
1111
import { executeRunnerCommand, prepareLocalIosRunner } from '../runner-lifecycle.ts';
1212
import { withAppleRunnerProvider } from '../runner-provider.ts';
13-
import { runApplePressSeries } from '../runner-sequence.ts';
14-
import { appleRunnerTestHost } from '../test-host.ts';
15-
import { IOS_SIMULATOR } from './device-fixtures.ts';
16-
import { startFakeRunnerServer, type FakeRunnerServer } from './fake-runner-server.ts';
17-
import { makeRunnerSession } from './runner-session-fixtures.ts';
1813
import {
1914
assertProducedRunnerRequests,
2015
compareRunnerRequestNames,
2116
readRunnerRequestFixture,
2217
REPO_ROOT,
23-
} from './runner-requests-fixture.ts';
18+
} from '../runner-requests.fixtures.ts';
19+
import { runApplePressSeries } from '../runner-sequence.ts';
20+
import { appleRunnerTestHost } from '../test-host.ts';
21+
import { IOS_SIMULATOR } from './device-fixtures.ts';
22+
import { startFakeRunnerServer, type FakeRunnerServer } from './fake-runner-server.ts';
23+
import { makeRunnerSession } from './runner-session-fixtures.ts';
2424
import { mkdtempForTestSync } from './tmp-dir.ts';
2525

2626
const runnerState = vi.hoisted(() => ({ ensureRunnerSession: vi.fn(), derivedPath: '' }));
@@ -156,10 +156,10 @@ const DIRECT_SEND = new RegExp(
156156
);
157157

158158
test('runner request drives send only requests production builds', () => {
159+
const producers = readRunnerRequestFixture().map((entry) => path.join(REPO_ROOT, entry.producer));
159160
const sources = [
160-
import.meta.filename,
161-
path.join(import.meta.dirname, 'runner-requests-fixture.ts'),
162-
path.join(import.meta.dirname, '../../__tests__/runner-requests.test.ts'),
161+
...new Set(producers),
162+
path.join(import.meta.dirname, '../runner-requests.fixtures.ts'),
163163
path.join(import.meta.dirname, '../../__tests__/recording-runner-provider.ts'),
164164
];
165165
const offending = sources.flatMap((file) =>

packages/platform-apple/src/runner/__tests__/runner-requests-fixture.ts renamed to packages/platform-apple/src/runner/runner-requests.fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type RunnerRequestEntry = {
99
request: Record<string, unknown>;
1010
};
1111

12-
export const REPO_ROOT = fileURLToPath(new URL('../../../../../', import.meta.url));
12+
export const REPO_ROOT = fileURLToPath(new URL('../../../../', import.meta.url));
1313

1414
const COMMAND_ID_KEYS = ['commandId', 'statusCommandId'];
1515

‎scripts/layering/package-boundaries.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ test('the real tree parses, declares, and passes R11', () => {
541541
'@agent-device/platform-apple/runner',
542542
'@agent-device/platform-apple/runner-owner',
543543
'@agent-device/platform-apple/runner/operations',
544+
// Test-only entry: the runner-requests.json check package and root tests share.
545+
'@agent-device/platform-apple/runner/requests-fixtures',
544546
'@agent-device/platform-apple/runner/test-host',
545547
'@agent-device/platform-apple/session-observation',
546548
'@agent-device/platform-apple/simctl',

‎scripts/layering/platform-package-policy.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function declarations(): PlatformPackageDeclaration[] {
3838
'@agent-device/platform-apple/runner',
3939
'@agent-device/platform-apple/runner/test-host',
4040
'@agent-device/platform-apple/runner/operations',
41+
'@agent-device/platform-apple/runner/requests-fixtures',
4142
'@agent-device/platform-apple/runner-owner',
4243
'@agent-device/platform-apple/session-observation',
4344
'@agent-device/platform-apple/simctl',

‎scripts/layering/platform-package-policy.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const MECHANICS_FACET_SUBPATHS: Readonly<Partial<Record<PlatformFamily, readonly
8686
'@agent-device/platform-apple/physical-device',
8787
'@agent-device/platform-apple/runner-owner',
8888
'@agent-device/platform-apple/runner/operations',
89+
'@agent-device/platform-apple/runner/requests-fixtures',
8990
'@agent-device/platform-apple/session-observation',
9091
'@agent-device/platform-apple/snapshot-source',
9192
'@agent-device/platform-apple/simctl',

‎src/__tests__/test-utils/runner-requests.ts‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎src/platform-runtime-screen-recording-apple-runner-host.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { expect, test, vi } from 'vitest';
2+
import { assertProducedRunnerRequests } from '@agent-device/platform-apple/runner/requests-fixtures';
23
import {
34
captureAppleClockAnchor,
45
runAppleRecordingRunner,
56
} from './platform-runtime-screen-recording-apple-runner-host.ts';
67
import { withAppleRunnerScreenRecordingTransport } from './platform-runtime-screen-recording-apple-runner-transport.ts';
78
import { withAppleSimulatorScreenRecordingTransport } from './platform-runtime-screen-recording-apple-transport.ts';
8-
import { expectProducedRunnerRequests } from './__tests__/test-utils/runner-requests.ts';
99

1010
const runnerClient = vi.hoisted(() => ({ run: vi.fn() }));
1111
vi.mock('@agent-device/platform-apple/runner/operations', () => ({
@@ -60,7 +60,7 @@ test('the clock anchor request matches its runner-requests.json entry', async ()
6060
runnerClient.run.mockReset();
6161
runnerClient.run.mockResolvedValue({ currentUptimeMs: 1_000 });
6262
await captureAppleClockAnchor(simulator, 'com.example.app');
63-
expectProducedRunnerRequests(import.meta.filename, [
63+
assertProducedRunnerRequests(import.meta.filename, [
6464
['ios-simulator.recording-clock-anchor.snapshot', runnerClient.run.mock.calls[0]?.[1]],
6565
]);
6666
});

0 commit comments

Comments
 (0)