Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Enable travis-ci #7

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: dart

dart:
- dev
- stable

dart_task:
- test

# Only run one instance of the formatter and the analyzer, rather than running
# them against each Dart version.
matrix:
include:
- dart: dev
dart_task: dartfmt
- dart: dev
dart_task: dartanalyzer

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

cache:
directories:
- $HOME/.pub-cache
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
analyzer:
strong-mode: true
17 changes: 9 additions & 8 deletions lib/test_process.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ class TestProcess {
/// printed to the console as they appear. This is only intended to be set
/// temporarily to help when debugging test failures.
static Future<TestProcess> start(
String executable,
Iterable<String> arguments,
String executable, Iterable<String> arguments,
{String workingDirectory,
Map<String, String> environment,
bool includeParentEnvironment: true,
Expand All @@ -102,8 +101,8 @@ class TestProcess {
}

encoding ??= UTF8;
return new TestProcess(
process, description, encoding: encoding, forwardStdio: forwardStdio);
return new TestProcess(process, description,
encoding: encoding, forwardStdio: forwardStdio);
}

/// Creates a [TestProcess] for [process].
Expand All @@ -113,13 +112,15 @@ class TestProcess {
///
/// This is protected, which means it should only be called by subclasses.
@protected
TestProcess(Process process, this.description, {Encoding encoding,
bool forwardStdio: false})
TestProcess(Process process, this.description,
{Encoding encoding, bool forwardStdio: false})
: _process = process,
_stdoutSplitter = new StreamSplitter(process.stdout
.transform(encoding.decoder).transform(const LineSplitter())),
.transform(encoding.decoder)
.transform(const LineSplitter())),
_stderrSplitter = new StreamSplitter(process.stderr
.transform(encoding.decoder).transform(const LineSplitter())) {
.transform(encoding.decoder)
.transform(const LineSplitter())) {
addTearDown(_tearDown);
expect(_process.exitCode.then((_) => _logOutput()), completes,
reason: "Process `$description` never exited.");
Expand Down
29 changes: 13 additions & 16 deletions test/test_process_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,15 @@ void main() {
print("\nworld");
''');

expect(process.stdout,
emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stdout, emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stderr, emitsInOrder(['hi', emitsDone]));
await process.shouldExit(0);
});

test("close when the process exits", () async {
var process = await startDartProcess('');
expect(expectLater(process.stdout, emits('hello')),
throwsTestFailure);
expect(expectLater(process.stderr, emits('world')),
throwsTestFailure);
expect(expectLater(process.stdout, emits('hello')), throwsTestFailure);
expect(expectLater(process.stderr, emits('world')), throwsTestFailure);
await process.shouldExit(0);
});
});
Expand All @@ -73,19 +70,19 @@ void main() {
print("\nworld");
''');

expect(process.stdoutStream(),
emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stdoutStream(),
emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stdoutStream(),
emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stdoutStream(),
emitsInOrder(['hello', '', 'world', emitsDone]));

expect(process.stderrStream(), emitsInOrder(['hi', emitsDone]));
expect(process.stderrStream(), emitsInOrder(['hi', emitsDone]));
expect(process.stderrStream(), emitsInOrder(['hi', emitsDone]));
expect(process.stderrStream(), emitsInOrder(['hi', emitsDone]));

await process.shouldExit(0);
await process.shouldExit(0);

expect(process.stdoutStream(),
emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stderrStream(), emitsInOrder(['hi', emitsDone]));
expect(process.stdoutStream(),
emitsInOrder(['hello', '', 'world', emitsDone]));
expect(process.stderrStream(), emitsInOrder(['hi', emitsDone]));
});

test("stdin writes to the process", () async {
Expand Down