Skip to content

Commit 9c1e583

Browse files
authored
fix(test): report errors without throwing (#393)
1 parent f738a8f commit 9c1e583

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

.github/workflows/very_good_cli.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939

4040
- name: Run Tests
4141
run: |
42-
flutter pub global activate coverage
43-
flutter pub run test -j 1 -x pull-request-only -x e2e --coverage=coverage --test-randomize-ordering-seed random && dart run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib
42+
flutter pub global activate coverage 1.2.0
43+
flutter pub run test -j 1 -x pull-request-only -x e2e --coverage=coverage --test-randomize-ordering-seed random && dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --packages=.packages --report-on=lib
4444
4545
- name: Check Code Coverage
4646
uses: VeryGoodOpenSource/very_good_coverage@v1.2.0

lib/src/cli/flutter_cli.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ Future<int> _flutterTest({
379379
}
380380
},
381381
onError: (Object error, StackTrace stackTrace) {
382-
subscription.cancel();
383-
completer.completeError(error, stackTrace);
382+
stderr('$clearLine$error');
383+
stderr('$clearLine$stackTrace');
384384
},
385385
);
386386

test/src/cli/flutter_cli_test.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ void main() {
312312
);
313313
});
314314

315-
test('throws when process fails (with cleanup)', () async {
315+
test('exits with code 69 when process fails (with cleanup)', () async {
316316
final directory = Directory.systemTemp.createTempSync();
317317
final testDirectory = Directory(p.join(directory.path, 'test'))
318318
..createSync();
@@ -322,22 +322,20 @@ void main() {
322322
.writeAsStringSync(testContents);
323323
await expectLater(
324324
Flutter.test(cwd: directory.path, optimizePerformance: true),
325-
throwsA(
326-
'''Error: Couldn't resolve the package 'test' in 'package:test/test.dart'.''',
327-
),
325+
completion(equals([69])),
328326
);
329327
await File(
330328
p.join(testDirectory.path, '.test_runner.dart'),
331329
).ensureDeleted();
332330
});
333331

334-
test('throws when there is no test directory', () {
332+
test('exits with code 69 when there is no test directory', () {
335333
final directory = Directory.systemTemp.createTempSync();
336334
File(p.join(directory.path, 'pubspec.yaml')).writeAsStringSync(pubspec);
337335

338336
expectLater(
339337
Flutter.test(cwd: directory.path),
340-
throwsA('Test directory "test" not found.'),
338+
completion(equals([69])),
341339
);
342340
});
343341

0 commit comments

Comments
 (0)