-
Notifications
You must be signed in to change notification settings - Fork 213
/
Copy pathhelp_test.dart
49 lines (39 loc) · 1.58 KB
/
help_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@TestOn('vm')
import 'dart:async';
import 'dart:io';
import 'package:test/test.dart';
import 'common/utils.dart';
void main() {
test('pub run build_runner help', () async {
await _testHelpCommand(() => runCommand(['help']));
});
test('pub run build_runner --help', () async {
await _testHelpCommand(() => runCommand(['--help']));
});
test('pub run build_runner build --help', () async {
await _testHelpCommand(() => runCommand(['build', '--help']));
});
test('pub run build_runner serve --help', () async {
await _testHelpCommand(() => runCommand(['serve', '--help']));
});
test('pub run build_runner test --help', () async {
await _testHelpCommand(() => runCommand(['test', '--help']));
});
test('pub run build_runner watch --help', () async {
await _testHelpCommand(() => runCommand(['watch', '--help']));
});
}
Future<void> _testHelpCommand(Future<ProcessResult> runCommand()) async {
var asyncResult = runCommand();
expect(asyncResult, completes,
reason: 'should not cause the auto build script to hang');
var result = await asyncResult;
expect(result.exitCode, equals(0),
reason: 'should give a successful exit code');
expect(result.stderr, isEmpty, reason: 'Should output nothing on stderr');
expect(result.stdout, isNot(contains('"Unhandled exception"')),
reason: 'Should not print an unhandled exception');
}