Skip to content

Commit

Permalink
fix(test): report errors without throwing (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed May 12, 2022
1 parent f738a8f commit 9c1e583
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/very_good_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:

- name: Run Tests
run: |
flutter pub global activate coverage
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
flutter pub global activate coverage 1.2.0
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
- name: Check Code Coverage
uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
Expand Down
4 changes: 2 additions & 2 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ Future<int> _flutterTest({
}
},
onError: (Object error, StackTrace stackTrace) {
subscription.cancel();
completer.completeError(error, stackTrace);
stderr('$clearLine$error');
stderr('$clearLine$stackTrace');
},
);

Expand Down
10 changes: 4 additions & 6 deletions test/src/cli/flutter_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void main() {
);
});

test('throws when process fails (with cleanup)', () async {
test('exits with code 69 when process fails (with cleanup)', () async {
final directory = Directory.systemTemp.createTempSync();
final testDirectory = Directory(p.join(directory.path, 'test'))
..createSync();
Expand All @@ -322,22 +322,20 @@ void main() {
.writeAsStringSync(testContents);
await expectLater(
Flutter.test(cwd: directory.path, optimizePerformance: true),
throwsA(
'''Error: Couldn't resolve the package 'test' in 'package:test/test.dart'.''',
),
completion(equals([69])),
);
await File(
p.join(testDirectory.path, '.test_runner.dart'),
).ensureDeleted();
});

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

expectLater(
Flutter.test(cwd: directory.path),
throwsA('Test directory "test" not found.'),
completion(equals([69])),
);
});

Expand Down

0 comments on commit 9c1e583

Please sign in to comment.