Skip to content

Commit 6295a19

Browse files
authored
Enable coverage once more. (#2609)
* Try enabling coverage again. * Actually enable coverage * Work around coverage failure? * expectLater is unreliable -- remove it * Get all the similar constructs converted to the 'working' pattern
1 parent cf09214 commit 6295a19

File tree

3 files changed

+67
-53
lines changed

3 files changed

+67
-53
lines changed

.github/workflows/test.yaml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,19 @@ jobs:
5252
run: ./tool/travis.sh
5353
env:
5454
DARTDOC_BOT: ${{ matrix.job }}
55-
# TODO(jcollins-g): uncomment after #2590 is fixed
56-
#COVERAGE_TOKEN: true # this needs to be set to enable coverage
55+
COVERAGE_TOKEN: true # this needs to be set to enable coverage
5756
- name: ${{ matrix.job }}
5857
if: runner.os == 'Windows' && matrix.job == 'main'
5958
run: pub run grinder buildbot
6059
env:
6160
DARTDOC_BOT: ${{ matrix.job }}
62-
# TODO(jcollins-g): uncomment after #2590 is fixed
63-
#- id: coverage
64-
# name: Upload coverage
65-
# if: runner.os == 'Linux' && matrix.job == 'main' && matrix.sdk == 'dev'
66-
# uses: coverallsapp/[email protected]
67-
# with:
68-
# github-token: ${{ secrets.GITHUB_TOKEN }}
69-
# path-to-lcov: lcov.info
70-
#- name: Echo coveralls api result
71-
# if: runner.os == 'Linux' && matrix.job == 'main' && matrix.sdk == 'dev'
72-
# run: echo ${{ steps.coverage.outputs['coveralls-api-result'] }}
61+
- id: coverage
62+
name: Upload coverage
63+
if: runner.os == 'Linux' && matrix.job == 'main' && matrix.sdk == 'dev'
64+
uses: coverallsapp/[email protected]
65+
with:
66+
github-token: ${{ secrets.GITHUB_TOKEN }}
67+
path-to-lcov: lcov.info
68+
- name: Echo coveralls api result
69+
if: runner.os == 'Linux' && matrix.job == 'main' && matrix.sdk == 'dev'
70+
run: echo ${{ steps.coverage.outputs['coveralls-api-result'] }}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: '>=2.11.99 <3.0.0'
88

99
dependencies:
10-
analyzer: ^1.3.0
10+
analyzer: ^1.4.0
1111
args: ^2.0.0
1212
charcode: ^1.2.0
1313
collection: ^1.2.0

test/end2end/dartdoc_integration_test.dart

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,20 @@ void main() {
9191
test('invalid parameters return non-zero and print a fatal-error',
9292
() async {
9393
var outputLines = <String>[];
94-
await expectLater(
95-
() => subprocessLauncher.runStreamed(
96-
Platform.resolvedExecutable,
97-
[
98-
dartdocPath,
99-
'--nonexisting',
100-
],
101-
perLine: outputLines.add),
102-
throwsA(const TypeMatcher<ProcessException>()));
94+
var threwException = false;
95+
// consider [expectLater] when it works reliably with coverage again.
96+
try {
97+
await subprocessLauncher.runStreamed(
98+
Platform.resolvedExecutable,
99+
[
100+
dartdocPath,
101+
'--nonexisting',
102+
],
103+
perLine: outputLines.add);
104+
} on ProcessException {
105+
threwException = true;
106+
}
107+
expect(threwException, isTrue);
103108
expect(
104109
outputLines.firstWhere((l) => l.startsWith(' fatal')),
105110
equals(
@@ -109,31 +114,41 @@ void main() {
109114
test('missing a required file path prints a fatal-error', () async {
110115
var outputLines = <String>[];
111116
var impossiblePath = path.join(dartdocPath, 'impossible');
112-
await expectLater(
113-
() => subprocessLauncher.runStreamed(
114-
Platform.resolvedExecutable,
115-
[
116-
dartdocPath,
117-
'--input',
118-
impossiblePath,
119-
],
120-
perLine: outputLines.add),
121-
throwsA(const TypeMatcher<ProcessException>()));
117+
var threwException = false;
118+
// consider [expectLater] when it works with coverage again.
119+
try {
120+
await subprocessLauncher.runStreamed(
121+
Platform.resolvedExecutable,
122+
[
123+
dartdocPath,
124+
'--input',
125+
impossiblePath,
126+
],
127+
perLine: outputLines.add);
128+
} on ProcessException {
129+
threwException = true;
130+
}
131+
expect(threwException, isTrue);
122132
expect(
123133
outputLines.firstWhere((l) => l.startsWith(' fatal')),
124134
startsWith(
125135
' fatal error: Argument --input, set to $impossiblePath, resolves to missing path: '));
126136
});
127137

128138
test('errors cause non-zero exit when warnings are off', () async {
129-
expect(
130-
() => subprocessLauncher.runStreamed(Platform.resolvedExecutable, [
131-
dartdocPath,
132-
'--allow-tools',
133-
'--input=${testPackageToolError.path}',
134-
'--output=${path.join(tempDir.absolute.path, 'test_package_tool_error')}'
135-
]),
136-
throwsA(const TypeMatcher<ProcessException>()));
139+
// consider [expectLater] when it works with coverage.
140+
var exceptionThrown = false;
141+
try {
142+
await subprocessLauncher.runStreamed(Platform.resolvedExecutable, [
143+
dartdocPath,
144+
'--allow-tools',
145+
'--input=${testPackageToolError.path}',
146+
'--output=${path.join(tempDir.absolute.path, 'test_package_tool_error')}'
147+
]);
148+
} on ProcessException {
149+
exceptionThrown = true;
150+
}
151+
expect(exceptionThrown, isTrue);
137152
});
138153

139154
test('help prints command line args', () async {
@@ -156,19 +171,20 @@ void main() {
156171
var dartTool =
157172
Directory(path.join(_testPackageFlutterPluginPath, '.dart_tool'));
158173
if (dartTool.existsSync()) dartTool.deleteSync(recursive: true);
159-
Future run = subprocessLauncher.runStreamed(
160-
Platform.resolvedExecutable, args,
161-
environment: Map.from(Platform.environment)..remove('FLUTTER_ROOT'),
162-
includeParentEnvironment: false,
163-
workingDirectory: _testPackageFlutterPluginPath, perLine: (s) {
164-
output.writeln(s);
165-
});
166-
// Asynchronous exception, but we still need the output, too.
167-
expect(run, throwsA(TypeMatcher<ProcessException>()));
174+
var exceptionThrown = false;
175+
// consider [expectLater] when this works with coverage
168176
try {
169-
await run;
170-
} on ProcessException catch (_) {}
171-
177+
await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args,
178+
environment: Map.from(Platform.environment)..remove('FLUTTER_ROOT'),
179+
includeParentEnvironment: false,
180+
workingDirectory: _testPackageFlutterPluginPath, perLine: (s) {
181+
output.writeln(s);
182+
});
183+
} on ProcessException {
184+
exceptionThrown = true;
185+
}
186+
// Asynchronous exception, but we still need the output, too.
187+
expect(exceptionThrown, isTrue);
172188
expect(
173189
output.toString(),
174190
contains(RegExp(

0 commit comments

Comments
 (0)