Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use latest pkg/test features and fix travis accordingly #70

Merged
merged 2 commits into from
Jan 4, 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
28 changes: 21 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
language: dart
sudo: false
dart:
- stable
- dev
- 1.19.0
- 1.18.1
- 1.17.1
- stable
- 1.21.0
- 1.20.1
- 1.19.1
with_content_shell: true
env:
- TEST_PLATFORM=vm
- TEST_PLATFORM=content-shell
- TEST_PLATFORM=firefox
cache:
directories:
- $HOME/.pub-cache
with_content_shell: true
addons:
firefox: "latest"
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- 't=0; until (xdpyinfo -display :99 &> /dev/null || test $t -gt 10); do sleep 1; let t=$t+1; done'
script: ./tool/travis.sh
matrix:
allow_failures:
# Exclude SDKs before 1.22.0-dev.4 which are lacking fix
# https://github.com/dart-lang/sdk/commit/7c3c297a8ad907f12bf12b96a21777421067fd18
- dart: stable
env: TEST_PLATFORM=firefox
- dart: 1.21.0
env: TEST_PLATFORM=firefox
- dart: 1.20.1
env: TEST_PLATFORM=firefox
- dart: 1.19.1
env: TEST_PLATFORM=firefox
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ dependencies:
dev_dependencies:
http: '>=0.9.2 <0.12.0'
scheduled_test: '^0.12.0'
test: '^0.12.0'
test: '^0.12.7'
2 changes: 0 additions & 2 deletions test/add_chunked_encoding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import 'dart:async';
import 'package:shelf/shelf.dart';
import 'package:test/test.dart';

import 'test_util.dart';

void main() {
test('adds chunked encoding with no transfer-encoding header', () async {
var response = await _chunkResponse(
Expand Down
16 changes: 8 additions & 8 deletions test/hijack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void main() {
test('hijacking a hijackable request throws a HijackException and calls '
'onHijack', () {
var request = new Request('GET', LOCALHOST_URI,
onHijack: expectAsync((callback) {
var streamController = new StreamController();
onHijack: expectAsync1((void callback(a, b)) {
var streamController = new StreamController<List<int>>();
streamController.add([1, 2, 3]);
streamController.close();

Expand All @@ -29,7 +29,7 @@ void main() {
callback(streamController.stream, sinkController);
}));

expect(() => request.hijack(expectAsync((channel) {
expect(() => request.hijack(expectAsync1((channel) {
expect(channel.stream.first, completion(equals([1, 2, 3])));
channel.sink.add([4, 5, 6]);
channel.sink.close();
Expand All @@ -39,7 +39,7 @@ void main() {
test('hijacking a hijackable request twice throws a StateError', () {
// Assert that the [onHijack] callback is only called once.
var request = new Request('GET', LOCALHOST_URI,
onHijack: expectAsync((_) => null, count: 1));
onHijack: expectAsync1((_) => null, count: 1));

expect(() => request.hijack((_) => null),
throwsA(new isInstanceOf<HijackException>()));
Expand All @@ -57,8 +57,8 @@ void main() {
test('hijacking a hijackable request throws a HijackException and calls '
'onHijack', () {
var request = new Request('GET', LOCALHOST_URI,
onHijack: expectAsync((callback) {
var streamController = new StreamController();
onHijack: expectAsync1((callback(a, b)) {
var streamController = new StreamController<List<int>>();
streamController.add([1, 2, 3]);
streamController.close();

Expand All @@ -70,7 +70,7 @@ void main() {

var newRequest = request.change();

expect(() => newRequest.hijack(expectAsync((channel) {
expect(() => newRequest.hijack(expectAsync1((channel) {
expect(channel.stream.first, completion(equals([1, 2, 3])));
channel.sink.add([4, 5, 6]);
channel.sink.close();
Expand All @@ -81,7 +81,7 @@ void main() {
'StateError', () {
// Assert that the [onHijack] callback is only called once.
var request = new Request('GET', LOCALHOST_URI,
onHijack: expectAsync((_) => null, count: 1));
onHijack: expectAsync1((_) => null, count: 1));

var newRequest = request.change();

Expand Down
1 change: 0 additions & 1 deletion test/message_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ void main() {
});

test("supports a List<int> body", () {
var controller = new StreamController();
var request = _createMessage(body: HELLO_BYTES);
expect(request.read().toList(),
completion(equals([HELLO_BYTES])));
Expand Down
2 changes: 1 addition & 1 deletion test/server_handler_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void main() {

test("stops servicing requests after Server.close is called", () {
var serverHandler = new ServerHandler(LOCALHOST_URI);
serverHandler.server.mount(expectAsync((_) {}, count: 0));
serverHandler.server.mount(expectAsync1((_) {}, count: 0));
serverHandler.server.close();

expect(makeSimpleRequest(serverHandler.handler), throwsStateError);
Expand Down
6 changes: 3 additions & 3 deletions test/shelf_io_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void main() {
});

test('chunked requests are un-chunked', () {
_scheduleServer(expectAsync((request) {
_scheduleServer(expectAsync1((request) {
expect(request.contentLength, isNull);
expect(request.method, 'POST');
expect(request.headers, isNot(contains(HttpHeaders.TRANSFER_ENCODING)));
Expand Down Expand Up @@ -209,7 +209,7 @@ void main() {
_scheduleServer((request) {
expect(request.method, 'POST');

request.hijack(expectAsync((stream, sink) {
request.hijack(expectAsync2((stream, sink) {
expect(stream.first, completion(equals("Hello".codeUnits)));

sink.add(("HTTP/1.1 404 Not Found\r\n"
Expand Down Expand Up @@ -249,7 +249,7 @@ void main() {
server.close();
});
});
}, onError: expectAsync((error) {
}, onError: expectAsync1((error) {
expect(error, equals('oh no'));
}));
});
Expand Down
11 changes: 9 additions & 2 deletions tool/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
# Fast fail the script on failures.
set -e

pub run test -p vm,content-shell,firefox -j 1
THE_COMMAND="pub run test -p $TEST_PLATFORM"
if [ $TEST_PLATFORM == 'firefox' ] || [ $TEST_PLATFORM == 'content-shell' ]; then
# browser tests don't run well on travis unless one-at-a-time
THE_COMMAND="$THE_COMMAND -j 1"
fi

echo $THE_COMMAND
exec $THE_COMMAND

# Install dart_coveralls; gather and send coverage data.
if [ "$COVERALLS_TOKEN" ] && [ "$TRAVIS_DART_VERSION" = "stable" ]; then
if [ $TEST_PLATFORM == 'vm' ] && [ "$COVERALLS_TOKEN" ] && [ "$TRAVIS_DART_VERSION" = "stable" ]; then
pub global activate dart_coveralls

pub global run dart_coveralls report \
Expand Down