From 38d4c9f69debb512be5256319e5331b755817c55 Mon Sep 17 00:00:00 2001 From: Gary Roumanis Date: Thu, 22 Jun 2017 13:43:12 -0700 Subject: [PATCH 1/4] await some unawaited futures --- lib/src/executable.dart | 2 +- lib/src/frontend/stream_matcher.dart | 2 +- lib/src/runner.dart | 2 +- lib/src/runner/browser/content_shell.dart | 6 +++--- lib/src/runner/browser/dartium.dart | 4 ++-- lib/src/runner/engine.dart | 4 ++-- lib/src/runner/load_suite.dart | 2 +- lib/src/runner/runner_suite.dart | 2 +- test/runner/expanded_reporter_test.dart | 2 +- test/runner/json_reporter_test.dart | 2 +- test/runner/pub_serve_test.dart | 2 +- test/runner/retry_test.dart | 2 +- test/util/stream_queue_test.dart | 26 +++++++++++------------ 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/src/executable.dart b/lib/src/executable.dart index 8293985a8..538ca0a43 100644 --- a/lib/src/executable.dart +++ b/lib/src/executable.dart @@ -161,7 +161,7 @@ transformers: if (signalSubscription == null) return; signalSubscription.cancel(); signalSubscription = null; - stdinLines.cancel(immediate: true); + await stdinLines.cancel(immediate: true); await runner.close(); } diff --git a/lib/src/frontend/stream_matcher.dart b/lib/src/frontend/stream_matcher.dart index 6c906744b..8b3603dc2 100644 --- a/lib/src/frontend/stream_matcher.dart +++ b/lib/src/frontend/stream_matcher.dart @@ -155,7 +155,7 @@ class _StreamMatcher extends AsyncMatcher implements StreamMatcher { // Wait on a timer tick so all buffered events are emitted. await new Future.delayed(Duration.ZERO); - subscription.cancel(); + await subscription.cancel(); var eventsString = events.map((event) { if (event == null) { diff --git a/lib/src/runner.dart b/lib/src/runner.dart index 0b63e5cea..c8d4b34fe 100644 --- a/lib/src/runner.dart +++ b/lib/src/runner.dart @@ -193,7 +193,7 @@ class Runner { if (_debugOperation != null) await _debugOperation.cancel(); - if (_suiteSubscription != null) _suiteSubscription.cancel(); + if (_suiteSubscription != null) await _suiteSubscription.cancel(); _suiteSubscription = null; // Make sure we close the engine *before* the loader. Otherwise, diff --git a/lib/src/runner/browser/content_shell.dart b/lib/src/runner/browser/content_shell.dart index 0a7009a57..4ce3027b9 100644 --- a/lib/src/runner/browser/content_shell.dart +++ b/lib/src/runner/browser/content_shell.dart @@ -73,7 +73,7 @@ class ContentShell extends Browser { !stderr.current .contains("kq_init: detected broken kqueue; not using")) { if (stderr.current == "[dartToStderr]: Dartium build has expired") { - stderr.cancel(); + await stderr.cancel(); process.kill(); // TODO(nweiz): link to dartlang.org once it has download links for // content shell @@ -86,7 +86,7 @@ class ContentShell extends Browser { } else if (stderr.current.contains("bind() returned an error")) { // If we failed to bind to the port, return null to tell // getUnusedPort to try another one. - stderr.cancel(); + await stderr.cancel(); process.kill(); return null; } @@ -99,7 +99,7 @@ class ContentShell extends Browser { remoteDebuggerCompleter.complete(null); } - stderr.cancel(); + await stderr.cancel(); return process; }; diff --git a/lib/src/runner/browser/dartium.dart b/lib/src/runner/browser/dartium.dart index 3e8235b97..c1a2b4235 100644 --- a/lib/src/runner/browser/dartium.dart +++ b/lib/src/runner/browser/dartium.dart @@ -92,12 +92,12 @@ class Dartium extends Browser { if (logs.current.contains("bind() returned an error")) { // If we failed to bind to the port, return null to tell // getUnusedPort to try another one. - logs.cancel(); + await logs.cancel(); process.kill(); return null; } } - logs.cancel(); + await logs.cancel(); } else { observatoryCompleter.complete(null); } diff --git a/lib/src/runner/engine.dart b/lib/src/runner/engine.dart index 07dbbeeac..e1aee95bc 100644 --- a/lib/src/runner/engine.dart +++ b/lib/src/runner/engine.dart @@ -529,8 +529,8 @@ class Engine { Future close() async { _closed = true; if (_closedBeforeDone != null) _closedBeforeDone = true; - _onSuiteAddedController.close(); - _suiteController.close(); + await _onSuiteAddedController.close(); + await _suiteController.close(); // Close the running tests first so that we're sure to wait for them to // finish before we close their suites and cause them to become unloaded. diff --git a/lib/src/runner/load_suite.dart b/lib/src/runner/load_suite.dart index d8194ddfa..0beaf966c 100644 --- a/lib/src/runner/load_suite.dart +++ b/lib/src/runner/load_suite.dart @@ -80,7 +80,7 @@ class LoadSuite extends Suite implements RunnerSuite { if (completer.isCompleted) { // If the load test has already been closed, close the suite it // generated. - suite?.close(); + await suite?.close(); return; } diff --git a/lib/src/runner/runner_suite.dart b/lib/src/runner/runner_suite.dart index 45cb6d97a..9d9ed1db0 100644 --- a/lib/src/runner/runner_suite.dart +++ b/lib/src/runner/runner_suite.dart @@ -114,7 +114,7 @@ class RunnerSuiteController { /// The backing function for [suite.close]. Future _close() => _closeMemo.runOnce(() async { - _onDebuggingController.close(); + await _onDebuggingController.close(); if (_onClose != null) await _onClose(); }); final _closeMemo = new AsyncMemoizer(); diff --git a/test/runner/expanded_reporter_test.dart b/test/runner/expanded_reporter_test.dart index 5a4097a5b..ea01d4268 100644 --- a/test/runner/expanded_reporter_test.dart +++ b/test/runner/expanded_reporter_test.dart @@ -350,7 +350,7 @@ void main() { } Future _expectReport(String tests, String expected, {List args}) async { - d + await d .file( "test.dart", """ diff --git a/test/runner/json_reporter_test.dart b/test/runner/json_reporter_test.dart index 92af2e774..83bbc1b72 100644 --- a/test/runner/json_reporter_test.dart +++ b/test/runner/json_reporter_test.dart @@ -563,7 +563,7 @@ void main() { /// [expected]. Future _expectReport(String tests, List expected, {List args}) async { - d + await d .file( "test.dart", """ diff --git a/test/runner/pub_serve_test.dart b/test/runner/pub_serve_test.dart index e79af54e5..e263cb57f 100644 --- a/test/runner/pub_serve_test.dart +++ b/test/runner/pub_serve_test.dart @@ -278,7 +278,7 @@ void main() { containsInOrder( [" main.", "package:test", "dart:async/zone.dart"])); await test.shouldExit(1); - pub.kill(); + await pub.kill(); }, tags: 'chrome'); test("doesn't dartify stack traces for JS-compiled tests with --js-trace", diff --git a/test/runner/retry_test.dart b/test/runner/retry_test.dart index a5405c8eb..6f8558db4 100644 --- a/test/runner/retry_test.dart +++ b/test/runner/retry_test.dart @@ -65,7 +65,7 @@ void main() { }); test("respects top-level @Retry declarations", () async { - d + await d .file( "test.dart", """ diff --git a/test/util/stream_queue_test.dart b/test/util/stream_queue_test.dart index 15ed3c018..f8ef7f01b 100644 --- a/test/util/stream_queue_test.dart +++ b/test/util/stream_queue_test.dart @@ -38,7 +38,7 @@ main() { expect(controller.hasListener, isTrue); expect(controller.isPaused, isTrue); - events.cancel(); + await events.cancel(); expect(controller.hasListener, isFalse); }); }); @@ -383,7 +383,7 @@ main() { expect(await events.next, 1); expect(controller.hasListener, isTrue); - events.cancel(immediate: true); + await events.cancel(immediate: true); expect(controller.hasListener, isFalse); }); @@ -831,7 +831,7 @@ main() { var queue1 = new StreamQueue(createStream()); var queue2 = queue1.fork(); - queue2.cancel(); + await queue2.cancel(); expect(() => queue2.next, throwsStateError); expect(await queue1.next, 1); @@ -846,7 +846,7 @@ main() { var queue1 = new StreamQueue(createStream()); var queue2 = queue1.fork(); - queue1.cancel(); + await queue1.cancel(); expect(() => queue1.next, throwsStateError); expect(await queue2.next, 1); @@ -863,7 +863,7 @@ main() { expect(await queue1.next, 1); - queue1.cancel(); + await queue1.cancel(); expect(() => queue1.next, throwsStateError); expect(await queue2.next, 1); @@ -886,12 +886,12 @@ main() { await flushMicrotasks(); expect(controller.hasListener, isTrue); - queue2.cancel(); + await queue2.cancel(); await flushMicrotasks(); expect(controller.hasListener, isTrue); controller.add(1); - queue1.cancel(); + await queue1.cancel(); await flushMicrotasks(); expect(controller.hasListener, isFalse); }); @@ -901,7 +901,7 @@ main() { var queue1 = new StreamQueue(createStream()); var queue2 = queue1.fork(); - queue2.cancel(immediate: true); + await queue2.cancel(immediate: true); expect(() => queue2.next, throwsStateError); expect(await queue1.next, 1); @@ -916,7 +916,7 @@ main() { var queue1 = new StreamQueue(createStream()); var queue2 = queue1.fork(); - queue1.cancel(immediate: true); + await queue1.cancel(immediate: true); expect(() => queue1.next, throwsStateError); expect(await queue2.next, 1); @@ -933,7 +933,7 @@ main() { expect(await queue1.next, 1); - queue1.cancel(immediate: true); + await queue1.cancel(immediate: true); expect(() => queue1.next, throwsStateError); expect(await queue2.next, 1); @@ -957,11 +957,11 @@ main() { await flushMicrotasks(); expect(controller.hasListener, isTrue); - queue2.cancel(immediate: true); + await queue2.cancel(immediate: true); await flushMicrotasks(); expect(controller.hasListener, isTrue); - queue1.cancel(immediate: true); + await queue1.cancel(immediate: true); await flushMicrotasks(); expect(controller.hasListener, isFalse); }); @@ -1132,7 +1132,7 @@ Stream createErrorStream() { await flushMicrotasks(); controller.add(4); await flushMicrotasks(); - controller.close(); + await controller.close(); }(); return controller.stream; } From 895687da910042b831341ad7ceae0e3f1436d6be Mon Sep 17 00:00:00 2001 From: Gary Roumanis Date: Thu, 22 Jun 2017 14:19:27 -0700 Subject: [PATCH 2/4] remove travis hack --- lib/src/executable.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/src/executable.dart b/lib/src/executable.dart index 538ca0a43..d00e17d08 100644 --- a/lib/src/executable.dart +++ b/lib/src/executable.dart @@ -182,12 +182,6 @@ transformers: } finally { await close(); } - - // TODO(grouma) - figure out why the executable can hang in the travis - // environment. https://github.com/dart-lang/test/issues/599 - if (Platform.environment["TRAVIS"] == "true") { - exit(exitCode); - } } /// Print usage information for this command. From 32944a3c341917ab10f382c069fbed3ac5e19b08 Mon Sep 17 00:00:00 2001 From: Gary Roumanis Date: Thu, 22 Jun 2017 16:39:23 -0700 Subject: [PATCH 3/4] remove await --- lib/src/executable.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/executable.dart b/lib/src/executable.dart index d00e17d08..331059c34 100644 --- a/lib/src/executable.dart +++ b/lib/src/executable.dart @@ -161,7 +161,7 @@ transformers: if (signalSubscription == null) return; signalSubscription.cancel(); signalSubscription = null; - await stdinLines.cancel(immediate: true); + stdinLines.cancel(immediate: true); await runner.close(); } From cf43071feb7c776def66b28b90d37e9b7e37afaf Mon Sep 17 00:00:00 2001 From: Gary Roumanis Date: Thu, 10 Aug 2017 14:32:29 -0700 Subject: [PATCH 4/4] dartfmt with correct sdk --- test/runner/pub_serve_test.dart | 52 ++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/test/runner/pub_serve_test.dart b/test/runner/pub_serve_test.dart index b4efa10a9..ed17ddc56 100644 --- a/test/runner/pub_serve_test.dart +++ b/test/runner/pub_serve_test.dart @@ -21,7 +21,10 @@ String get _pubServeArg => '--pub-serve=$pubServePort'; void main() { setUp(() async { - await d.file("pubspec.yaml", """ + await d + .file( + "pubspec.yaml", + """ name: myapp dependencies: barback: any @@ -31,10 +34,13 @@ transformers: \$include: test/**_test.dart - test/pub_serve: \$include: test/**_test.dart -""").create(); +""") + .create(); await d.dir("test", [ - d.file("my_test.dart", """ + d.file( + "my_test.dart", + """ import 'package:test/test.dart'; void main() { @@ -44,7 +50,9 @@ void main() { ]).create(); await d.dir("lib", [ - d.file("myapp.dart", """ + d.file( + "myapp.dart", + """ import 'package:barback/barback.dart'; class MyTransformer extends Transformer { @@ -69,13 +77,17 @@ class MyTransformer extends Transformer { setUp(() async { // Give the test a failing assertion that the transformer will convert to // a passing assertion. - await d.file("test/my_test.dart", """ + await d + .file( + "test/my_test.dart", + """ import 'package:test/test.dart'; void main() { test("test", () => expect(true, isFalse)); } -""").create(); +""") + .create(); }); test("runs those tests in the VM", () async { @@ -191,16 +203,22 @@ void main() { }, tags: 'node'); test("gracefully handles unconfigured transformers", () async { - await d.file("pubspec.yaml", """ + await d + .file( + "pubspec.yaml", + """ name: myapp dependencies: barback: any test: {path: ${p.current}} -""").create(); +""") + .create(); var pub = await runPubServe(); var test = await runTest([_pubServeArg]); - expectStderrEquals(test, ''' + expectStderrEquals( + test, + ''' When using --pub-serve, you must include the "test/pub_serve" transformer in your pubspec: @@ -217,7 +235,9 @@ transformers: group("uses a custom HTML file", () { setUp(() async { await d.dir("test", [ - d.file("test.dart", """ + d.file( + "test.dart", + """ import 'dart:html'; import 'package:test/test.dart'; @@ -228,7 +248,9 @@ void main() { }); } """), - d.file("test.html", """ + d.file( + "test.html", + """ @@ -260,7 +282,10 @@ void main() { group("with a failing test", () { setUp(() async { - await d.file("test/my_test.dart", """ + await d + .file( + "test/my_test.dart", + """ import 'dart:html'; import 'package:test/test.dart'; @@ -268,7 +293,8 @@ import 'package:test/test.dart'; void main() { test("failure", () => throw 'oh no'); } -""").create(); +""") + .create(); }); group("dartifies stack traces for JS-compiled tests by default", () {