Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pub/bricks/test_optimizer/hooks/t…
Browse files Browse the repository at this point in the history
…est-1.25.0
  • Loading branch information
alestiago authored Dec 15, 2023
2 parents 8d0739e + 0670bb0 commit a5b7465
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
9 changes: 7 additions & 2 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class Flutter {
FlutterTestRunner testRunner = flutterTest,
GeneratorBuilder buildGenerator = MasonGenerator.fromBundle,
}) async {
final initialCwd = cwd;

return _runCommand<int>(
cmd: (cwd) async {
final lcovPath = p.join(cwd, 'coverage', 'lcov.info');
Expand All @@ -165,14 +167,17 @@ class Flutter {
void noop(String? _) {}
final target = DirectoryGeneratorTarget(Directory(p.normalize(cwd)));
final workingDirectory = target.dir.absolute.path;
final relativePath = p.relative(workingDirectory, from: initialCwd);
final path =
relativePath == '.' ? '.' : '.${p.context.separator}$relativePath';

stdout?.call(
'Running "flutter test" in ${p.dirname(workingDirectory)}...\n',
'Running "flutter test" in $path ...\n',
);

if (!Directory(p.join(target.dir.absolute.path, 'test')).existsSync()) {
stdout?.call(
'No test folder found in ${target.dir.absolute.path}\n',
'No test folder found in $path\n',
);
return ExitCode.success.code;
}
Expand Down
48 changes: 30 additions & 18 deletions test/src/cli/flutter_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'No test folder found in ${tempDirectory.absolute.path}\n',
'Running "flutter test" in . ...\n',
'No test folder found in .\n',
]),
);
});
Expand Down Expand Up @@ -431,7 +431,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
'\x1B[2K\r00:00 ...',
contains('All tests passed!'),
]),
Expand Down Expand Up @@ -462,7 +462,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
'\x1B[2K\r00:02 +1: CounterCubit initial state is 0',
'''\x1B[2K\r00:02 +2: CounterCubit emits [1] when increment is called''',
'''\x1B[2K\r00:02 +3: CounterCubit emits [-1] when decrement is called''',
Expand Down Expand Up @@ -504,7 +504,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
'''\x1B[2K\r\x1B[90m00:02\x1B[0m \x1B[92m+1\x1B[0m: CounterCubit initial state is 0''',
'''\x1B[2K\r\x1B[90m00:02\x1B[0m \x1B[92m+2\x1B[0m: CounterCubit emits [1] when increment is called''',
'''\x1B[2K\r\x1B[90m00:02\x1B[0m \x1B[92m+3\x1B[0m: CounterCubit emits [-1] when decrement is called''',
Expand Down Expand Up @@ -544,7 +544,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
'\x1B[2K\r00:11 -1: CounterCubit initial state is 0',
'''\x1B[2K\r00:11 +1 -1: CounterCubit emits [1] when increment is called''',
'''\x1B[2K\r00:11 +2 -1: CounterCubit emits [-1] when decrement is called''',
Expand Down Expand Up @@ -599,7 +599,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
'\x1B[2K\rSkip: currently failing (see issue 1234)\n',
'\x1B[2K\r(suite) ${tempDirectory.path}/test/counter/view/other_test.dart (SKIPPED)\n',
'\x1B[2K\r00:00 ~1: (suite)',
Expand Down Expand Up @@ -846,7 +846,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -882,7 +882,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
'Shuffling test order with --test-randomize-ordering-seed=$seed\n',
contains('All tests passed!'),
]),
Expand Down Expand Up @@ -928,7 +928,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -969,7 +969,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -1061,7 +1061,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -1114,13 +1114,19 @@ void main() {
completion(equals([ExitCode.success.code, ExitCode.success.code])),
);

final nestedRelativePath = p.relative(
tempNestedDirectory.path,
from: tempDirectory.path,
);
final relativePathPrefix = '.${p.context.separator}';

expect(
stdoutLogs,
unorderedEquals([
'Running "flutter test" in '
'${p.dirname(tempNestedDirectory.path)}...\n',
'$relativePathPrefix$nestedRelativePath ...\n',
contains('All tests passed!'),
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -1179,14 +1185,20 @@ void main() {
),
);

final nestedRelativePath = p.relative(
tempNestedDirectory.path,
from: tempDirectory.path,
);
final relativePathPrefix = '.${p.context.separator}';

expect(
stdoutLogs,
unorderedEquals([
'Running "flutter test" in '
'${p.dirname(tempDirectory.path)}...\n',
'. ...\n',
contains('All tests passed!'),
'Running "flutter test" in '
'${p.dirname(tempNestedDirectory.path)}...\n',
'$relativePathPrefix$nestedRelativePath ...\n',
contains('All tests passed!'),
]),
);
Expand Down Expand Up @@ -1242,7 +1254,7 @@ void main() {
expect(
stdoutLogs,
equals([
'Running "flutter test" in ${p.dirname(tempDirectory.path)}...\n',
'Running "flutter test" in . ...\n',
contains('All tests passed!'),
]),
);
Expand Down

0 comments on commit a5b7465

Please sign in to comment.