Skip to content

Commit 0a03109

Browse files
committed
Add simple integration test
1 parent 2682e15 commit 0a03109

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ jobs:
1919
script: ./tool/travis.sh dartanalyzer
2020
env: PKG="webdev"
2121
dart: dev
22+
- stage: unit_test
23+
script: ./tool/travis.sh test
24+
env: PKG="webdev"
25+
dart: dev
2226

2327
stages:
2428
- analyzer_and_format
29+
- unit_test
2530

2631
# Only building master means that we don't run two builds for each pull request.
2732
branches:

tool/travis.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ while (( "$#" )); do
2929
echo -e 'dartfmt -n --set-exit-if-changed .'
3030
dartfmt -n --set-exit-if-changed . || EXIT_CODE=$?
3131
;;
32+
test) echo
33+
echo -e '\033[1mTASK: test\033[22m'
34+
echo -e 'pub run test'
35+
pub run test || EXIT_CODE=$?
36+
;;
3237
*) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m"
3338
EXIT_CODE=1
3439
;;

webdev/.mono_repo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ stages:
66
- analyzer_and_format:
77
- dartfmt
88
- dartanalyzer: --fatal-infos --fatal-warnings .
9-
# - unit_test:
10-
# - test
9+
- unit_test:
10+
- test

webdev/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ dependencies:
1212
io: ^0.3.2+1
1313
stack_trace: ^1.9.2
1414

15+
dev_dependencies:
16+
test: ^0.12.0
17+
test_process: ^1.0.1
18+
1519
executables:
1620
webdev:

webdev/test/integration_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:test/test.dart';
8+
import 'package:test_process/test_process.dart';
9+
10+
void main() {
11+
test('README contains help output', () async {
12+
var process = await TestProcess.start('dart', ['bin/webdev.dart']);
13+
14+
var output = (await process.stdoutStream().join('\n')).trim();
15+
16+
var readme = new File('README.md');
17+
18+
expect(readme.readAsStringSync(),
19+
contains('```console\n\$ webdev\n$output\n```'));
20+
21+
await process.shouldExit(0);
22+
});
23+
24+
test('non-existant commands create errors', () async {
25+
var process =
26+
await TestProcess.start('dart', ['bin/webdev.dart', 'monkey']);
27+
28+
var output = (await process.stdoutStream().join('\n')).trim();
29+
30+
expect(output, contains('Could not find a command named "monkey".'));
31+
32+
await process.shouldExit(64);
33+
});
34+
35+
test('should fail in a package without a build_runner dependency', () async {
36+
var process = await TestProcess.start('dart', ['bin/webdev.dart', 'serve']);
37+
await process.shouldExit(255);
38+
});
39+
}

0 commit comments

Comments
 (0)