`check --format json --write-baseline b.json` printed "wrote baseline to ..." after the JSON document, and `guide --yams` printed "persisted to yams as ..." after the brief, so stdout was no longer a single JSON document (or a clean brief) and `| jq` failed. Both status lines now go to stderr.
27 lines
907 B
Dart
27 lines
907 B
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
test('check --format json --write-baseline keeps stdout pure JSON', () async {
|
|
// The "wrote baseline" status line used to follow the JSON document on
|
|
// stdout, so `pipe check --format json --write-baseline b.json | jq` failed.
|
|
final temp = Directory.systemTemp.createTempSync('pipe-json-stdout');
|
|
final baseline = '${temp.path}/baseline.json';
|
|
final result = await Process.run(Platform.resolvedExecutable, [
|
|
'bin/pipe.dart',
|
|
'check',
|
|
'test/fixtures/stuck_loading',
|
|
'--format',
|
|
'json',
|
|
'--write-baseline',
|
|
baseline,
|
|
'-c',
|
|
'1',
|
|
]);
|
|
expect(result.exitCode, 0, reason: '${result.stderr}');
|
|
expect(() => jsonDecode(result.stdout as String), returnsNormally);
|
|
expect(result.stderr as String, contains('wrote baseline'));
|
|
});
|
|
}
|