Skip to content

Commit 3ece759

Browse files
authored
fix(test): allow packages without a test directory (#404)
1 parent d229c5e commit 3ece759

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

lib/src/cli/flutter_cli.dart

+7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ class Flutter {
143143
'Running "flutter test" in ${p.dirname(workingDirectory)}...\n',
144144
);
145145

146+
if (!Directory(p.join(target.dir.absolute.path, 'test')).existsSync()) {
147+
stdout?.call(
148+
'No test folder found in ${target.dir.absolute.path}',
149+
);
150+
return ExitCode.success.code;
151+
}
152+
146153
if (randomSeed != null) {
147154
stdout?.call(
148155
'''Shuffling test order with --test-randomize-ordering-seed=$randomSeed\n''',

test/src/cli/flutter_cli_test.dart

+13-3
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,24 @@ void main() {
355355
).ensureDeleted();
356356
});
357357

358-
test('exits with code 69 when there is no test directory', () {
358+
test('exits with code 0 when there is no test directory', () {
359359
final directory = Directory.systemTemp.createTempSync();
360360
File(p.join(directory.path, 'pubspec.yaml')).writeAsStringSync(pubspec);
361361

362362
expectLater(
363-
Flutter.test(cwd: directory.path),
364-
completion(equals([69])),
363+
Flutter.test(cwd: directory.path, stdout: logger.write),
364+
completion(equals([ExitCode.success.code])),
365365
);
366+
367+
verify(
368+
() => logger.write(
369+
any(
370+
that: contains(
371+
'No test folder found in ${directory.path}',
372+
),
373+
),
374+
),
375+
).called(1);
366376
});
367377

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

0 commit comments

Comments
 (0)