Files
pipelines/app/test/features/runs/domain/check_step_output_test.dart
T
alan 87016ef5dc Engine: check stages, harness-agnostic delivery, read-only enforcement, complete captures
- New `type=check` stage: the server runs a `commands` block (sh -c, per
  command_timeout, workspace env) and routes on pass/fail; per-command status,
  exit code, duration and bounded output are recorded and the failing output is
  the handoff. With delivery=true it is the landing gate (commit leftovers,
  merge moved main, checks in a fresh candidate worktree, fast-forward main).
  Parser/registry, lint (silent guards), format docs, CLI inspect, app graph and
  run detail rendering.
- delivery=true is accepted on every harness (and on check stages).
- permissions.shell on claude stages maps to Bash(cmd) / Bash(prefix:*) rules
  instead of a bare Bash allow; stages without edit that change the workspace
  fail the visit with the changed files listed (allow_workspace_changes=true
  opts out; artifacts, public and harness state dirs are ignored).
- File-change capture: symlinks compared by target, untouched protected files no
  longer make captures partial, untracked caches/dependency/build output left
  out, lockfiles listed without patch, huge files compared by metadata, raised
  patch/line limits. Outcome repair follow-ups are logged and counted on the
  step (control.outcome_repairs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 12:52:16 +00:00

78 lines
2.6 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/domain/check_step_output.dart';
void main() {
test('a check output reads each command result', () {
final output = checkStepOutput({
'markdown': '# outcome\n\nfail\n',
'summary': '1 of 2 checks failed: go test ./...',
'delivery': true,
'checks': [
{
'command': 'go vet ./...',
'status': 'passed',
'exit_code': 0,
'duration_ms': 2100,
'output': '',
'truncated': false,
},
{
'command': 'go test ./...',
'status': 'failed',
'exit_code': 1,
'duration_ms': 51000,
'output': '--- FAIL',
'truncated': true,
},
{'command': 'make lint', 'status': 'not_run'},
'not a map',
],
})!;
expect(output.delivery, isTrue);
expect(output.summary, '1 of 2 checks failed: go test ./...');
expect(output.markdown, startsWith('# outcome'));
expect(output.checks, hasLength(3));
final [vet, test, lint] = output.checks;
expect(vet.status, CheckCommandStatus.passed);
expect(vet.meta, 'exit 0 · 2.1s');
expect(test.status, CheckCommandStatus.failed);
expect(test.meta, 'exit 1 · 51s');
expect(test.truncated, isTrue);
expect(lint.status, CheckCommandStatus.notRun);
expect(lint.meta, '');
expect(checkStatusLabel(lint), 'Not run');
});
test('statuses this client does not know keep their own word', () {
final output = checkStepOutput({
'checks': [
{'command': 'x', 'status': 'skipped_by_policy'},
{'command': 'y'},
{'command': 'z', 'status': 'timed_out'},
],
})!;
expect(output.checks[0].status, CheckCommandStatus.unknown);
expect(checkStatusLabel(output.checks[0]), 'skipped_by_policy');
expect(checkStatusLabel(output.checks[1]), 'Unknown status');
expect(checkStatusLabel(output.checks[2]), 'Timed out');
expect(output.delivery, isFalse);
});
test('outputs without a checks list are not check outputs', () {
expect(checkStepOutput(null), isNull);
expect(checkStepOutput('text'), isNull);
expect(checkStepOutput({'markdown': '# outcome'}), isNull);
expect(checkStepOutput({'checks': 'go test'}), isNull);
});
test('durations read compactly', () {
expect(formatCheckDuration(850), '850ms');
expect(formatCheckDuration(2000), '2s');
expect(formatCheckDuration(2100), '2.1s');
expect(formatCheckDuration(51000), '51s');
expect(formatCheckDuration(185000), '3m 05s');
expect(formatCheckDuration(3720000), '1h 02m');
});
}