Skip to content

Commit

Permalink
fix(test): allow packages without a test directory (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasreis54 committed May 20, 2022
1 parent d229c5e commit 3ece759
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ class Flutter {
'Running "flutter test" in ${p.dirname(workingDirectory)}...\n',
);

if (!Directory(p.join(target.dir.absolute.path, 'test')).existsSync()) {
stdout?.call(
'No test folder found in ${target.dir.absolute.path}',
);
return ExitCode.success.code;
}

if (randomSeed != null) {
stdout?.call(
'''Shuffling test order with --test-randomize-ordering-seed=$randomSeed\n''',
Expand Down
16 changes: 13 additions & 3 deletions test/src/cli/flutter_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,24 @@ void main() {
).ensureDeleted();
});

test('exits with code 69 when there is no test directory', () {
test('exits with code 0 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),
completion(equals([69])),
Flutter.test(cwd: directory.path, stdout: logger.write),
completion(equals([ExitCode.success.code])),
);

verify(
() => logger.write(
any(
that: contains(
'No test folder found in ${directory.path}',
),
),
),
).called(1);
});

test('throws when there is no pubspec.yaml (recursive)', () {
Expand Down

0 comments on commit 3ece759

Please sign in to comment.