Skip to content

Commit 1f7cea8

Browse files
fix: address review feedback on PR #1636
Co-authored-by: marcossevilla <marcossevilla@users.noreply.github.com>
1 parent 2d68fa6 commit 1f7cea8

7 files changed

Lines changed: 82 additions & 74 deletions

File tree

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,3 @@ CLAUDE.local.md
3737

3838
.codex/
3939
.cursor/
40-
41-
# act artifacts
42-
act_output.log
43-
.secrets
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: malformed_fixture
2+
description: Fixture for testing malformed very_good.yaml.
3+
version: 0.1.0+1
4+
publish_to: none
5+
6+
environment:
7+
sdk: ^3.12.0
8+
9+
dev_dependencies:
10+
test: ^1.24.3
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- not
2+
- a
3+
- map

e2e/test/commands/test/very_good_config/very_good_config_test.dart

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ void main() {
3535
Directory.current = tempDirectory;
3636
addTearDown(() => Directory.current = cwd);
3737

38-
final result = await commandRunner.run(['test', '--coverage']);
39-
40-
expect(result, equals(ExitCode.unavailable.code));
38+
await expectLater(
39+
commandRunner.run(['test', '--coverage']),
40+
completion(equals(ExitCode.unavailable.code)),
41+
);
4142
verify(
4243
() => logger.err(any(that: contains('Expected coverage >= 100.00%'))),
4344
).called(1);
@@ -71,14 +72,15 @@ void main() {
7172
Directory.current = tempDirectory;
7273
addTearDown(() => Directory.current = cwd);
7374

74-
final result = await commandRunner.run([
75-
'test',
76-
'--coverage',
77-
'--min-coverage',
78-
'0',
79-
]);
80-
81-
expect(result, equals(ExitCode.success.code));
75+
await expectLater(
76+
commandRunner.run([
77+
'test',
78+
'--coverage',
79+
'--min-coverage',
80+
'0',
81+
]),
82+
completion(equals(ExitCode.success.code)),
83+
);
8284
}),
8385
);
8486

@@ -91,31 +93,23 @@ void main() {
9193
);
9294
addTearDown(() => tempDirectory.deleteSync(recursive: true));
9395

94-
File(path.join(tempDirectory.path, 'pubspec.yaml')).writeAsStringSync(
95-
'''
96-
name: malformed_fixture
97-
description: Fixture for testing malformed very_good.yaml.
98-
version: 0.1.0+1
99-
publish_to: none
100-
101-
environment:
102-
sdk: ^3.12.0
103-
104-
dev_dependencies:
105-
test: ^1.24.3
106-
''',
96+
final fixture = Directory(
97+
path.join(
98+
Directory.current.path,
99+
'test/commands/test/very_good_config/malformed_fixture',
100+
),
107101
);
108-
File(
109-
path.join(tempDirectory.path, 'very_good.yaml'),
110-
).writeAsStringSync('- not\n- a\n- map');
102+
103+
await copyDirectory(fixture, tempDirectory);
111104

112105
final cwd = Directory.current;
113106
Directory.current = tempDirectory;
114107
addTearDown(() => Directory.current = cwd);
115108

116-
final result = await commandRunner.run(['test']);
117-
118-
expect(result, equals(ExitCode.config.code));
109+
await expectLater(
110+
commandRunner.run(['test']),
111+
completion(equals(ExitCode.config.code)),
112+
);
119113
verify(
120114
() => logger.err(
121115
any(that: contains('Could not read `very_good.yaml`')),

test/src/commands/test/test_test.dart

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,8 @@ void main() {
951951
),
952952
),
953953
);
954-
expect(options.minCoverage, 90);
955-
expect(options.excludeFromCoverage, '**/*.g.dart');
954+
expect(options.minCoverage, equals(90));
955+
expect(options.excludeFromCoverage, equals('**/*.g.dart'));
956956
expect(options.reportOn, equals(['lib/']));
957957
});
958958

@@ -967,23 +967,20 @@ void main() {
967967
test: VeryGoodTestConfig(minCoverage: '90'),
968968
),
969969
);
970-
expect(options.minCoverage, 50);
970+
expect(options.minCoverage, equals(50));
971971
});
972972

973-
test(
974-
'falls back to the CLI default when the parsed arg is null '
975-
'and the config is unset',
976-
() {
977-
when(() => argResults.wasParsed(any())).thenReturn(true);
978-
when<dynamic>(
979-
() => argResults['collect-coverage-from'],
980-
).thenReturn(null);
973+
test('falls back to the CLI default when the parsed arg is null '
974+
'and the config is unset', () {
975+
when(() => argResults.wasParsed(any())).thenReturn(true);
976+
when<dynamic>(
977+
() => argResults['collect-coverage-from'],
978+
).thenReturn(null);
981979

982-
final options = FlutterTestOptions.parse(argResults);
980+
final options = FlutterTestOptions.parse(argResults);
983981

984-
expect(options.collectCoverageFrom, CoverageCollectionMode.imports);
985-
},
986-
);
982+
expect(options.collectCoverageFrom, CoverageCollectionMode.imports);
983+
});
987984
});
988985
});
989986
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
test:
2+
coverage: true
3+
optimization: false
4+
concurrency: 8
5+
tags: my-tag
6+
exclude_coverage: "**/*.g.dart"
7+
exclude_tags: skip
8+
min_coverage: 95
9+
show_uncovered: true
10+
collect_coverage_from: all
11+
update_goldens: true
12+
fail_fast: true
13+
dart_define:
14+
- FOO=bar
15+
- X=42
16+
dart_define_from_file: defines.env
17+
platform: chrome
18+
report_on:
19+
- lib/
20+
- packages/foo/lib/
21+
run_skipped: true
22+
flavor: staging
23+
timeout: 30

test/src/very_good_config/very_good_config_test.dart

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,16 @@ void main() {
3434
});
3535

3636
test('parses all supported test options', () {
37-
final config = VeryGoodConfig.fromString('''
38-
test:
39-
coverage: true
40-
optimization: false
41-
concurrency: 8
42-
tags: my-tag
43-
exclude_coverage: "**/*.g.dart"
44-
exclude_tags: skip
45-
min_coverage: 95
46-
show_uncovered: true
47-
collect_coverage_from: all
48-
update_goldens: true
49-
fail_fast: true
50-
dart_define:
51-
- FOO=bar
52-
- X=42
53-
dart_define_from_file: defines.env
54-
platform: chrome
55-
report_on:
56-
- lib/
57-
- packages/foo/lib/
58-
run_skipped: true
59-
flavor: staging
60-
timeout: 30
61-
''');
37+
final fixture = File(
38+
p.join(
39+
'test',
40+
'src',
41+
'very_good_config',
42+
'fixtures',
43+
'all_test_options.yaml',
44+
),
45+
);
46+
final config = VeryGoodConfig.fromString(fixture.readAsStringSync());
6247

6348
expect(config.test.coverage, isTrue);
6449
expect(config.test.optimization, isFalse);

0 commit comments

Comments
 (0)