Skip to content

Commit 0f9d353

Browse files
committed
Use better process output validation
1 parent ba8a0bb commit 0f9d353

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

webdev/test/integration_test.dart

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,19 @@ final _webdevBin = p.absolute('bin/webdev.dart');
1414
void main() {
1515
test('README contains help output', () async {
1616
var process = await TestProcess.start('dart', [_webdevBin]);
17-
1817
var output = (await process.stdoutStream().join('\n')).trim();
18+
await process.shouldExit(0);
1919

2020
var readme = new File('README.md');
21-
2221
expect(readme.readAsStringSync(),
2322
contains('```console\n\$ webdev\n$output\n```'));
24-
25-
await process.shouldExit(0);
2623
});
2724

2825
test('non-existant commands create errors', () async {
2926
var process = await TestProcess.start('dart', [_webdevBin, 'monkey']);
3027

31-
var output = (await process.stdoutStream().join('\n')).trim();
32-
33-
expect(output, contains('Could not find a command named "monkey".'));
28+
await expectLater(
29+
process.stdout, emits('Could not find a command named "monkey".'));
3430

3531
await process.shouldExit(64);
3632
});
@@ -63,12 +59,12 @@ packages:
6359

6460
var process = await TestProcess.start('dart', [_webdevBin, 'build'],
6561
workingDirectory: d.sandbox);
66-
var output = (await process.stdoutStream().join('\n')).trim();
6762

68-
expect(output, contains('Could not run in the current directory.'));
69-
expect(
70-
output,
71-
contains('The `build_runner` version – $version – '
63+
await expectLater(
64+
process.stdout, emits('Could not run in the current directory.'));
65+
await expectLater(
66+
process.stdout,
67+
emits('The `build_runner` version – $version – '
7268
'is not within the supported range – >=0.8.0 <0.9.0.'));
7369
await process.shouldExit(78);
7470
});
@@ -90,11 +86,11 @@ packages:
9086

9187
var process = await TestProcess.start('dart', [_webdevBin, 'build'],
9288
workingDirectory: d.sandbox);
93-
var output = (await process.stdoutStream().join('\n')).trim();
9489

95-
expect(output, contains('Could not run in the current directory.'));
96-
expect(output,
97-
contains('A dependency on `build_web_compilers` was not found.'));
90+
await expectLater(
91+
process.stdout, emits('Could not run in the current directory.'));
92+
await expectLater(process.stdout,
93+
emits('A dependency on `build_web_compilers` was not found.'));
9894
await process.shouldExit(78);
9995
});
10096

@@ -120,11 +116,11 @@ packages:
120116

121117
var process = await TestProcess.start('dart', [_webdevBin, 'build'],
122118
workingDirectory: d.sandbox);
123-
var output = (await process.stdoutStream().join('\n')).trim();
124119

125-
expect(output, contains('Could not run in the current directory.'));
126-
expect(output,
127-
contains('A `.packages` file does not exist in the target directory.'));
120+
await expectLater(
121+
process.stdout, emits('Could not run in the current directory.'));
122+
await expectLater(process.stdout,
123+
emits('A `.packages` file does not exist in the target directory.'));
128124
await process.shouldExit(78);
129125
});
130126

@@ -152,9 +148,9 @@ packages:
152148

153149
var process = await TestProcess.start('dart', [_webdevBin, 'build'],
154150
workingDirectory: d.sandbox);
155-
var output = (await process.stdoutStream().join('\n')).trim();
156151

157-
expect(output, contains('An unexpected exception has occurred.'));
152+
await expectLater(
153+
process.stdout, emits('An unexpected exception has occurred.'));
158154
await process.shouldExit(70);
159155
});
160156
}

0 commit comments

Comments
 (0)