Skip to content

Commit 5f389be

Browse files
authored
Fix DWDS tests with webdev 2.0.0 (#321)
1 parent 662ea5c commit 5f389be

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ jobs:
2828
env: PKGS="dwds example webdev"
2929
script: ./tool/travis.sh dartanalyzer_1
3030
- stage: unit_test
31-
name: "SDK: 2.2.1-dev.2.0; PKG: dwds; TASKS: `pub run test`"
31+
name: "SDK: 2.2.1-dev.2.0; PKG: dwds; TASKS: `pub run test -j 1`"
3232
dart: "2.2.1-dev.2.0"
3333
env: PKGS="dwds"
3434
script: ./tool/travis.sh test_0
3535
- stage: unit_test
36-
name: "SDK: dev; PKG: dwds; TASKS: `pub run test`"
36+
name: "SDK: dev; PKG: dwds; TASKS: `pub run test -j 1`"
3737
dart: dev
3838
env: PKGS="dwds"
3939
script: ./tool/travis.sh test_0

dwds/example/hello_world/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
<head>
44
<script defer src="main.dart.js"></script>
5-
<script>
6-
window.$dartAppId = 'id-for-testing';
7-
window.$dartAppInstanceId = 'instance-id-for-testing';
8-
</script>
95
</head>
106

117
</html>

dwds/mono_pkg.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ stages:
1313
- dartanalyzer: --fatal-warnings .
1414
dart: [2.2.1-dev.2.0]
1515
- unit_test:
16-
- test:
16+
- test: -j 1

dwds/test/test_context.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import 'dart:async';
12
import 'dart:convert';
23
import 'dart:io';
34

5+
import 'package:dwds/service.dart';
46
import 'package:dwds/src/chrome_proxy_service.dart';
57
import 'package:dwds/src/helpers.dart';
6-
import 'package:dwds/service.dart';
78
import 'package:http/http.dart' as http;
89
import 'package:test/test.dart';
910
import 'package:webdriver/io.dart';
@@ -36,12 +37,18 @@ class TestContext {
3637
webdev.stderr
3738
.transform(const Utf8Decoder())
3839
.transform(const LineSplitter())
39-
.listen(printOnFailure);
40-
await webdev.stdout
40+
.listen(print);
41+
var assetReadyCompleter = Completer();
42+
webdev.stdout
4143
.transform(const Utf8Decoder())
4244
.transform(const LineSplitter())
43-
.takeWhile((line) => !line.contains('$port'))
44-
.drain();
45+
.listen((line) {
46+
if (line.contains('$port') && !assetReadyCompleter.isCompleted) {
47+
assetReadyCompleter.complete();
48+
}
49+
printOnFailure(line);
50+
});
51+
await assetReadyCompleter.future;
4552
appUrl = 'http://localhost:$port/hello_world/';
4653
var debugPort = await findUnusedPort();
4754
webDriver = await createDriver(desired: {
@@ -71,8 +78,11 @@ class TestContext {
7178
return result.body;
7279
};
7380

81+
var instanceId =
82+
await tabConnection.runtime.evaluate(r'window.$dartAppInstanceId');
83+
7484
debugService = await DebugService.start(
75-
'localhost', connection, assetHandler, 'instance-id-for-testing');
85+
'localhost', connection, assetHandler, instanceId.value.toString());
7686
}
7787

7888
Future<Null> tearDown() async {

tool/travis.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ for PKG in ${PKGS}; do
3737
;;
3838
test_0) echo
3939
echo -e '\033[1mTASK: test_0\033[22m'
40-
echo -e 'pub run test'
41-
pub run test || EXIT_CODE=$?
40+
echo -e 'pub run test -j 1'
41+
pub run test -j 1 || EXIT_CODE=$?
4242
;;
4343
test_1) echo
4444
echo -e '\033[1mTASK: test_1\033[22m'

0 commit comments

Comments
 (0)