Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions scripts/fuzz/harness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,37 +211,38 @@ describe('run envelope', () => {
});

describe('artifact promotion', () => {
it('promotes a saved failing case into the corpus, once', () => {
it.each([false, true])('promotes a saved failing case once (existing corpus: %s)', (existing) => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'fuzz-promote-'));
const corpus = path.join(dir, 'regressions.json');
fs.writeFileSync(corpus, '[]\n');
const entry = { target: 'self-check-untyped-throw', input: 'promote me', note: 'existing' };
fs.writeFileSync(corpus, JSON.stringify(existing ? [entry] : []));
const artifact = path.join(dir, 'case.json');
fs.writeFileSync(
artifact,
JSON.stringify({
target: 'self-check-untyped-throw',
input: 'promote me',
kind: 'untyped-throw',
detail: 'seeded',
kind: 'empty-hint',
detail: 'artifact-only',
}),
);
const env = { AGENT_DEVICE_FUZZ_CORPUS: corpus };

const first = runHarness(['--input-file', artifact, '--append-corpus'], env);
expect(first.stdout).toContain('Case still violates the invariant');
expect(first.stdout).toContain('Appended 1 case(s)');
expect(first.status).toBe(1);
const { status, stdout } = runHarness(['--input-file', artifact, '--append-corpus'], env);
expect(stdout).toContain('Case still violates the invariant');
expect(stdout).toContain(
existing ? 'already contains every failing case' : 'Appended 1 case(s)',
);
expect(status).toBe(1);
expect(JSON.parse(fs.readFileSync(corpus, 'utf8'))).toEqual([
{
target: 'self-check-untyped-throw',
input: 'promote me',
note: expect.stringContaining('untyped-throw'),
...entry,
note: existing
? entry.note
: expect.stringContaining('untyped-throw: Error: self-check untyped throw'),
},
]);

const second = runHarness(['--input-file', artifact, '--append-corpus'], env);
expect(second.stdout).toContain('already contains every failing case');
expect(JSON.parse(fs.readFileSync(corpus, 'utf8'))).toHaveLength(1);
fs.rmSync(dir, { recursive: true, force: true });
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import { test } from 'vitest';
import { assertRpcOk } from '../provider-scenarios/assertions.ts';
import { PARALLEL_PROVIDER_SCENARIO_TIMEOUT_MS } from '../provider-scenarios/test-timeouts.ts';
import type { ProviderScenarioTranscript } from '../provider-scenarios/transcript.ts';
import { RUNNER_CONTINUE_NODES } from './fixtures.ts';
import {
Expand Down Expand Up @@ -60,23 +61,27 @@ const NOISY_DEFAULT_TAP_RESULT = {
jitterPx: 0,
};

test('interaction response shape: press @ref uses the canonical ref envelope', async () => {
await withIosContractDaemon(
[runnerSnapshotEntry(RUNNER_CONTINUE_NODES), runnerTapEntry(NOISY_DEFAULT_TAP_RESULT)],
async (daemon, transcript) => {
assertRpcOk(await daemon.callCommand('snapshot', [], { snapshotInteractiveOnly: true }));

const data = assertRpcOk(await daemon.callCommand('press', ['@e2']));
assertRunnerRequest(transcript, 'ios.runner.tap', tapRequest(200, 322));

assertCanonicalRef(data, {
message: 'Tapped @e2 (200, 322)',
x: 200,
y: 322,
});
},
);
});
test(
'interaction response shape: press @ref uses the canonical ref envelope',
async () => {
await withIosContractDaemon(
[runnerSnapshotEntry(RUNNER_CONTINUE_NODES), runnerTapEntry(NOISY_DEFAULT_TAP_RESULT)],
async (daemon, transcript) => {
assertRpcOk(await daemon.callCommand('snapshot', [], { snapshotInteractiveOnly: true }));

const data = assertRpcOk(await daemon.callCommand('press', ['@e2']));
assertRunnerRequest(transcript, 'ios.runner.tap', tapRequest(200, 322));

assertCanonicalRef(data, {
message: 'Tapped @e2 (200, 322)',
x: 200,
y: 322,
});
},
);
},
PARALLEL_PROVIDER_SCENARIO_TIMEOUT_MS,
);

test('interaction response shape: fill @ref uses the canonical ref envelope', async () => {
await withIosContractDaemon(
Expand Down
Loading