From e38374be0d2c3fe0ce73eb1f22a2050aeecd38e8 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 18 Jun 2020 15:26:55 -0700 Subject: [PATCH 01/46] Add back multi server for node platform Fixes #1278 Copy the `_loopback` code from `package:multi_server_socket` but model it as a `List` instead of a single server. Remove the unnecessary arguments for handling anything other than port 0. --- pkgs/test/CHANGELOG.md | 2 + pkgs/test/lib/src/runner/node/platform.dart | 70 ++++++++++++++++++--- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index a732b1bc3..2f9fb66ad 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -2,6 +2,8 @@ * Avoid a confusing stack trace when there is a problem loading a platform when using the JSON reporter and enabling debugging. +* Restore behavior of listening for both `IPv6 and `IPv4` sockets for the node + platform. ## 1.15.0 diff --git a/pkgs/test/lib/src/runner/node/platform.dart b/pkgs/test/lib/src/runner/node/platform.dart index 194e14830..c575cd0fc 100644 --- a/pkgs/test/lib/src/runner/node/platform.dart +++ b/pkgs/test/lib/src/runner/node/platform.dart @@ -99,15 +99,11 @@ class NodePlatform extends PlatformPlugin /// source map for the compiled suite. Future> _loadChannel( String path, Runtime runtime, SuiteConfiguration suiteConfig) async { - ServerSocket server; - try { - server = await ServerSocket.bind(InternetAddress.loopbackIPv6, 0); - } on SocketException { - server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); - } + final servers = await _loopback(); try { - var pair = await _spawnProcess(path, runtime, suiteConfig, server.port); + var pair = + await _spawnProcess(path, runtime, suiteConfig, servers.first.port); var process = pair.first; // Forward Node's standard IO to the print handler so it's associated with @@ -117,7 +113,7 @@ class NodePlatform extends PlatformPlugin process.stdout.transform(lineSplitter).listen(print); process.stderr.transform(lineSplitter).listen(print); - var socket = await server.first; + var socket = await Future.any(servers.map((s) => s.first)); var channel = StreamChannel(socket.cast>(), socket) .transform(StreamChannelTransformer.fromCodec(utf8)) .transform(chunksToLines) @@ -129,7 +125,7 @@ class NodePlatform extends PlatformPlugin return Pair(channel, pair.last); } catch (_) { - unawaited(server.close().catchError((_) {})); + unawaited(Future.wait(servers.map((s) => s.close().catchError((_) {})))); rethrow; } } @@ -300,3 +296,59 @@ class NodePlatform extends PlatformPlugin }); final _closeMemo = AsyncMemoizer(); } + +Future> _loopback({int remainingRetries = 5}) async { + if (!await _supportsIPv4) { + return [await ServerSocket.bind(InternetAddress.loopbackIPv6, 0)]; + } + + var v4Server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); + if (!await _supportsIPv6) return [v4Server]; + + try { + // Reuse the IPv4 server's port so that if [port] is 0, both servers use + // the same ephemeral port. + var v6Server = + await ServerSocket.bind(InternetAddress.loopbackIPv6, v4Server.port); + return [v4Server, v6Server]; + } on SocketException catch (error) { + if (error.osError.errorCode != _addressInUseErrno) rethrow; + if (remainingRetries == 0) rethrow; + + // A port being available on IPv4 doesn't necessarily mean that the same + // port is available on IPv6. If it's not (which is rare in practice), + // we try again until we find one that's available on both. + unawaited(v4Server.close()); + return await _loopback(remainingRetries: remainingRetries - 1); + } +} + +/// Whether this computer supports binding to IPv6 addresses. +final Future _supportsIPv6 = () async { + try { + var socket = await ServerSocket.bind(InternetAddress.loopbackIPv6, 0); + unawaited(socket.close()); + return true; + } on SocketException catch (_) { + return false; + } +}(); + +/// Whether this computer supports binding to IPv4 addresses. +final Future _supportsIPv4 = () async { + try { + var socket = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); + unawaited(socket.close()); + return true; + } on SocketException catch (_) { + return false; + } +}(); + +/// The error code for an error caused by a port already being in use. +final int _addressInUseErrno = () { + if (Platform.isWindows) return 10048; + if (Platform.isMacOS) return 48; + assert(Platform.isLinux); + return 98; +}(); From 6fcd27fa4c6abdfe46b0410b50a43cb366f75ccd Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 18 Jun 2020 15:32:43 -0700 Subject: [PATCH 02/46] Typo --- pkgs/test/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 2f9fb66ad..cd4ab8c38 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -2,7 +2,7 @@ * Avoid a confusing stack trace when there is a problem loading a platform when using the JSON reporter and enabling debugging. -* Restore behavior of listening for both `IPv6 and `IPv4` sockets for the node +* Restore behavior of listening for both `IPv6` and `IPv4` sockets for the node platform. ## 1.15.0 From f355958cfea6ca0001f043ef6ed361aec88e0c25 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 13:22:06 -0700 Subject: [PATCH 03/46] Merge streams instead of calling .first on each --- pkgs/test/lib/src/runner/node/platform.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test/lib/src/runner/node/platform.dart b/pkgs/test/lib/src/runner/node/platform.dart index c575cd0fc..99fd7d473 100644 --- a/pkgs/test/lib/src/runner/node/platform.dart +++ b/pkgs/test/lib/src/runner/node/platform.dart @@ -113,7 +113,7 @@ class NodePlatform extends PlatformPlugin process.stdout.transform(lineSplitter).listen(print); process.stderr.transform(lineSplitter).listen(print); - var socket = await Future.any(servers.map((s) => s.first)); + var socket = await StreamGroup.merge(servers).first; var channel = StreamChannel(socket.cast>(), socket) .transform(StreamChannelTransformer.fromCodec(utf8)) .transform(chunksToLines) From 3cf83d34bfce0d2407f9841c250d39feb5965566 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 13:25:48 -0700 Subject: [PATCH 04/46] Remove hard exit hack See what fails... --- pkgs/test_core/lib/src/executable.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test_core/lib/src/executable.dart b/pkgs/test_core/lib/src/executable.dart index f3749f0bf..0a350eed9 100644 --- a/pkgs/test_core/lib/src/executable.dart +++ b/pkgs/test_core/lib/src/executable.dart @@ -166,7 +166,7 @@ Future _execute(List args) async { // TODO(grouma) - figure out why the executable can hang in the travis // environment. https://github.com/dart-lang/test/issues/599 if (Platform.environment['FORCE_TEST_EXIT'] == 'true') { - exit(exitCode); + // exit(exitCode); } return; From 1db9e9d576607000c702e654c57b5921a79ebac1 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 13:28:34 -0700 Subject: [PATCH 05/46] No analyze and format --- .travis.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb82324fd..aac77db84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,18 +12,6 @@ after_failure: jobs: include: - - stage: analyze_and_format - name: "SDK: 2.7.0; PKGS: pkgs/test, pkgs/test_api, pkgs/test_core; TASKS: `dartanalyzer --fatal-warnings .`" - dart: "2.7.0" - os: linux - env: PKGS="pkgs/test pkgs/test_api pkgs/test_core" - script: ./tool/travis.sh dartanalyzer_1 - - stage: analyze_and_format - name: "SDK: dev; PKGS: pkgs/test, pkgs/test_api, pkgs/test_core; TASKS: [`dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos --fatal-warnings .`]" - dart: dev - os: linux - env: PKGS="pkgs/test pkgs/test_api pkgs/test_core" - script: ./tool/travis.sh dartfmt dartanalyzer_0 - stage: unit_test name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0`" dart: dev @@ -62,7 +50,6 @@ jobs: script: ./tool/travis.sh test stages: - - analyze_and_format - unit_test # Only building master means that we don't run two builds for each pull request. From 58383da027c600f78bb619730b927359b00659ca Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 14:41:10 -0700 Subject: [PATCH 06/46] Use finally block If there is no exception and we never close the servers they can hold the process open. I'm not sure if this fully explains the flakiness on travis... --- pkgs/test/lib/src/runner/node/platform.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/test/lib/src/runner/node/platform.dart b/pkgs/test/lib/src/runner/node/platform.dart index 99fd7d473..a9601ed35 100644 --- a/pkgs/test/lib/src/runner/node/platform.dart +++ b/pkgs/test/lib/src/runner/node/platform.dart @@ -124,9 +124,8 @@ class NodePlatform extends PlatformPlugin })); return Pair(channel, pair.last); - } catch (_) { + } finally { unawaited(Future.wait(servers.map((s) => s.close().catchError((_) {})))); - rethrow; } } From 4431a172cfd7076462dcbc0886e30d7c84554e7a Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 17:29:55 -0700 Subject: [PATCH 07/46] Skip signal tests to see if the flake still shows up --- pkgs/test/test/runner/signal_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test/test/runner/signal_test.dart b/pkgs/test/test/runner/signal_test.dart index 32f69725c..670afb062 100644 --- a/pkgs/test/test/runner/signal_test.dart +++ b/pkgs/test/test/runner/signal_test.dart @@ -4,6 +4,7 @@ // Windows doesn't support sending signals. @TestOn('vm && !windows') +@Skip() // Is this test causing the flakes in Travis? import 'dart:async'; import 'dart:io'; From 9b76490a3f2d59a04f856930bdce33ad93715f42 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 20:02:44 -0700 Subject: [PATCH 08/46] Skip browser loader tests. --- pkgs/test/test/runner/browser/loader_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test/test/runner/browser/loader_test.dart b/pkgs/test/test/runner/browser/loader_test.dart index 84b42d491..3ac473fe8 100644 --- a/pkgs/test/test/runner/browser/loader_test.dart +++ b/pkgs/test/test/runner/browser/loader_test.dart @@ -4,6 +4,7 @@ @TestOn('vm') @Tags(['chrome']) +@Skip() import 'dart:io'; import 'package:path/path.dart' as p; From 98a5cf01df7645e95e37b8d726e8a8a05bdcf22b Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 20:36:57 -0700 Subject: [PATCH 09/46] Skip more browser tests --- pkgs/test/test/runner/browser/chrome_test.dart | 1 + pkgs/test/test/runner/browser/phantom_js_test.dart | 1 + pkgs/test/test/runner/browser/runner_test.dart | 1 + 3 files changed, 3 insertions(+) diff --git a/pkgs/test/test/runner/browser/chrome_test.dart b/pkgs/test/test/runner/browser/chrome_test.dart index a60bdf468..1373da584 100644 --- a/pkgs/test/test/runner/browser/chrome_test.dart +++ b/pkgs/test/test/runner/browser/chrome_test.dart @@ -4,6 +4,7 @@ @TestOn('vm') @Tags(['chrome']) +@Skip() import 'package:test/src/runner/browser/chrome.dart'; import 'package:test/src/runner/executable_settings.dart'; diff --git a/pkgs/test/test/runner/browser/phantom_js_test.dart b/pkgs/test/test/runner/browser/phantom_js_test.dart index f0c4c10e0..492e4aa7d 100644 --- a/pkgs/test/test/runner/browser/phantom_js_test.dart +++ b/pkgs/test/test/runner/browser/phantom_js_test.dart @@ -4,6 +4,7 @@ @TestOn('vm') @Tags(['phantomjs']) +@Skip() import 'package:test/src/runner/browser/phantom_js.dart'; import 'package:test/src/runner/executable_settings.dart'; diff --git a/pkgs/test/test/runner/browser/runner_test.dart b/pkgs/test/test/runner/browser/runner_test.dart index ccd12ce7e..646822637 100644 --- a/pkgs/test/test/runner/browser/runner_test.dart +++ b/pkgs/test/test/runner/browser/runner_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:convert'; import 'package:test_descriptor/test_descriptor.dart' as d; From b49ee013e9950c8d38281dc5edb60f99276a63b1 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 19 Jun 2020 22:00:39 -0700 Subject: [PATCH 10/46] Skip top level tests --- pkgs/test/test/runner/configuration/top_level_error_test.dart | 1 + pkgs/test/test/runner/configuration/top_level_test.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/pkgs/test/test/runner/configuration/top_level_error_test.dart b/pkgs/test/test/runner/configuration/top_level_error_test.dart index eb0835084..87628bc9c 100644 --- a/pkgs/test/test/runner/configuration/top_level_error_test.dart +++ b/pkgs/test/test/runner/configuration/top_level_error_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:convert'; import 'package:test_descriptor/test_descriptor.dart' as d; diff --git a/pkgs/test/test/runner/configuration/top_level_test.dart b/pkgs/test/test/runner/configuration/top_level_test.dart index 5e7208ce2..4e7bb2175 100644 --- a/pkgs/test/test/runner/configuration/top_level_test.dart +++ b/pkgs/test/test/runner/configuration/top_level_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:async'; import 'dart:convert'; From a804ac19e5dd3c23157d0abd9bbf9a139e218120 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Sat, 20 Jun 2020 08:32:36 -0700 Subject: [PATCH 11/46] Skip more --- pkgs/test/test/runner/configuration/custom_platform_test.dart | 1 + pkgs/test/test/runner/pause_after_load_test.dart | 1 + pkgs/test/test/runner/precompiled_test.dart | 1 + 3 files changed, 3 insertions(+) diff --git a/pkgs/test/test/runner/configuration/custom_platform_test.dart b/pkgs/test/test/runner/configuration/custom_platform_test.dart index 5682551b9..e59a3abff 100644 --- a/pkgs/test/test/runner/configuration/custom_platform_test.dart +++ b/pkgs/test/test/runner/configuration/custom_platform_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:io'; diff --git a/pkgs/test/test/runner/pause_after_load_test.dart b/pkgs/test/test/runner/pause_after_load_test.dart index c1cd3157d..87da62aca 100644 --- a/pkgs/test/test/runner/pause_after_load_test.dart +++ b/pkgs/test/test/runner/pause_after_load_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:async'; import 'dart:io'; diff --git a/pkgs/test/test/runner/precompiled_test.dart b/pkgs/test/test/runner/precompiled_test.dart index b324e2d6e..f3acf1903 100644 --- a/pkgs/test/test/runner/precompiled_test.dart +++ b/pkgs/test/test/runner/precompiled_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:async'; import 'dart:io'; import 'dart:isolate'; From f4d36e5f74175a45c074fa98ddee1437d1cbae9f Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Sat, 20 Jun 2020 08:57:43 -0700 Subject: [PATCH 12/46] Skip hybrid test --- pkgs/test/test/runner/hybrid_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index 7c1b0dde3..1c1061096 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +@Skip() import 'dart:io'; import 'dart:isolate'; From 920e6b3744fc537c3f147adbe21ab7e767db2d0f Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Sat, 20 Jun 2020 09:30:30 -0700 Subject: [PATCH 13/46] Unskip everything other than hybrid test --- pkgs/test/test/runner/browser/chrome_test.dart | 1 - pkgs/test/test/runner/browser/loader_test.dart | 1 - pkgs/test/test/runner/browser/phantom_js_test.dart | 1 - pkgs/test/test/runner/browser/runner_test.dart | 1 - pkgs/test/test/runner/configuration/custom_platform_test.dart | 1 - pkgs/test/test/runner/configuration/top_level_error_test.dart | 1 - pkgs/test/test/runner/configuration/top_level_test.dart | 1 - pkgs/test/test/runner/pause_after_load_test.dart | 1 - pkgs/test/test/runner/precompiled_test.dart | 1 - pkgs/test/test/runner/signal_test.dart | 1 - 10 files changed, 10 deletions(-) diff --git a/pkgs/test/test/runner/browser/chrome_test.dart b/pkgs/test/test/runner/browser/chrome_test.dart index 1373da584..a60bdf468 100644 --- a/pkgs/test/test/runner/browser/chrome_test.dart +++ b/pkgs/test/test/runner/browser/chrome_test.dart @@ -4,7 +4,6 @@ @TestOn('vm') @Tags(['chrome']) -@Skip() import 'package:test/src/runner/browser/chrome.dart'; import 'package:test/src/runner/executable_settings.dart'; diff --git a/pkgs/test/test/runner/browser/loader_test.dart b/pkgs/test/test/runner/browser/loader_test.dart index 3ac473fe8..84b42d491 100644 --- a/pkgs/test/test/runner/browser/loader_test.dart +++ b/pkgs/test/test/runner/browser/loader_test.dart @@ -4,7 +4,6 @@ @TestOn('vm') @Tags(['chrome']) -@Skip() import 'dart:io'; import 'package:path/path.dart' as p; diff --git a/pkgs/test/test/runner/browser/phantom_js_test.dart b/pkgs/test/test/runner/browser/phantom_js_test.dart index 492e4aa7d..f0c4c10e0 100644 --- a/pkgs/test/test/runner/browser/phantom_js_test.dart +++ b/pkgs/test/test/runner/browser/phantom_js_test.dart @@ -4,7 +4,6 @@ @TestOn('vm') @Tags(['phantomjs']) -@Skip() import 'package:test/src/runner/browser/phantom_js.dart'; import 'package:test/src/runner/executable_settings.dart'; diff --git a/pkgs/test/test/runner/browser/runner_test.dart b/pkgs/test/test/runner/browser/runner_test.dart index 646822637..ccd12ce7e 100644 --- a/pkgs/test/test/runner/browser/runner_test.dart +++ b/pkgs/test/test/runner/browser/runner_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:convert'; import 'package:test_descriptor/test_descriptor.dart' as d; diff --git a/pkgs/test/test/runner/configuration/custom_platform_test.dart b/pkgs/test/test/runner/configuration/custom_platform_test.dart index e59a3abff..5682551b9 100644 --- a/pkgs/test/test/runner/configuration/custom_platform_test.dart +++ b/pkgs/test/test/runner/configuration/custom_platform_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:io'; diff --git a/pkgs/test/test/runner/configuration/top_level_error_test.dart b/pkgs/test/test/runner/configuration/top_level_error_test.dart index 87628bc9c..eb0835084 100644 --- a/pkgs/test/test/runner/configuration/top_level_error_test.dart +++ b/pkgs/test/test/runner/configuration/top_level_error_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:convert'; import 'package:test_descriptor/test_descriptor.dart' as d; diff --git a/pkgs/test/test/runner/configuration/top_level_test.dart b/pkgs/test/test/runner/configuration/top_level_test.dart index 4e7bb2175..5e7208ce2 100644 --- a/pkgs/test/test/runner/configuration/top_level_test.dart +++ b/pkgs/test/test/runner/configuration/top_level_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:async'; import 'dart:convert'; diff --git a/pkgs/test/test/runner/pause_after_load_test.dart b/pkgs/test/test/runner/pause_after_load_test.dart index 87da62aca..c1cd3157d 100644 --- a/pkgs/test/test/runner/pause_after_load_test.dart +++ b/pkgs/test/test/runner/pause_after_load_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:async'; import 'dart:io'; diff --git a/pkgs/test/test/runner/precompiled_test.dart b/pkgs/test/test/runner/precompiled_test.dart index f3acf1903..b324e2d6e 100644 --- a/pkgs/test/test/runner/precompiled_test.dart +++ b/pkgs/test/test/runner/precompiled_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:async'; import 'dart:io'; import 'dart:isolate'; diff --git a/pkgs/test/test/runner/signal_test.dart b/pkgs/test/test/runner/signal_test.dart index 670afb062..32f69725c 100644 --- a/pkgs/test/test/runner/signal_test.dart +++ b/pkgs/test/test/runner/signal_test.dart @@ -4,7 +4,6 @@ // Windows doesn't support sending signals. @TestOn('vm && !windows') -@Skip() // Is this test causing the flakes in Travis? import 'dart:async'; import 'dart:io'; From f7e3c221279164318ec8f05c39e35ec8bd94e811 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Sat, 20 Jun 2020 12:32:48 -0700 Subject: [PATCH 14/46] Unskip - verify the flakes resurface --- pkgs/test/test/runner/hybrid_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index 1c1061096..7c1b0dde3 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Skip() import 'dart:io'; import 'dart:isolate'; From 9bf24fd2c7a428a33a293fa2686b0172f71addf9 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 18:30:32 -0700 Subject: [PATCH 15/46] Try running just the hybrid tests --- .travis.yml | 20 ++++++++++---------- pkgs/test/mono_pkg.yaml | 10 +++++----- tool/travis.sh | 22 +++------------------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index aac77db84..95dcef73d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,35 +13,35 @@ after_failure: jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_0 + script: ./tool/travis.sh command - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_1 + script: ./tool/travis.sh command - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_2 + script: ./tool/travis.sh command - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_3 + script: ./tool/travis.sh command - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_4 + script: ./tool/travis.sh command - stage: unit_test name: "SDK: dev; PKG: pkgs/test_api; TASKS: `pub run test --preset travis`" dart: dev diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index ef401afd8..ff00bda7a 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -11,8 +11,8 @@ stages: - dartanalyzer: --fatal-warnings . dart: 2.7.0 - unit_test: - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart diff --git a/tool/travis.sh b/tool/travis.sh index 7ac5921af..ca6deb81b 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -54,25 +54,9 @@ for PKG in ${PKGS}; do echo echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in - command_0) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 0 || EXIT_CODE=$? - ;; - command_1) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 1 || EXIT_CODE=$? - ;; - command_2) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 2 || EXIT_CODE=$? - ;; - command_3) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 3 || EXIT_CODE=$? - ;; - command_4) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis -x phantomjs --total-shards 5 --shard-index 4 || EXIT_CODE=$? + command) + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart || EXIT_CODE=$? ;; dartanalyzer_0) echo 'dartanalyzer --fatal-infos --fatal-warnings .' From 08df8506a3661af05233f3692c8cd38d083c3b54 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 18:37:44 -0700 Subject: [PATCH 16/46] Keep sharding --- .travis.yml | 20 ++++++++++---------- pkgs/test/mono_pkg.yaml | 10 +++++----- tool/travis.sh | 22 +++++++++++++++++++--- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95dcef73d..f327563c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,35 +13,35 @@ after_failure: jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command + script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command + script: ./tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command + script: ./tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command + script: ./tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command + script: ./tool/travis.sh command_4 - stage: unit_test name: "SDK: dev; PKG: pkgs/test_api; TASKS: `pub run test --preset travis`" dart: dev diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index ff00bda7a..e766df8f7 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -11,8 +11,8 @@ stages: - dartanalyzer: --fatal-warnings . dart: 2.7.0 - unit_test: - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 diff --git a/tool/travis.sh b/tool/travis.sh index ca6deb81b..2e9c5d320 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -54,9 +54,25 @@ for PKG in ${PKGS}; do echo echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in - command) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart || EXIT_CODE=$? + command_0) + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 || EXIT_CODE=$? + ;; + command_1) + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 || EXIT_CODE=$? + ;; + command_2) + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 || EXIT_CODE=$? + ;; + command_3) + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 || EXIT_CODE=$? + ;; + command_4) + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 || EXIT_CODE=$? ;; dartanalyzer_0) echo 'dartanalyzer --fatal-infos --fatal-warnings .' From 66a078e6f3b2be8dfe644e54316005d20c262dd2 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 18:42:32 -0700 Subject: [PATCH 17/46] Skip test_api tests --- .travis.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f327563c7..fc27879a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ jobs: env: PKGS="pkgs/test" script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1`"t dart: dev os: linux env: PKGS="pkgs/test" @@ -42,12 +42,6 @@ jobs: os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_4 - - stage: unit_test - name: "SDK: dev; PKG: pkgs/test_api; TASKS: `pub run test --preset travis`" - dart: dev - os: linux - env: PKGS="pkgs/test_api" - script: ./tool/travis.sh test stages: - unit_test From 671417a7db07cf9985e290f51976410376c43246 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 18:52:18 -0700 Subject: [PATCH 18/46] Expanded reporter --- .travis.yml | 10 +++++----- pkgs/test/mono_pkg.yaml | 10 +++++----- tool/travis.sh | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc27879a2..c071a7180 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,31 +13,31 @@ after_failure: jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1`"t + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded`" dart: dev os: linux env: PKGS="pkgs/test" diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index e766df8f7..47bf27679 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -11,8 +11,8 @@ stages: - dartanalyzer: --fatal-warnings . dart: 2.7.0 - unit_test: - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded diff --git a/tool/travis.sh b/tool/travis.sh index 2e9c5d320..7f74b6e41 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -55,24 +55,24 @@ for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in command_0) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded || EXIT_CODE=$? ;; command_1) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded || EXIT_CODE=$? ;; command_2) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded || EXIT_CODE=$? ;; command_3) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded || EXIT_CODE=$? ;; command_4) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded || EXIT_CODE=$? ;; dartanalyzer_0) echo 'dartanalyzer --fatal-infos --fatal-warnings .' From 96c75dcd616d13cf25580a3198389203d955b9bb Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 19:17:39 -0700 Subject: [PATCH 19/46] Remove some test cases --- pkgs/test/test/runner/hybrid_test.dart | 409 ------------------------- 1 file changed, 409 deletions(-) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index 7c1b0dde3..cd59c1ba6 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -4,9 +4,6 @@ @TestOn('vm') -import 'dart:io'; -import 'dart:isolate'; - import 'package:path/path.dart' as p; import 'package:test_descriptor/test_descriptor.dart' as d; @@ -15,37 +12,7 @@ import 'package:test/test.dart'; import '../io.dart'; void main() { - String packageRoot; - setUpAll(() async { - packageRoot = p.absolute(p.dirname(p - .fromUri(await Isolate.resolvePackageUri(Uri.parse('package:test/'))))); - }); - - group('spawnHybridUri():', () { - group('in the VM', () { - _spawnHybridUriTests(); - }); - - group('in the browser', () { - _spawnHybridUriTests(['-p', 'chrome']); - }, tags: 'chrome'); - - group('in Node.js', () { - _spawnHybridUriTests(['-p', 'node']); - }, tags: 'node'); - }); - group('spawnHybridCode()', () { - test('loads the code in a separate isolate connected via StreamChannel', - () { - expect(spawnHybridCode(''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink..add(1)..add(2)..add(3)..close(); - } - ''').stream.toList(), completion(equals([1, 2, 3]))); - }); test('can use dart:io even when run from a browser', () async { var path = p.join(d.sandbox, 'test.dart'); @@ -207,381 +174,5 @@ void main() { await test.shouldExit(0); }, tags: ['chrome']); - test('gracefully handles an unserializable message in the hybrid isolate', - () { - var channel = spawnHybridCode(''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink.add([].iterator); - } - '''); - - channel.stream.listen(null, onError: expectAsync1((error) { - expect(error.toString(), contains("can't be JSON-encoded.")); - })); - }); - - test('forwards prints from the hybrid isolate', () { - expect(() async { - var channel = spawnHybridCode(''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - print("hi!"); - channel.sink.add(null); - } - '''); - await channel.stream.first; - }, prints('hi!\n')); - }); - - // This takes special handling, since the code is packed into a data: URI - // that's imported, URIs don't escape $ by default, and $ isn't allowed in - // imports. - test('supports a dollar character in the hybrid code', () { - expect(spawnHybridCode(r''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - var value = "bar"; - channel.sink.add("foo${value}baz"); - } - ''').stream.first, completion('foobarbaz')); - }); - - test('kills the isolate when the test closes the channel', () async { - var channel = spawnHybridCode(''' - import "dart:async"; - import "dart:io"; - - import "package:shelf/shelf.dart" as shelf; - import "package:shelf/shelf_io.dart" as io; - import "package:stream_channel/stream_channel.dart"; - - hybridMain(StreamChannel channel) async { - var server = await ServerSocket.bind("localhost", 0); - server.listen(null); - channel.sink.add(server.port); - } - '''); - - // Expect that the socket disconnects at some point (presumably when the - // isolate closes). - var port = await channel.stream.first as int; - var socket = await Socket.connect('localhost', port); - expect(socket.listen(null).asFuture(), completes); - - await channel.sink.close(); - }, skip: 'Enable when sdk#28081 is fixed.'); - - test('kills the isolate when the hybrid isolate closes the channel', - () async { - var channel = spawnHybridCode(''' - import "dart:async"; - import "dart:io"; - - import "package:stream_channel/stream_channel.dart"; - - hybridMain(StreamChannel channel) async { - var server = await ServerSocket.bind("localhost", 0); - server.listen(null); - channel.sink.add(server.port); - await channel.stream.first; - channel.sink.close(); - } - '''); - - // Expect that the socket disconnects at some point (presumably when the - // isolate closes). - var port = await channel.stream.first as int; - var socket = await Socket.connect('localhost', port); - expect(socket.listen(null).asFuture(), completes); - channel.sink.add(null); - }, skip: 'Enable when sdk#28081 is fixed.'); - - test('closes the channel when the hybrid isolate exits', () { - var channel = spawnHybridCode(''' - import "dart:isolate"; - - hybridMain(_) { - Isolate.current.kill(); - } - '''); - - expect(channel.stream.toList(), completion(isEmpty)); - }); - - test('closes the channel when the test finishes by default', () async { - await d.file('test.dart', ''' - import "package:stream_channel/stream_channel.dart"; - import "package:test/test.dart"; - - import "${p.toUri(packageRoot)}/test/utils.dart"; - - void main() { - StreamChannel channel; - test("test 1", () { - channel = spawnHybridCode(""" - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) {} - """); - }); - - test("test 2", () async { - var isDone = false; - channel.stream.listen(null, onDone: () => isDone = true); - await pumpEventQueue(); - expect(isDone, isTrue); - }); - } - ''').create(); - - var test = await runTest(['test.dart']); - expect( - test.stdout, - containsInOrder( - ['+0: test 1', '+1: test 2', '+2: All tests passed!'])); - await test.shouldExit(0); - }); - - test('persists across multiple tests with stayAlive: true', () async { - await d.file('test.dart', ''' - import "dart:async"; - - import "package:async/async.dart"; - import "package:stream_channel/stream_channel.dart"; - - import "package:test/test.dart"; - - void main() { - StreamQueue queue; - StreamSink sink; - setUpAll(() { - var channel = spawnHybridCode(""" - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.stream.listen((message) { - channel.sink.add(message); - }); - } - """, stayAlive: true); - queue = StreamQueue(channel.stream); - sink = channel.sink; - }); - - test("echoes a number", () { - expect(queue.next, completion(equals(123))); - sink.add(123); - }); - - test("echoes a string", () { - expect(queue.next, completion(equals("wow"))); - sink.add("wow"); - }); - } - ''').create(); - - var test = await runTest(['test.dart']); - expect( - test.stdout, - containsInOrder([ - '+0: echoes a number', - '+1: echoes a string', - '+2: All tests passed!' - ])); - await test.shouldExit(0); - }); - }); -} - -/// Defines tests for `spawnHybridUri()`. -/// -/// If [arguments] is given, it's passed on to the invocation of the test -/// runner. -void _spawnHybridUriTests([Iterable arguments]) { - arguments ??= []; - - test('loads a file in a separate isolate connected via StreamChannel', - () async { - await d.file('test.dart', ''' - import "package:test/test.dart"; - - void main() { - test("hybrid emits numbers", () { - expect(spawnHybridUri("hybrid.dart").stream.toList(), - completion(equals([1, 2, 3]))); - }); - } - ''').create(); - - await d.file('hybrid.dart', ''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink..add(1)..add(2)..add(3)..close(); - } - ''').create(); - - var test = await runTest(['test.dart', ...arguments]); - expect(test.stdout, - containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); - await test.shouldExit(0); - }); - - test('resolves URIs relative to the test file', () async { - await d.dir('test/dir/subdir', [ - d.file('test.dart', ''' - import "package:test/test.dart"; - - void main() { - test("hybrid emits numbers", () { - expect(spawnHybridUri("hybrid.dart").stream.toList(), - completion(equals([1, 2, 3]))); - }); - } - '''), - d.file('hybrid.dart', ''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink..add(1)..add(2)..add(3)..close(); - } - '''), - ]).create(); - - var test = await runTest(['test/dir/subdir/test.dart', ...arguments]); - expect(test.stdout, - containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); - await test.shouldExit(0); - }); - - test('resolves root-relative URIs relative to the package root', () async { - await d.dir('test/dir/subdir', [ - d.file('test.dart', ''' - import "package:test/test.dart"; - - void main() { - test("hybrid emits numbers", () { - expect( - spawnHybridUri("/test/dir/subdir/hybrid.dart") - .stream.toList(), - completion(equals([1, 2, 3]))); - }); - } - '''), - d.file('hybrid.dart', ''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink..add(1)..add(2)..add(3)..close(); - } - '''), - ]).create(); - - var test = await runTest(['test/dir/subdir/test.dart', ...arguments]); - expect(test.stdout, - containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); - await test.shouldExit(0); - }); - - test('supports absolute file: URIs', () async { - var url = p.toUri(p.absolute(p.join(d.sandbox, 'hybrid.dart'))); - await d.file('test.dart', ''' - import "package:test/test.dart"; - - void main() { - test("hybrid emits numbers", () { - expect(spawnHybridUri("$url").stream.toList(), - completion(equals([1, 2, 3]))); - }); - } - ''').create(); - - await d.file('hybrid.dart', ''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink..add(1)..add(2)..add(3)..close(); - } - ''').create(); - - var test = await runTest(['test.dart', ...arguments]); - expect(test.stdout, - containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); - await test.shouldExit(0); - }); - - test('supports Uri objects', () async { - await d.file('test.dart', ''' - import "package:test/test.dart"; - - void main() { - test("hybrid emits numbers", () { - expect(spawnHybridUri(Uri.parse("hybrid.dart")).stream.toList(), - completion(equals([1, 2, 3]))); - }); - } - ''').create(); - - await d.file('hybrid.dart', ''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel) { - channel.sink..add(1)..add(2)..add(3)..close(); - } - ''').create(); - - var test = await runTest(['test.dart', ...arguments]); - expect(test.stdout, - containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); - await test.shouldExit(0); - }); - - test('rejects non-String, non-Uri objects', () { - expect(() => spawnHybridUri(123), throwsArgumentError); - }); - - test('passes a message to the hybrid isolate', () async { - await d.file('test.dart', ''' - import "package:test/test.dart"; - - void main() { - test("hybrid echoes message", () { - expect( - spawnHybridUri(Uri.parse("hybrid.dart"), message: 123) - .stream.first, - completion(equals(123))); - - expect( - spawnHybridUri(Uri.parse("hybrid.dart"), message: "wow") - .stream.first, - completion(equals("wow"))); - }); - } - ''').create(); - - await d.file('hybrid.dart', ''' - import "package:stream_channel/stream_channel.dart"; - - void hybridMain(StreamChannel channel, Object message) { - channel.sink..add(message)..close(); - } - ''').create(); - - var test = await runTest(['test.dart', ...arguments]); - expect( - test.stdout, - containsInOrder( - ['+0: hybrid echoes message', '+1: All tests passed!'])); - await test.shouldExit(0); - }); - - test('emits an error from the stream channel if the isolate fails to load', - () { - expect(spawnHybridUri('non existent file').stream.first, - throwsA(TypeMatcher())); }); } From 11a9bd9ffa15d4917b1f506eaf13fd37d4d156c5 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 19:29:23 -0700 Subject: [PATCH 20/46] Run the same shard multiple times --- .travis.yml | 10 +- pkgs/test/mono_pkg.yaml | 10 +- pkgs/test/test/runner/hybrid_test.dart | 409 +++++++++++++++++++++++++ tool/travis.sh | 20 +- 4 files changed, 429 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index c071a7180..a38a941d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,31 +13,31 @@ after_failure: jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" dart: dev os: linux env: PKGS="pkgs/test" diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index 47bf27679..7430426f3 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -11,8 +11,8 @@ stages: - dartanalyzer: --fatal-warnings . dart: 2.7.0 - unit_test: - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index cd59c1ba6..7c1b0dde3 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -4,6 +4,9 @@ @TestOn('vm') +import 'dart:io'; +import 'dart:isolate'; + import 'package:path/path.dart' as p; import 'package:test_descriptor/test_descriptor.dart' as d; @@ -12,7 +15,37 @@ import 'package:test/test.dart'; import '../io.dart'; void main() { + String packageRoot; + setUpAll(() async { + packageRoot = p.absolute(p.dirname(p + .fromUri(await Isolate.resolvePackageUri(Uri.parse('package:test/'))))); + }); + + group('spawnHybridUri():', () { + group('in the VM', () { + _spawnHybridUriTests(); + }); + + group('in the browser', () { + _spawnHybridUriTests(['-p', 'chrome']); + }, tags: 'chrome'); + + group('in Node.js', () { + _spawnHybridUriTests(['-p', 'node']); + }, tags: 'node'); + }); + group('spawnHybridCode()', () { + test('loads the code in a separate isolate connected via StreamChannel', + () { + expect(spawnHybridCode(''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink..add(1)..add(2)..add(3)..close(); + } + ''').stream.toList(), completion(equals([1, 2, 3]))); + }); test('can use dart:io even when run from a browser', () async { var path = p.join(d.sandbox, 'test.dart'); @@ -174,5 +207,381 @@ void main() { await test.shouldExit(0); }, tags: ['chrome']); + test('gracefully handles an unserializable message in the hybrid isolate', + () { + var channel = spawnHybridCode(''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink.add([].iterator); + } + '''); + + channel.stream.listen(null, onError: expectAsync1((error) { + expect(error.toString(), contains("can't be JSON-encoded.")); + })); + }); + + test('forwards prints from the hybrid isolate', () { + expect(() async { + var channel = spawnHybridCode(''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + print("hi!"); + channel.sink.add(null); + } + '''); + await channel.stream.first; + }, prints('hi!\n')); + }); + + // This takes special handling, since the code is packed into a data: URI + // that's imported, URIs don't escape $ by default, and $ isn't allowed in + // imports. + test('supports a dollar character in the hybrid code', () { + expect(spawnHybridCode(r''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + var value = "bar"; + channel.sink.add("foo${value}baz"); + } + ''').stream.first, completion('foobarbaz')); + }); + + test('kills the isolate when the test closes the channel', () async { + var channel = spawnHybridCode(''' + import "dart:async"; + import "dart:io"; + + import "package:shelf/shelf.dart" as shelf; + import "package:shelf/shelf_io.dart" as io; + import "package:stream_channel/stream_channel.dart"; + + hybridMain(StreamChannel channel) async { + var server = await ServerSocket.bind("localhost", 0); + server.listen(null); + channel.sink.add(server.port); + } + '''); + + // Expect that the socket disconnects at some point (presumably when the + // isolate closes). + var port = await channel.stream.first as int; + var socket = await Socket.connect('localhost', port); + expect(socket.listen(null).asFuture(), completes); + + await channel.sink.close(); + }, skip: 'Enable when sdk#28081 is fixed.'); + + test('kills the isolate when the hybrid isolate closes the channel', + () async { + var channel = spawnHybridCode(''' + import "dart:async"; + import "dart:io"; + + import "package:stream_channel/stream_channel.dart"; + + hybridMain(StreamChannel channel) async { + var server = await ServerSocket.bind("localhost", 0); + server.listen(null); + channel.sink.add(server.port); + await channel.stream.first; + channel.sink.close(); + } + '''); + + // Expect that the socket disconnects at some point (presumably when the + // isolate closes). + var port = await channel.stream.first as int; + var socket = await Socket.connect('localhost', port); + expect(socket.listen(null).asFuture(), completes); + channel.sink.add(null); + }, skip: 'Enable when sdk#28081 is fixed.'); + + test('closes the channel when the hybrid isolate exits', () { + var channel = spawnHybridCode(''' + import "dart:isolate"; + + hybridMain(_) { + Isolate.current.kill(); + } + '''); + + expect(channel.stream.toList(), completion(isEmpty)); + }); + + test('closes the channel when the test finishes by default', () async { + await d.file('test.dart', ''' + import "package:stream_channel/stream_channel.dart"; + import "package:test/test.dart"; + + import "${p.toUri(packageRoot)}/test/utils.dart"; + + void main() { + StreamChannel channel; + test("test 1", () { + channel = spawnHybridCode(""" + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) {} + """); + }); + + test("test 2", () async { + var isDone = false; + channel.stream.listen(null, onDone: () => isDone = true); + await pumpEventQueue(); + expect(isDone, isTrue); + }); + } + ''').create(); + + var test = await runTest(['test.dart']); + expect( + test.stdout, + containsInOrder( + ['+0: test 1', '+1: test 2', '+2: All tests passed!'])); + await test.shouldExit(0); + }); + + test('persists across multiple tests with stayAlive: true', () async { + await d.file('test.dart', ''' + import "dart:async"; + + import "package:async/async.dart"; + import "package:stream_channel/stream_channel.dart"; + + import "package:test/test.dart"; + + void main() { + StreamQueue queue; + StreamSink sink; + setUpAll(() { + var channel = spawnHybridCode(""" + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.stream.listen((message) { + channel.sink.add(message); + }); + } + """, stayAlive: true); + queue = StreamQueue(channel.stream); + sink = channel.sink; + }); + + test("echoes a number", () { + expect(queue.next, completion(equals(123))); + sink.add(123); + }); + + test("echoes a string", () { + expect(queue.next, completion(equals("wow"))); + sink.add("wow"); + }); + } + ''').create(); + + var test = await runTest(['test.dart']); + expect( + test.stdout, + containsInOrder([ + '+0: echoes a number', + '+1: echoes a string', + '+2: All tests passed!' + ])); + await test.shouldExit(0); + }); + }); +} + +/// Defines tests for `spawnHybridUri()`. +/// +/// If [arguments] is given, it's passed on to the invocation of the test +/// runner. +void _spawnHybridUriTests([Iterable arguments]) { + arguments ??= []; + + test('loads a file in a separate isolate connected via StreamChannel', + () async { + await d.file('test.dart', ''' + import "package:test/test.dart"; + + void main() { + test("hybrid emits numbers", () { + expect(spawnHybridUri("hybrid.dart").stream.toList(), + completion(equals([1, 2, 3]))); + }); + } + ''').create(); + + await d.file('hybrid.dart', ''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink..add(1)..add(2)..add(3)..close(); + } + ''').create(); + + var test = await runTest(['test.dart', ...arguments]); + expect(test.stdout, + containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); + await test.shouldExit(0); + }); + + test('resolves URIs relative to the test file', () async { + await d.dir('test/dir/subdir', [ + d.file('test.dart', ''' + import "package:test/test.dart"; + + void main() { + test("hybrid emits numbers", () { + expect(spawnHybridUri("hybrid.dart").stream.toList(), + completion(equals([1, 2, 3]))); + }); + } + '''), + d.file('hybrid.dart', ''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink..add(1)..add(2)..add(3)..close(); + } + '''), + ]).create(); + + var test = await runTest(['test/dir/subdir/test.dart', ...arguments]); + expect(test.stdout, + containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); + await test.shouldExit(0); + }); + + test('resolves root-relative URIs relative to the package root', () async { + await d.dir('test/dir/subdir', [ + d.file('test.dart', ''' + import "package:test/test.dart"; + + void main() { + test("hybrid emits numbers", () { + expect( + spawnHybridUri("/test/dir/subdir/hybrid.dart") + .stream.toList(), + completion(equals([1, 2, 3]))); + }); + } + '''), + d.file('hybrid.dart', ''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink..add(1)..add(2)..add(3)..close(); + } + '''), + ]).create(); + + var test = await runTest(['test/dir/subdir/test.dart', ...arguments]); + expect(test.stdout, + containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); + await test.shouldExit(0); + }); + + test('supports absolute file: URIs', () async { + var url = p.toUri(p.absolute(p.join(d.sandbox, 'hybrid.dart'))); + await d.file('test.dart', ''' + import "package:test/test.dart"; + + void main() { + test("hybrid emits numbers", () { + expect(spawnHybridUri("$url").stream.toList(), + completion(equals([1, 2, 3]))); + }); + } + ''').create(); + + await d.file('hybrid.dart', ''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink..add(1)..add(2)..add(3)..close(); + } + ''').create(); + + var test = await runTest(['test.dart', ...arguments]); + expect(test.stdout, + containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); + await test.shouldExit(0); + }); + + test('supports Uri objects', () async { + await d.file('test.dart', ''' + import "package:test/test.dart"; + + void main() { + test("hybrid emits numbers", () { + expect(spawnHybridUri(Uri.parse("hybrid.dart")).stream.toList(), + completion(equals([1, 2, 3]))); + }); + } + ''').create(); + + await d.file('hybrid.dart', ''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel) { + channel.sink..add(1)..add(2)..add(3)..close(); + } + ''').create(); + + var test = await runTest(['test.dart', ...arguments]); + expect(test.stdout, + containsInOrder(['+0: hybrid emits numbers', '+1: All tests passed!'])); + await test.shouldExit(0); + }); + + test('rejects non-String, non-Uri objects', () { + expect(() => spawnHybridUri(123), throwsArgumentError); + }); + + test('passes a message to the hybrid isolate', () async { + await d.file('test.dart', ''' + import "package:test/test.dart"; + + void main() { + test("hybrid echoes message", () { + expect( + spawnHybridUri(Uri.parse("hybrid.dart"), message: 123) + .stream.first, + completion(equals(123))); + + expect( + spawnHybridUri(Uri.parse("hybrid.dart"), message: "wow") + .stream.first, + completion(equals("wow"))); + }); + } + ''').create(); + + await d.file('hybrid.dart', ''' + import "package:stream_channel/stream_channel.dart"; + + void hybridMain(StreamChannel channel, Object message) { + channel.sink..add(message)..close(); + } + ''').create(); + + var test = await runTest(['test.dart', ...arguments]); + expect( + test.stdout, + containsInOrder( + ['+0: hybrid echoes message', '+1: All tests passed!'])); + await test.shouldExit(0); + }); + + test('emits an error from the stream channel if the isolate fails to load', + () { + expect(spawnHybridUri('non existent file').stream.first, + throwsA(TypeMatcher())); }); } diff --git a/tool/travis.sh b/tool/travis.sh index 7f74b6e41..598223469 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -55,24 +55,24 @@ for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in command_0) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 0 -r expanded || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 || EXIT_CODE=$? ;; command_1) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 1 -r expanded || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 || EXIT_CODE=$? ;; command_2) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 2 -r expanded || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 || EXIT_CODE=$? ;; command_3) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 || EXIT_CODE=$? ;; command_4) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 4 -r expanded || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5' + xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 || EXIT_CODE=$? ;; dartanalyzer_0) echo 'dartanalyzer --fatal-infos --fatal-warnings .' From 66c7d4e09e5fc7409ec19c5973cd92f8a6697f82 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 19:41:34 -0700 Subject: [PATCH 21/46] Skip the chrome ones --- pkgs/test/test/runner/hybrid_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index 7c1b0dde3..fe1d24e66 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -75,7 +75,7 @@ void main() { containsInOrder( ['+0: hybrid loads dart:io', '+1: All tests passed!'])); await test.shouldExit(0); - }, tags: ['chrome']); + }, tags: ['chrome'], skip: 'browser?'); test('forwards data from the test to the hybrid isolate', () async { var channel = spawnHybridCode(''' @@ -205,7 +205,7 @@ void main() { containsInOrder( ['+0: invalid message to hybrid', '+1: All tests passed!'])); await test.shouldExit(0); - }, tags: ['chrome']); + }, tags: ['chrome'], skip: 'browser?'); test('gracefully handles an unserializable message in the hybrid isolate', () { From 8f8422121ed8297347457018b855833dd17fcfe1 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 19:45:07 -0700 Subject: [PATCH 22/46] Skip non-chrome ones --- pkgs/test/test/runner/hybrid_test.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index fe1d24e66..0748de176 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -75,7 +75,7 @@ void main() { containsInOrder( ['+0: hybrid loads dart:io', '+1: All tests passed!'])); await test.shouldExit(0); - }, tags: ['chrome'], skip: 'browser?'); + }, tags: ['chrome']); test('forwards data from the test to the hybrid isolate', () async { var channel = spawnHybridCode(''' @@ -89,7 +89,7 @@ void main() { '''); channel.sink..add(1)..add(2)..add(3); expect(channel.stream.take(3).toList(), completion(equals([2, 3, 4]))); - }); + }, skip: 'Non-browser?'); test('passes an initial message to the hybrid isolate', () { var code = ''' @@ -104,7 +104,7 @@ void main() { completion(equals([1, 2, 3]))); expect(spawnHybridCode(code, message: {'a': 'b'}).stream.first, completion(equals({'a': 'b'}))); - }); + }, skip: 'Non-browser?'); test('allows the hybrid isolate to send errors across the stream channel', () { @@ -121,7 +121,7 @@ void main() { expect(error.toString(), equals('oh no!')); expect(stackTrace.toString(), contains('hybridMain')); })); - }); + }, skip: 'Non-browser?'); test('sends an unhandled synchronous error across the stream channel', () { var channel = spawnHybridCode(''' @@ -136,7 +136,7 @@ void main() { expect(error.toString(), equals('oh no!')); expect(stackTrace.toString(), contains('hybridMain')); })); - }); + }, skip: 'Non-browser?'); test('sends an unhandled asynchronous error across the stream channel', () { var channel = spawnHybridCode(''' @@ -155,7 +155,7 @@ void main() { expect(error.toString(), equals('oh no!')); expect(stackTrace.toString(), contains('hybridMain')); })); - }); + }, skip: 'Non-browser?'); test('deserializes TestFailures as TestFailures', () { var channel = spawnHybridCode(''' @@ -169,7 +169,7 @@ void main() { '''); expect(channel.stream.first, throwsA(TypeMatcher())); - }); + }, skip: 'Non-browser?'); test('gracefully handles an unserializable message in the VM', () { var channel = spawnHybridCode(''' @@ -179,7 +179,7 @@ void main() { '''); expect(() => channel.sink.add([].iterator), throwsArgumentError); - }); + }, skip: 'Non-browser?'); test('gracefully handles an unserializable message in the browser', () async { @@ -205,7 +205,7 @@ void main() { containsInOrder( ['+0: invalid message to hybrid', '+1: All tests passed!'])); await test.shouldExit(0); - }, tags: ['chrome'], skip: 'browser?'); + }, tags: ['chrome']); test('gracefully handles an unserializable message in the hybrid isolate', () { From 5adc1932b830930d40b467537bf47ee83809de7a Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 20:15:51 -0700 Subject: [PATCH 23/46] Both serialization error tests --- pkgs/test/test/runner/hybrid_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index 0748de176..473c3aede 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -45,7 +45,7 @@ void main() { channel.sink..add(1)..add(2)..add(3)..close(); } ''').stream.toList(), completion(equals([1, 2, 3]))); - }); + }, skip: 'only serialization error'); test('can use dart:io even when run from a browser', () async { var path = p.join(d.sandbox, 'test.dart'); @@ -75,7 +75,7 @@ void main() { containsInOrder( ['+0: hybrid loads dart:io', '+1: All tests passed!'])); await test.shouldExit(0); - }, tags: ['chrome']); + }, tags: ['chrome'], skip: 'only serialization error'); test('forwards data from the test to the hybrid isolate', () async { var channel = spawnHybridCode(''' @@ -179,7 +179,7 @@ void main() { '''); expect(() => channel.sink.add([].iterator), throwsArgumentError); - }, skip: 'Non-browser?'); + }); test('gracefully handles an unserializable message in the browser', () async { From d93ab230f711d701a4021232f53b0052a26050fe Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 21:00:17 -0700 Subject: [PATCH 24/46] Unskip tests --- pkgs/test/test/runner/hybrid_test.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/test/test/runner/hybrid_test.dart b/pkgs/test/test/runner/hybrid_test.dart index 473c3aede..7c1b0dde3 100644 --- a/pkgs/test/test/runner/hybrid_test.dart +++ b/pkgs/test/test/runner/hybrid_test.dart @@ -45,7 +45,7 @@ void main() { channel.sink..add(1)..add(2)..add(3)..close(); } ''').stream.toList(), completion(equals([1, 2, 3]))); - }, skip: 'only serialization error'); + }); test('can use dart:io even when run from a browser', () async { var path = p.join(d.sandbox, 'test.dart'); @@ -75,7 +75,7 @@ void main() { containsInOrder( ['+0: hybrid loads dart:io', '+1: All tests passed!'])); await test.shouldExit(0); - }, tags: ['chrome'], skip: 'only serialization error'); + }, tags: ['chrome']); test('forwards data from the test to the hybrid isolate', () async { var channel = spawnHybridCode(''' @@ -89,7 +89,7 @@ void main() { '''); channel.sink..add(1)..add(2)..add(3); expect(channel.stream.take(3).toList(), completion(equals([2, 3, 4]))); - }, skip: 'Non-browser?'); + }); test('passes an initial message to the hybrid isolate', () { var code = ''' @@ -104,7 +104,7 @@ void main() { completion(equals([1, 2, 3]))); expect(spawnHybridCode(code, message: {'a': 'b'}).stream.first, completion(equals({'a': 'b'}))); - }, skip: 'Non-browser?'); + }); test('allows the hybrid isolate to send errors across the stream channel', () { @@ -121,7 +121,7 @@ void main() { expect(error.toString(), equals('oh no!')); expect(stackTrace.toString(), contains('hybridMain')); })); - }, skip: 'Non-browser?'); + }); test('sends an unhandled synchronous error across the stream channel', () { var channel = spawnHybridCode(''' @@ -136,7 +136,7 @@ void main() { expect(error.toString(), equals('oh no!')); expect(stackTrace.toString(), contains('hybridMain')); })); - }, skip: 'Non-browser?'); + }); test('sends an unhandled asynchronous error across the stream channel', () { var channel = spawnHybridCode(''' @@ -155,7 +155,7 @@ void main() { expect(error.toString(), equals('oh no!')); expect(stackTrace.toString(), contains('hybridMain')); })); - }, skip: 'Non-browser?'); + }); test('deserializes TestFailures as TestFailures', () { var channel = spawnHybridCode(''' @@ -169,7 +169,7 @@ void main() { '''); expect(channel.stream.first, throwsA(TypeMatcher())); - }, skip: 'Non-browser?'); + }); test('gracefully handles an unserializable message in the VM', () { var channel = spawnHybridCode(''' From 467c06b7b14a6156e2dca32627a396544716d1db Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Jun 2020 21:27:22 -0700 Subject: [PATCH 25/46] Print when starting/exiting isolate --- pkgs/test_core/lib/src/runner/runner_test.dart | 3 ++- pkgs/test_core/lib/src/runner/spawn_hybrid.dart | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/test_core/lib/src/runner/runner_test.dart b/pkgs/test_core/lib/src/runner/runner_test.dart index 0dc6229c7..f894cdb34 100644 --- a/pkgs/test_core/lib/src/runner/runner_test.dart +++ b/pkgs/test_core/lib/src/runner/runner_test.dart @@ -71,7 +71,8 @@ class RunnerTest extends Test { // When we kill the isolate that the test lives in, that will close // this virtual channel and cause the spawned isolate to close as // well. - spawnHybridUri(message['url'] as String, message['message']) + spawnHybridUri(message['channel'] as int, message['url'] as String, + message['message']) .pipe(testChannel.virtualChannel(message['channel'] as int)); break; } diff --git a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart index 1db6769df..b4ed8d355 100644 --- a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart +++ b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart @@ -19,7 +19,7 @@ import 'package:test_api/src/util/remote_exception.dart'; // ignore: implementat /// This connects the main isolate to the hybrid isolate, whereas /// `lib/src/frontend/spawn_hybrid.dart` connects the test isolate to the main /// isolate. -StreamChannel spawnHybridUri(String url, Object message) { +StreamChannel spawnHybridUri(int id, String url, Object message) { return StreamChannelCompleter.fromFuture(() async { var port = ReceivePort(); var onExitPort = ReceivePort(); @@ -32,12 +32,14 @@ StreamChannel spawnHybridUri(String url, Object message) { void main(_, List data) => listen(() => lib.hybridMain, data); '''; + print('Starting isolate for: $id'); var isolate = await dart.runInIsolate(code, [port.sendPort, message], onExit: onExitPort.sendPort); // Ensure that we close [port] and [channel] when the isolate exits. var disconnector = Disconnector(); onExitPort.listen((_) { + print('Isolate exited for: $id'); disconnector.disconnect(); onExitPort.close(); }); @@ -46,11 +48,13 @@ StreamChannel spawnHybridUri(String url, Object message) { .transform(disconnector) .transformSink(StreamSinkTransformer.fromHandlers(handleDone: (sink) { // If the user closes the stream channel, kill the isolate. + print('Killing Isolate for: $id'); isolate.kill(); onExitPort.close(); sink.close(); })); } catch (error, stackTrace) { + print('Error in Isolate for: $id'); port.close(); onExitPort.close(); From 3fb74a6fc91c49eeb47b63ca42ff38cf422177a4 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 15:23:49 -0700 Subject: [PATCH 26/46] Run without pub run --- pkgs/test/mono_pkg.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index 7430426f3..748ce762d 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -11,8 +11,8 @@ stages: - dartanalyzer: --fatal-warnings . dart: 2.7.0 - unit_test: - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 - - command: xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 From 84ce861f6c817c61ffa987ed7f996ed7b8ed4bc9 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 15:32:49 -0700 Subject: [PATCH 27/46] Mono repo --- .travis.yml | 12 +++++------- mono_repo.yaml | 6 ------ pkgs/test/mono_pkg.yaml | 8 -------- pkgs/test_api/mono_pkg.yaml | 14 +------------- pkgs/test_core/mono_pkg.yaml | 10 +--------- tool/travis.sh | 36 ++++++++++-------------------------- 6 files changed, 17 insertions(+), 69 deletions(-) diff --git a/.travis.yml b/.travis.yml index a38a941d3..b9536e345 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,37 +7,35 @@ addons: chrome: stable env: global: FORCE_TEST_EXIT=true -after_failure: - - tool/report_failure.sh jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" dart: dev os: linux env: PKGS="pkgs/test" diff --git a/mono_repo.yaml b/mono_repo.yaml index 77c90a37d..96f93891a 100644 --- a/mono_repo.yaml +++ b/mono_repo.yaml @@ -5,9 +5,3 @@ travis: chrome: stable env: global: FORCE_TEST_EXIT=true - - after_failure: - - tool/report_failure.sh - -merge_stages: -- analyze_and_format diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index 748ce762d..f2332d455 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -2,14 +2,6 @@ dart: - dev stages: - - analyze_and_format: - - group: - - dartfmt: sdk - - dartanalyzer: --fatal-infos --fatal-warnings . - dart: dev - - group: - - dartanalyzer: --fatal-warnings . - dart: 2.7.0 - unit_test: - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 diff --git a/pkgs/test_api/mono_pkg.yaml b/pkgs/test_api/mono_pkg.yaml index 4a2bb76fb..5191f6fc4 100644 --- a/pkgs/test_api/mono_pkg.yaml +++ b/pkgs/test_api/mono_pkg.yaml @@ -1,13 +1 @@ -stages: - - analyze_and_format: - - group: - - dartfmt: sdk - - dartanalyzer: --fatal-infos --fatal-warnings . - dart: dev - - group: - - dartanalyzer: --fatal-warnings . - dart: 2.7.0 - - unit_test: - - group: - - test: --preset travis - dart: dev +stages: [] diff --git a/pkgs/test_core/mono_pkg.yaml b/pkgs/test_core/mono_pkg.yaml index f6da98d43..5191f6fc4 100644 --- a/pkgs/test_core/mono_pkg.yaml +++ b/pkgs/test_core/mono_pkg.yaml @@ -1,9 +1 @@ -stages: - - analyze_and_format: - - group: - - dartfmt: sdk - - dartanalyzer: --fatal-infos --fatal-warnings . - dart: dev - - group: - - dartanalyzer: --fatal-warnings . - dart: 2.7.0 +stages: [] diff --git a/tool/travis.sh b/tool/travis.sh index 598223469..c7488ac89 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -55,40 +55,24 @@ for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in command_0) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 || EXIT_CODE=$? ;; command_1) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 || EXIT_CODE=$? ;; command_2) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 || EXIT_CODE=$? ;; command_3) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 || EXIT_CODE=$? ;; command_4) - echo 'xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5' - xvfb-run -s "-screen 0 1024x768x24" pub run test --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 || EXIT_CODE=$? - ;; - dartanalyzer_0) - echo 'dartanalyzer --fatal-infos --fatal-warnings .' - dartanalyzer --fatal-infos --fatal-warnings . || EXIT_CODE=$? - ;; - dartanalyzer_1) - echo 'dartanalyzer --fatal-warnings .' - dartanalyzer --fatal-warnings . || EXIT_CODE=$? - ;; - dartfmt) - echo 'dartfmt -n --set-exit-if-changed .' - dartfmt -n --set-exit-if-changed . || EXIT_CODE=$? - ;; - test) - echo 'pub run test --preset travis' - pub run test --preset travis || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 || EXIT_CODE=$? ;; *) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" From 5b35ab8841f84b8a3dd97148ad0888dc9a5e32cf Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 15:15:39 -0700 Subject: [PATCH 28/46] Attempt to diagnose hang with vm service --- pkgs/test/mono_pkg.yaml | 10 ++-- pkgs/test/pubspec.yaml | 1 + pkgs/test/test/diagnose_exit.dart | 79 +++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 pkgs/test/test/diagnose_exit.dart diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index f2332d455..f9b943f5e 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -3,8 +3,8 @@ dart: stages: - unit_test: - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 + - command: dart test/diagnose_exit.dart -fake1 + - command: dart test/diagnose_exit.dart -fake2 + - command: dart test/diagnose_exit.dart -fake3 + - command: dart test/diagnose_exit.dart -fake4 + - command: dart test/diagnose_exit.dart -fake5 diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 3c59d40d3..2926d0743 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -40,6 +40,7 @@ dev_dependencies: shelf_test_handler: ^1.0.0 test_descriptor: ^1.0.0 test_process: ^1.0.0 + vm_service: '>=1.0.0 <5.0.0' dependency_overrides: test_api: diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart new file mode 100644 index 000000000..d569563dd --- /dev/null +++ b/pkgs/test/test/diagnose_exit.dart @@ -0,0 +1,79 @@ +import 'dart:io'; +import 'dart:convert'; + +import 'package:async/async.dart'; +import 'package:pedantic/pedantic.dart'; +import 'package:vm_service/utils.dart'; +import 'package:vm_service/vm_service.dart'; +import 'package:vm_service/vm_service_io.dart'; + +void main(List args) async { + final process = await Process.start('dart', [ + '--enable-vm-service', + 'bin/test.dart', + 'test/runner/hybrid_test.dart', + '--total-shards', + '5', + '--shard-index', + '3', + '-r', + 'expanded' + ]); + final testOut = StreamQueue(process.stdout); + final observatoryUrl = await _findObservatoryUrl(testOut); + print('Observatory Url: $observatoryUrl'); + unawaited(process.stderr.pipe(stderr)); + unawaited(testOut.rest.pipe(stdout)); + exitCode = 0; + unawaited(process.exitCode.whenComplete(() { + exit(exitCode); + })); + await Future.delayed(const Duration(minutes: 2)); + await _showInfo(observatoryUrl); + exitCode = 1; + process.kill(); +} + +Future _findObservatoryUrl(StreamQueue> stdout) async { + final newline = '\n'.codeUnitAt(0); + final line = >[]; + while (line.isEmpty || line.last.last != newline) { + line.add(await stdout.next); + } + return Uri.parse(utf8.decode(line.expand((l) => l).toList()).split(' ').last); +} + +Future _showInfo(Uri serviceProtocolUrl) async { + final service = await vmServiceConnectUri( + convertToWebSocketUrl(serviceProtocolUrl: serviceProtocolUrl).toString()); + final vm = await service.getVM(); + final isolates = vm.isolates; + print(isolates); + + for (final isolate in isolates) { + final classList = await service.getClassList(isolate.id); + for (final c in classList.classes) { + if (c?.name?.endsWith('Subscription') ?? false) { + final instances = + (await service.getInstances(isolate.id, c.id, 100)).instances; + if (instances.isEmpty) continue; + print('${c.name}: ${instances.length} instances'); + for (final instance in instances) { + final retainingPath = + await service.getRetainingPath(isolate.id, instance.id, 100); + print('Retained type: ${retainingPath.gcRootType}'); + for (final o in retainingPath.elements) { + final value = o.value; + if (value is InstanceRef) { + print('-> ${value.classRef.name} in ${o.parentField}'); + } else { + print('-> in ${o.parentField}'); + } + } + } + } + } + } + + service.dispose(); +} From 8092fd59f59d17b49cf3a10bbd02f418edab92d7 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 16:17:01 -0700 Subject: [PATCH 29/46] Run through the new script --- .travis.yml | 10 +++++----- tool/travis.sh | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9536e345..9058b30a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,31 +11,31 @@ env: jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake1`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake2`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake3`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake4`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake5`" dart: dev os: linux env: PKGS="pkgs/test" diff --git a/tool/travis.sh b/tool/travis.sh index c7488ac89..014009f3e 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -55,24 +55,24 @@ for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in command_0) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 || EXIT_CODE=$? + echo 'dart test/diagnose_exit.dart -fake1' + dart test/diagnose_exit.dart -fake1 || EXIT_CODE=$? ;; command_1) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 || EXIT_CODE=$? + echo 'dart test/diagnose_exit.dart -fake2' + dart test/diagnose_exit.dart -fake2 || EXIT_CODE=$? ;; command_2) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 || EXIT_CODE=$? + echo 'dart test/diagnose_exit.dart -fake3' + dart test/diagnose_exit.dart -fake3 || EXIT_CODE=$? ;; command_3) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 || EXIT_CODE=$? + echo 'dart test/diagnose_exit.dart -fake4' + dart test/diagnose_exit.dart -fake4 || EXIT_CODE=$? ;; command_4) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 || EXIT_CODE=$? + echo 'dart test/diagnose_exit.dart -fake5' + dart test/diagnose_exit.dart -fake5 || EXIT_CODE=$? ;; *) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" From 8f3c9831b6d40aaae5d1374307b6fe637b00162e Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 16:32:06 -0700 Subject: [PATCH 30/46] Do we sometimes get non-observatory output? --- pkgs/test/test/diagnose_exit.dart | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart index d569563dd..8e9ab4867 100644 --- a/pkgs/test/test/diagnose_exit.dart +++ b/pkgs/test/test/diagnose_exit.dart @@ -34,13 +34,20 @@ void main(List args) async { process.kill(); } -Future _findObservatoryUrl(StreamQueue> stdout) async { +Future _findObservatoryUrl(StreamQueue> testOut) async { final newline = '\n'.codeUnitAt(0); - final line = >[]; - while (line.isEmpty || line.last.last != newline) { - line.add(await stdout.next); + while (true) { + final line = >[]; + while (line.isEmpty || line.last.last != newline) { + line.add(await testOut.next); + } + final decoded = utf8.decode([for (var part in line) ...part]); + if (decoded.startsWith('Observatory listening on')) { + return Uri.parse(decoded.split(' ').last); + } else { + stdout.writeAll(line); + } } - return Uri.parse(utf8.decode(line.expand((l) => l).toList()).split(' ').last); } Future _showInfo(Uri serviceProtocolUrl) async { From 2c68035c1b39194fb38fca4953ed14121deb26e6 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 16:35:58 -0700 Subject: [PATCH 31/46] Write as char code --- pkgs/test/test/diagnose_exit.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart index 8e9ab4867..48915038f 100644 --- a/pkgs/test/test/diagnose_exit.dart +++ b/pkgs/test/test/diagnose_exit.dart @@ -45,7 +45,11 @@ Future _findObservatoryUrl(StreamQueue> testOut) async { if (decoded.startsWith('Observatory listening on')) { return Uri.parse(decoded.split(' ').last); } else { - stdout.writeAll(line); + for (final part in line) { + for (final char in part) { + stdout.writeCharCode(char); + } + } } } } From c557a0c926a32d0a79d686d21b3ec44f22a9b2ce Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 17:06:42 -0700 Subject: [PATCH 32/46] Fake a hang to see output on "success" case --- pkgs/test/test/diagnose_exit.dart | 1 + pkgs/test_core/lib/src/executable.dart | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart index 48915038f..956cc2fe2 100644 --- a/pkgs/test/test/diagnose_exit.dart +++ b/pkgs/test/test/diagnose_exit.dart @@ -11,6 +11,7 @@ void main(List args) async { final process = await Process.start('dart', [ '--enable-vm-service', 'bin/test.dart', + '--fake-long-exit', 'test/runner/hybrid_test.dart', '--total-shards', '5', diff --git a/pkgs/test_core/lib/src/executable.dart b/pkgs/test_core/lib/src/executable.dart index 0a350eed9..242b35c60 100644 --- a/pkgs/test_core/lib/src/executable.dart +++ b/pkgs/test_core/lib/src/executable.dart @@ -33,8 +33,14 @@ final String _globalConfigPath = () { }(); Future main(List args) async { + var fakeLongExit = false; + if (args.first == '--fake-long-exit') { + args = args.skip(1).toList(); + fakeLongExit = true; + } await _execute(args); completeShutdown(); + if (fakeLongExit) await Future.delayed(const Duration(minutes: 2)); } Future runTests(List args) async { From 8716882291a62aeb0058aaf544549435439aed7e Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 18:11:45 -0700 Subject: [PATCH 33/46] Write context ref and indexes --- pkgs/test/test/diagnose_exit.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart index 956cc2fe2..8ef1b2b39 100644 --- a/pkgs/test/test/diagnose_exit.dart +++ b/pkgs/test/test/diagnose_exit.dart @@ -77,9 +77,13 @@ Future _showInfo(Uri serviceProtocolUrl) async { for (final o in retainingPath.elements) { final value = o.value; if (value is InstanceRef) { - print('-> ${value.classRef.name} in ${o.parentField}'); + print( + '-> ${value.classRef.name} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}}'); + } else if (value is ContextRef) { + print('-> Context ${value.id}'); } else { - print('-> in ${o.parentField}'); + print( + '-> Non-Instance: ${value.runtimeType} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}'); } } } From 36cf1bcb611f4800aa6c67be7f63211d651e54c7 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 20:52:39 -0700 Subject: [PATCH 34/46] Hack things up to reduce retained references After these hacks there is no `Invoker` retained in hello world test cases. - Don't pass through executable arguments. This isn't safe for things like `--enable-vm-service`. - Eagerly resolve some static futures. - Add an extra delay for paranoia, and print when observatory should be "settled". - Don't use an AsyncMemo for closing the runner. Refactor away from async/await to old style future chaining. This prevents the `_awaiter` field on the Future from holding on to the entire closure context and preventing GC. - Avoid reusing a static final future. Change to a getter which reads from a variable if it has already been resolved. - Fix some bugs around double newlines in observatory message. --- pkgs/test/test/diagnose_exit.dart | 11 ++- pkgs/test/test/io.dart | 4 +- pkgs/test_core/lib/src/executable.dart | 4 + pkgs/test_core/lib/src/runner.dart | 75 +++++++++++-------- .../lib/src/runner/reporter/expanded.dart | 1 + pkgs/test_core/lib/src/util/io.dart | 21 ++++-- 6 files changed, 69 insertions(+), 47 deletions(-) diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart index 8ef1b2b39..7f27e9797 100644 --- a/pkgs/test/test/diagnose_exit.dart +++ b/pkgs/test/test/diagnose_exit.dart @@ -42,15 +42,14 @@ Future _findObservatoryUrl(StreamQueue> testOut) async { while (line.isEmpty || line.last.last != newline) { line.add(await testOut.next); } - final decoded = utf8.decode([for (var part in line) ...part]); + final decoded = utf8 + .decode([for (var part in line) ...part]) + .split('\n') + .firstWhere((l) => l.isNotEmpty); if (decoded.startsWith('Observatory listening on')) { return Uri.parse(decoded.split(' ').last); } else { - for (final part in line) { - for (final char in part) { - stdout.writeCharCode(char); - } - } + line.forEach(stdout.add); } } } diff --git a/pkgs/test/test/io.dart b/pkgs/test/test/io.dart index 309438020..825c855b7 100644 --- a/pkgs/test/test/io.dart +++ b/pkgs/test/test/io.dart @@ -103,8 +103,8 @@ Future runDart(Iterable args, bool forwardStdio = false, String packageConfig}) async { var allArgs = [ - ...Platform.executableArguments.where((arg) => - !arg.startsWith('--package-root=') && !arg.startsWith('--packages=')), + // ...Platform.executableArguments.where((arg) => + // !arg.startsWith('--package-root=') && !arg.startsWith('--packages=')), '--packages=${packageConfig ?? await Isolate.packageConfig}', ...args ]; diff --git a/pkgs/test_core/lib/src/executable.dart b/pkgs/test_core/lib/src/executable.dart index 242b35c60..a959577d5 100644 --- a/pkgs/test_core/lib/src/executable.dart +++ b/pkgs/test_core/lib/src/executable.dart @@ -33,6 +33,8 @@ final String _globalConfigPath = () { }(); Future main(List args) async { + // Eager resolve of values that would capture a zone. + print(await rootPackageLanguageVersionComment); var fakeLongExit = false; if (args.first == '--fake-long-exit') { args = args.skip(1).toList(); @@ -40,6 +42,8 @@ Future main(List args) async { } await _execute(args); completeShutdown(); + await Future.delayed(const Duration(seconds: 5)); + print('Shutdown complete'); if (fakeLongExit) await Future.delayed(const Duration(minutes: 2)); } diff --git a/pkgs/test_core/lib/src/runner.dart b/pkgs/test_core/lib/src/runner.dart index 89ed8bdb1..0fa2f03fe 100644 --- a/pkgs/test_core/lib/src/runner.dart +++ b/pkgs/test_core/lib/src/runner.dart @@ -66,9 +66,7 @@ class Runner { /// This is stored so that we can cancel it when the runner is closed. CancelableOperation _debugOperation; - /// The memoizer for ensuring [close] only runs once. - final _closeMemo = AsyncMemoizer(); - bool get _closed => _closeMemo.hasRun; + bool _closed = false; /// Sinks created for each file reporter (if there are any). final List _sinks; @@ -221,40 +219,51 @@ class Runner { /// This stops any future test suites from running. It will wait for any /// currently-running VM tests, in case they have stuff to clean up on the /// filesystem. - Future close() => _closeMemo.runOnce(() async { - Timer timer; - if (!_engine.isIdle) { - // Wait a bit to print this message, since printing it eagerly looks weird - // if the tests then finish immediately. - timer = Timer(Duration(seconds: 1), () { - // Pause the reporter while we print to ensure that we don't interfere - // with its output. - _reporter.pause(); - print('Waiting for current test(s) to finish.'); - print('Press Control-C again to terminate immediately.'); - _reporter.resume(); - }); - } + Future close() { + if (_closed) return Future.value(null); + _closed = true; + Timer timer; + if (!_engine.isIdle) { + // Wait a bit to print this message, since printing it eagerly looks weird + // if the tests then finish immediately. + timer = Timer(Duration(seconds: 1), () { + // Pause the reporter while we print to ensure that we don't interfere + // with its output. + _reporter.pause(); + print('Waiting for current test(s) to finish.'); + print('Press Control-C again to terminate immediately.'); + _reporter.resume(); + }); + } - if (_debugOperation != null) await _debugOperation.cancel(); + var done = Future.value(null); - if (_suiteSubscription != null) await _suiteSubscription.cancel(); - _suiteSubscription = null; + if (_debugOperation != null) { + done = done.then((_) => _debugOperation.cancel()); + } - // Make sure we close the engine *before* the loader. Otherwise, - // LoadSuites provided by the loader may get into bad states. - // - // We close the loader's browsers while we're closing the engine because - // browser tests don't store any state we care about and we want them to - // shut down without waiting for their tear-downs. - await Future.wait([_loader.closeEphemeral(), _engine.close()]); - if (timer != null) timer.cancel(); - await _loader.close(); + if (_suiteSubscription != null) { + done = done.then((_) => + _suiteSubscription.cancel().then((_) => _suiteSubscription = null)); + } - // Flush any IOSinks created for file reporters. - await Future.wait(_sinks.map((s) => s.flush().then((_) => s.close()))); - _sinks.clear(); - }); + // Make sure we close the engine *before* the loader. Otherwise, + // LoadSuites provided by the loader may get into bad states. + // + // We close the loader's browsers while we're closing the engine because + // browser tests don't store any state we care about and we want them to + // shut down without waiting for their tear-downs. + done = done + .then((_) => Future.wait([_loader.closeEphemeral(), _engine.close()])); + if (timer != null) timer.cancel(); + done = done.then((_) => _loader.close()); + + // Flush any IOSinks created for file reporters. + done = done.then((_) => + Future.wait(_sinks.map((s) => s.flush().then((_) => s.close()))) + .then((_) => _sinks.clear())); + return done; + } /// Return a stream of [LoadSuite]s in [_config.paths]. /// diff --git a/pkgs/test_core/lib/src/runner/reporter/expanded.dart b/pkgs/test_core/lib/src/runner/reporter/expanded.dart index 2785ae910..f0874cb39 100644 --- a/pkgs/test_core/lib/src/runner/reporter/expanded.dart +++ b/pkgs/test_core/lib/src/runner/reporter/expanded.dart @@ -218,6 +218,7 @@ class ExpandedReporter implements Reporter { /// [success] will be `true` if all tests passed, `false` if some tests /// failed, and `null` if the engine was closed prematurely. void _onDone(bool success) { + cancel(); // A null success value indicates that the engine was closed before the // tests finished running, probably because of a signal from the user, in // which case we shouldn't print summary information. diff --git a/pkgs/test_core/lib/src/util/io.dart b/pkgs/test_core/lib/src/util/io.dart index 9c608cef3..b97bcc25a 100644 --- a/pkgs/test_core/lib/src/util/io.dart +++ b/pkgs/test_core/lib/src/util/io.dart @@ -43,12 +43,21 @@ final int lineLength = () { /// /// If the cwd is not a package, this returns an empty string which ends up /// defaulting to the current sdk version. -final Future rootPackageLanguageVersionComment = () async { - var packageConfig = await loadPackageConfigUri(await Isolate.packageConfig); - var rootPackage = packageConfig.packageOf(Uri.file(p.absolute('foo.dart'))); - if (rootPackage == null) return ''; - return '// @dart=${rootPackage.languageVersion}'; -}(); +String _languageComment; +Future _languageCommentWork; +Future get rootPackageLanguageVersionComment { + if (_languageComment != null) return Future.value(_languageComment); + return _languageCommentWork ??= () async { + var packageConfig = await loadPackageConfigUri(await Isolate.packageConfig); + var rootPackage = packageConfig.packageOf(Uri.file(p.absolute('foo.dart'))); + if (rootPackage == null) return ''; + return '// @dart=${rootPackage.languageVersion}'; + }() + ..then((c) { + _languageComment = c; + _languageCommentWork = null; + }); +} /// The root directory of the Dart SDK. final String sdkDir = p.dirname(p.dirname(Platform.resolvedExecutable)); From 9503eb093b4d5bb8c384b9cde1581452a9de39aa Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 23 Jun 2020 22:38:37 -0700 Subject: [PATCH 35/46] Try to print retaining root names Hack around bugs in the VM service protocol with uncaught errors. --- pkgs/test/test/diagnose_exit.dart | 57 +++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart index 7f27e9797..f59371d8b 100644 --- a/pkgs/test/test/diagnose_exit.dart +++ b/pkgs/test/test/diagnose_exit.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:io'; import 'dart:convert'; @@ -55,40 +56,82 @@ Future _findObservatoryUrl(StreamQueue> testOut) async { } Future _showInfo(Uri serviceProtocolUrl) async { - final service = await vmServiceConnectUri( - convertToWebSocketUrl(serviceProtocolUrl: serviceProtocolUrl).toString()); + final skips = StreamController.broadcast(); + var skipCount = 0; + final service = await runZonedGuarded( + () => vmServiceConnectUri( + convertToWebSocketUrl(serviceProtocolUrl: serviceProtocolUrl) + .toString()), (error, st) { + skipCount++; + skips.add(null); + }); final vm = await service.getVM(); final isolates = vm.isolates; print(isolates); - for (final isolate in isolates) { - final classList = await service.getClassList(isolate.id); + for (final isolateRef in isolates) { + final classList = await service.getClassList(isolateRef.id); + final isolate = await service.getIsolate(isolateRef.id); + final rootRefs = []; for (final c in classList.classes) { if (c?.name?.endsWith('Subscription') ?? false) { final instances = - (await service.getInstances(isolate.id, c.id, 100)).instances; + (await service.getInstances(isolateRef.id, c.id, 100)).instances; if (instances.isEmpty) continue; print('${c.name}: ${instances.length} instances'); for (final instance in instances) { final retainingPath = - await service.getRetainingPath(isolate.id, instance.id, 100); + await service.getRetainingPath(isolateRef.id, instance.id, 100); print('Retained type: ${retainingPath.gcRootType}'); + InstanceRef lastRetained; for (final o in retainingPath.elements) { final value = o.value; if (value is InstanceRef) { + lastRetained = value; print( '-> ${value.classRef.name} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}}'); } else if (value is ContextRef) { print('-> Context ${value.id}'); } else { print( - '-> Non-Instance: ${value.runtimeType} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}'); + '-> Non-Instance: ${value.runtimeType} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}}'); } } + if (lastRetained != null) { + rootRefs.add(lastRetained); + } + } + } + } + print('Roots: '); + for (final libraryRef in isolate.libraries) { + final library = + await service.getObject(isolateRef.id, libraryRef.id) as Library; + if (library.name.startsWith('dart.') || + library.name.startsWith('builtin')) { + continue; + } + for (final variableRef in library.variables) { + try { + final variableOrSkip = await Future.any([ + service.getObject(isolateRef.id, variableRef.id), + skips.stream.first + ]); + if (variableOrSkip == null) continue; + final variable = variableOrSkip as Field; + for (final root in rootRefs.toList()) { + if (root.classRef.id == variable.staticValue.classRef.id) { + print( + 'Potential Root: ${root.classRef.name} at ${variableRef.name} in library "${library.name}" at ${variable.location.script.uri}'); + } + } + } catch (_) { + skipCount++; } } } } + print('Errors reading $skipCount variables'); service.dispose(); } From e19afa3aeb394865425f6a1c5bec1f50b79d4ab0 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 19 Aug 2020 16:47:02 -0700 Subject: [PATCH 36/46] GO back to running through the real test, verify it is still failing --- .travis.yml | 10 +-- pkgs/test/mono_pkg.yaml | 10 +-- pkgs/test/test/diagnose_exit.dart | 139 ------------------------------ tool/travis.sh | 20 ++--- 4 files changed, 20 insertions(+), 159 deletions(-) delete mode 100644 pkgs/test/test/diagnose_exit.dart diff --git a/.travis.yml b/.travis.yml index 9058b30a4..b9536e345 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,31 +11,31 @@ env: jobs: include: - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake1`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake2`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake3`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake4`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" dart: dev os: linux env: PKGS="pkgs/test" script: ./tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart test/diagnose_exit.dart -fake5`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" dart: dev os: linux env: PKGS="pkgs/test" diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index f9b943f5e..f2332d455 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -3,8 +3,8 @@ dart: stages: - unit_test: - - command: dart test/diagnose_exit.dart -fake1 - - command: dart test/diagnose_exit.dart -fake2 - - command: dart test/diagnose_exit.dart -fake3 - - command: dart test/diagnose_exit.dart -fake4 - - command: dart test/diagnose_exit.dart -fake5 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 + - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 diff --git a/pkgs/test/test/diagnose_exit.dart b/pkgs/test/test/diagnose_exit.dart deleted file mode 100644 index 98712df87..000000000 --- a/pkgs/test/test/diagnose_exit.dart +++ /dev/null @@ -1,139 +0,0 @@ -// @dart=2.7 - -import 'dart:async'; -import 'dart:io'; -import 'dart:convert'; - -import 'package:async/async.dart'; -import 'package:pedantic/pedantic.dart'; -import 'package:vm_service/utils.dart'; -import 'package:vm_service/vm_service.dart'; -import 'package:vm_service/vm_service_io.dart'; - -void main(List args) async { - final process = await Process.start('dart', [ - '--enable-vm-service', - 'bin/test.dart', - '--fake-long-exit', - 'test/runner/hybrid_test.dart', - '--total-shards', - '5', - '--shard-index', - '3', - '-r', - 'expanded' - ]); - final testOut = StreamQueue(process.stdout); - final observatoryUrl = await _findObservatoryUrl(testOut); - print('Observatory Url: $observatoryUrl'); - unawaited(process.stderr.pipe(stderr)); - unawaited(testOut.rest.pipe(stdout)); - exitCode = 0; - unawaited(process.exitCode.whenComplete(() { - exit(exitCode); - })); - await Future.delayed(const Duration(minutes: 2)); - await _showInfo(observatoryUrl); - exitCode = 1; - process.kill(); -} - -Future _findObservatoryUrl(StreamQueue> testOut) async { - final newline = '\n'.codeUnitAt(0); - while (true) { - final line = >[]; - while (line.isEmpty || line.last.last != newline) { - line.add(await testOut.next); - } - final decoded = utf8 - .decode([for (var part in line) ...part]) - .split('\n') - .firstWhere((l) => l.isNotEmpty); - if (decoded.startsWith('Observatory listening on')) { - return Uri.parse(decoded.split(' ').last); - } else { - line.forEach(stdout.add); - } - } -} - -Future _showInfo(Uri serviceProtocolUrl) async { - final skips = StreamController.broadcast(); - var skipCount = 0; - final service = await runZonedGuarded( - () => vmServiceConnectUri( - convertToWebSocketUrl(serviceProtocolUrl: serviceProtocolUrl) - .toString()), (error, st) { - skipCount++; - skips.add(null); - }); - final vm = await service.getVM(); - final isolates = vm.isolates; - print(isolates); - - for (final isolateRef in isolates) { - final classList = await service.getClassList(isolateRef.id); - final isolate = await service.getIsolate(isolateRef.id); - final rootRefs = []; - for (final c in classList.classes) { - if (c?.name?.endsWith('Subscription') ?? false) { - final instances = - (await service.getInstances(isolateRef.id, c.id, 100)).instances; - if (instances.isEmpty) continue; - print('${c.name}: ${instances.length} instances'); - for (final instance in instances) { - final retainingPath = - await service.getRetainingPath(isolateRef.id, instance.id, 100); - print('Retained type: ${retainingPath.gcRootType}'); - InstanceRef lastRetained; - for (final o in retainingPath.elements) { - final value = o.value; - if (value is InstanceRef) { - lastRetained = value; - print( - '-> ${value.classRef.name} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}}'); - } else if (value is ContextRef) { - print('-> Context ${value.id}'); - } else { - print( - '-> Non-Instance: ${value.runtimeType} in ${o.parentField} {map: ${o.parentMapKey}, list: ${o.parentListIndex}}'); - } - } - if (lastRetained != null) { - rootRefs.add(lastRetained); - } - } - } - } - print('Roots: '); - for (final libraryRef in isolate.libraries) { - final library = - await service.getObject(isolateRef.id, libraryRef.id) as Library; - if (library.name.startsWith('dart.') || - library.name.startsWith('builtin')) { - continue; - } - for (final variableRef in library.variables) { - try { - final variableOrSkip = await Future.any([ - service.getObject(isolateRef.id, variableRef.id), - skips.stream.first - ]); - if (variableOrSkip == null) continue; - final variable = variableOrSkip as Field; - for (final root in rootRefs.toList()) { - if (root.classRef.id == variable.staticValue.classRef.id) { - print( - 'Potential Root: ${root.classRef.name} at ${variableRef.name} in library "${library.name}" at ${variable.location.script.uri}'); - } - } - } catch (_) { - skipCount++; - } - } - } - } - print('Errors reading $skipCount variables'); - - service.dispose(); -} diff --git a/tool/travis.sh b/tool/travis.sh index 014009f3e..c7488ac89 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -55,24 +55,24 @@ for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in command_0) - echo 'dart test/diagnose_exit.dart -fake1' - dart test/diagnose_exit.dart -fake1 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 || EXIT_CODE=$? ;; command_1) - echo 'dart test/diagnose_exit.dart -fake2' - dart test/diagnose_exit.dart -fake2 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 || EXIT_CODE=$? ;; command_2) - echo 'dart test/diagnose_exit.dart -fake3' - dart test/diagnose_exit.dart -fake3 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 || EXIT_CODE=$? ;; command_3) - echo 'dart test/diagnose_exit.dart -fake4' - dart test/diagnose_exit.dart -fake4 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 || EXIT_CODE=$? ;; command_4) - echo 'dart test/diagnose_exit.dart -fake5' - dart test/diagnose_exit.dart -fake5 || EXIT_CODE=$? + echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5' + dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 || EXIT_CODE=$? ;; *) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" From 96a8f8b9e21adcc4c50291144f19d02aa20f2928 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 19 Aug 2020 16:51:54 -0700 Subject: [PATCH 37/46] Go back to normal, verify still fails --- pkgs/test/pubspec.yaml | 1 - pkgs/test/test/io.dart | 4 ++-- pkgs/test_core/lib/src/executable.dart | 10 ---------- pkgs/test_core/lib/src/runner/reporter/expanded.dart | 1 - pkgs/test_core/lib/src/runner/runner_test.dart | 3 +-- pkgs/test_core/lib/src/runner/spawn_hybrid.dart | 6 +----- 6 files changed, 4 insertions(+), 21 deletions(-) diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 69daf48cb..18e25066e 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -41,7 +41,6 @@ dev_dependencies: shelf_test_handler: ^1.0.0 test_descriptor: ^1.0.0 test_process: ^1.0.0 - vm_service: '>=1.0.0 <5.0.0' dependency_overrides: test_api: diff --git a/pkgs/test/test/io.dart b/pkgs/test/test/io.dart index 1c40078cc..9fa37db87 100644 --- a/pkgs/test/test/io.dart +++ b/pkgs/test/test/io.dart @@ -105,8 +105,8 @@ Future runDart(Iterable args, bool forwardStdio = false, String packageConfig}) async { var allArgs = [ - // ...Platform.executableArguments.where((arg) => - // !arg.startsWith('--package-root=') && !arg.startsWith('--packages=')), + ...Platform.executableArguments.where((arg) => + !arg.startsWith('--package-root=') && !arg.startsWith('--packages=')), '--packages=${packageConfig ?? await Isolate.packageConfig}', ...args ]; diff --git a/pkgs/test_core/lib/src/executable.dart b/pkgs/test_core/lib/src/executable.dart index c85e7ef60..38e88cf15 100644 --- a/pkgs/test_core/lib/src/executable.dart +++ b/pkgs/test_core/lib/src/executable.dart @@ -34,18 +34,8 @@ final String _globalConfigPath = () { }(); Future main(List args) async { - // Eager resolve of values that would capture a zone. - print(await rootPackageLanguageVersionComment); - var fakeLongExit = false; - if (args.first == '--fake-long-exit') { - args = args.skip(1).toList(); - fakeLongExit = true; - } await _execute(args); completeShutdown(); - await Future.delayed(const Duration(seconds: 5)); - print('Shutdown complete'); - if (fakeLongExit) await Future.delayed(const Duration(minutes: 2)); } Future runTests(List args) async { diff --git a/pkgs/test_core/lib/src/runner/reporter/expanded.dart b/pkgs/test_core/lib/src/runner/reporter/expanded.dart index 44d806800..36ce474be 100644 --- a/pkgs/test_core/lib/src/runner/reporter/expanded.dart +++ b/pkgs/test_core/lib/src/runner/reporter/expanded.dart @@ -220,7 +220,6 @@ class ExpandedReporter implements Reporter { /// [success] will be `true` if all tests passed, `false` if some tests /// failed, and `null` if the engine was closed prematurely. void _onDone(bool? success) { - cancel(); // A null success value indicates that the engine was closed before the // tests finished running, probably because of a signal from the user, in // which case we shouldn't print summary information. diff --git a/pkgs/test_core/lib/src/runner/runner_test.dart b/pkgs/test_core/lib/src/runner/runner_test.dart index b37eef311..2093212e7 100644 --- a/pkgs/test_core/lib/src/runner/runner_test.dart +++ b/pkgs/test_core/lib/src/runner/runner_test.dart @@ -71,8 +71,7 @@ class RunnerTest extends Test { // When we kill the isolate that the test lives in, that will close // this virtual channel and cause the spawned isolate to close as // well. - spawnHybridUri(message['channel'] as int, message['url'] as String, - message['message']) + spawnHybridUri(message['url'] as String, message['message']) .pipe(testChannel.virtualChannel(message['channel'] as int)); break; } diff --git a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart index 78c0b646f..768146b42 100644 --- a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart +++ b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart @@ -19,7 +19,7 @@ import 'package:test_api/src/util/remote_exception.dart'; // ignore: implementat /// This connects the main isolate to the hybrid isolate, whereas /// `lib/src/frontend/spawn_hybrid.dart` connects the test isolate to the main /// isolate. -StreamChannel spawnHybridUri(int id, String url, Object? message) { +StreamChannel spawnHybridUri(String url, Object? message) { return StreamChannelCompleter.fromFuture(() async { var port = ReceivePort(); var onExitPort = ReceivePort(); @@ -32,14 +32,12 @@ StreamChannel spawnHybridUri(int id, String url, Object? message) { void main(_, List data) => listen(() => lib.hybridMain, data); '''; - print('Starting isolate for: $id'); var isolate = await dart.runInIsolate(code, [port.sendPort, message], onExit: onExitPort.sendPort); // Ensure that we close [port] and [channel] when the isolate exits. var disconnector = Disconnector(); onExitPort.listen((_) { - print('Isolate exited for: $id'); disconnector.disconnect(); onExitPort.close(); }); @@ -48,13 +46,11 @@ StreamChannel spawnHybridUri(int id, String url, Object? message) { .transform(disconnector) .transformSink(StreamSinkTransformer.fromHandlers(handleDone: (sink) { // If the user closes the stream channel, kill the isolate. - print('Killing Isolate for: $id'); isolate.kill(); onExitPort.close(); sink.close(); })); } catch (error, stackTrace) { - print('Error in Isolate for: $id'); port.close(); onExitPort.close(); From f0e6ded9124cb84f0b60df178693736a71f5dfcc Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 19 Aug 2020 17:19:17 -0700 Subject: [PATCH 38/46] Cancel subscriptions in expanded reporter --- pkgs/test_core/lib/src/runner/reporter/expanded.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test_core/lib/src/runner/reporter/expanded.dart b/pkgs/test_core/lib/src/runner/reporter/expanded.dart index 36ce474be..44d806800 100644 --- a/pkgs/test_core/lib/src/runner/reporter/expanded.dart +++ b/pkgs/test_core/lib/src/runner/reporter/expanded.dart @@ -220,6 +220,7 @@ class ExpandedReporter implements Reporter { /// [success] will be `true` if all tests passed, `false` if some tests /// failed, and `null` if the engine was closed prematurely. void _onDone(bool? success) { + cancel(); // A null success value indicates that the engine was closed before the // tests finished running, probably because of a signal from the user, in // which case we shouldn't print summary information. From ff28c1b39f9429b663073853b6f9895c8a932a69 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 13 Nov 2020 16:44:25 -0800 Subject: [PATCH 39/46] CLose some recieve ports --- pkgs/test_core/lib/src/runner/spawn_hybrid.dart | 2 ++ pkgs/test_core/lib/src/runner/vm/platform.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart index 768146b42..72a3dcf67 100644 --- a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart +++ b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart @@ -39,6 +39,7 @@ StreamChannel spawnHybridUri(String url, Object? message) { var disconnector = Disconnector(); onExitPort.listen((_) { disconnector.disconnect(); + port.close(); onExitPort.close(); }); @@ -47,6 +48,7 @@ StreamChannel spawnHybridUri(String url, Object? message) { .transformSink(StreamSinkTransformer.fromHandlers(handleDone: (sink) { // If the user closes the stream channel, kill the isolate. isolate.kill(); + port.close(); onExitPort.close(); sink.close(); })); diff --git a/pkgs/test_core/lib/src/runner/vm/platform.dart b/pkgs/test_core/lib/src/runner/vm/platform.dart index 040173824..0c2c184b2 100644 --- a/pkgs/test_core/lib/src/runner/vm/platform.dart +++ b/pkgs/test_core/lib/src/runner/vm/platform.dart @@ -58,6 +58,7 @@ class VMPlatform extends PlatformPlugin { StreamSubscription? eventSub; var channel = IsolateChannel.connectReceive(receivePort) .transformStream(StreamTransformer.fromHandlers(handleDone: (sink) { + receivePort.close(); isolate.kill(); eventSub?.cancel(); client?.dispose(); From 3462c3f27681c9b68eb7427f535949d7064763ed Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 13 Nov 2020 16:49:44 -0800 Subject: [PATCH 40/46] Back to narrow travis --- .travis.yml | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index acd03611e..b9536e345 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ -# Created with package:mono_repo v2.5.0 +# Created with package:mono_repo v2.3.0 language: dart # Custom configuration +sudo: required addons: chrome: stable env: @@ -9,16 +10,35 @@ env: jobs: include: - - stage: mono_repo_self_validate - name: mono_repo self validate + - stage: unit_test + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" + dart: dev + os: linux + env: PKGS="pkgs/test" + script: ./tool/travis.sh command_0 + - stage: unit_test + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" + dart: dev + os: linux + env: PKGS="pkgs/test" + script: ./tool/travis.sh command_1 + - stage: unit_test + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" + dart: dev + os: linux + env: PKGS="pkgs/test" + script: ./tool/travis.sh command_2 + - stage: unit_test + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" + dart: dev os: linux - script: tool/mono_repo_self_validate.sh - - stage: analyze_and_format - name: "SDK: dev; PKGS: pkgs/test, pkgs/test_api, pkgs/test_core; TASKS: [`dartfmt -n --set-exit-if-changed .`, `dartanalyzer --enable-experiment=non-nullable --fatal-infos --fatal-warnings .`]" + env: PKGS="pkgs/test" + script: ./tool/travis.sh command_3 + - stage: unit_test + name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" dart: dev os: linux - env: PKGS="pkgs/test pkgs/test_api pkgs/test_core" - script: tool/travis.sh dartfmt dartanalyzer + env: PKGS="pkgs/test" script: ./tool/travis.sh command_4 stages: From bcab1f0241592260401ba72374fa81c3ba959a70 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 13 Nov 2020 16:58:06 -0800 Subject: [PATCH 41/46] Back to typical job setup --- .travis.yml | 43 +++++++++++++++++++------- mono_repo.yaml | 6 ++++ pkgs/test/mono_pkg.yaml | 14 ++++++--- pkgs/test_api/mono_pkg.yaml | 12 ++++++- pkgs/test_core/lib/src/executable.dart | 6 ---- pkgs/test_core/mono_pkg.yaml | 9 +++++- tool/travis.sh | 32 +++++++++++++------ 7 files changed, 87 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9536e345..d8c32882b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,47 +1,66 @@ -# Created with package:mono_repo v2.3.0 +# Created with package:mono_repo v2.5.0 language: dart # Custom configuration -sudo: required addons: chrome: stable env: global: FORCE_TEST_EXIT=true +after_failure: + - tool/report_failure.sh jobs: include: + - stage: mono_repo_self_validate + name: mono_repo self validate + os: linux + script: tool/mono_repo_self_validate.sh + - stage: analyze_and_format + name: "SDK: dev; PKGS: pkgs/test, pkgs/test_api, pkgs/test_core; TASKS: [`dartfmt -n --set-exit-if-changed .`, `dartanalyzer --enable-experiment=non-nullable --fatal-infos --fatal-warnings .`]" + dart: dev + os: linux + env: PKGS="pkgs/test pkgs/test_api pkgs/test_core" + script: tool/travis.sh dartfmt dartanalyzer - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 0`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_0 + script: tool/travis.sh command_0 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 1`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_1 + script: tool/travis.sh command_1 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 2`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_2 + script: tool/travis.sh command_2 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 3`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_3 + script: tool/travis.sh command_3 - stage: unit_test - name: "SDK: dev; PKG: pkgs/test; TASKS: `dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5`" + name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 4`" dart: dev os: linux env: PKGS="pkgs/test" - script: ./tool/travis.sh command_4 + script: tool/travis.sh command_4 + - stage: unit_test + name: "SDK: dev; PKG: pkgs/test_api; TASKS: `pub run --enable-experiment=non-nullable test --preset travis -x browser`" + dart: dev + os: linux + env: PKGS="pkgs/test_api" + script: tool/travis.sh command_5 stages: + - mono_repo_self_validate + - analyze_and_format - unit_test # Only building master means that we don't run two builds for each pull request. diff --git a/mono_repo.yaml b/mono_repo.yaml index 0038d1e8e..266bfe4a2 100644 --- a/mono_repo.yaml +++ b/mono_repo.yaml @@ -5,3 +5,9 @@ travis: chrome: stable env: global: FORCE_TEST_EXIT=true + + after_failure: + - tool/report_failure.sh + +merge_stages: +- analyze_and_format diff --git a/pkgs/test/mono_pkg.yaml b/pkgs/test/mono_pkg.yaml index f2332d455..2f5c81276 100644 --- a/pkgs/test/mono_pkg.yaml +++ b/pkgs/test/mono_pkg.yaml @@ -2,9 +2,13 @@ dart: - dev stages: + - analyze_and_format: + - group: + - dartfmt: sdk + - dartanalyzer: --enable-experiment=non-nullable --fatal-infos --fatal-warnings . - unit_test: - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 - - command: dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 0 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 1 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 2 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 3 + - command: xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 4 diff --git a/pkgs/test_api/mono_pkg.yaml b/pkgs/test_api/mono_pkg.yaml index 5191f6fc4..c3e2834bb 100644 --- a/pkgs/test_api/mono_pkg.yaml +++ b/pkgs/test_api/mono_pkg.yaml @@ -1 +1,11 @@ -stages: [] +dart: + - dev + +stages: + - analyze_and_format: + - group: + - dartfmt: sdk + - dartanalyzer: --enable-experiment=non-nullable --fatal-infos --fatal-warnings . + - unit_test: + - group: + - command: pub run --enable-experiment=non-nullable test --preset travis -x browser diff --git a/pkgs/test_core/lib/src/executable.dart b/pkgs/test_core/lib/src/executable.dart index d4b46015c..eec7fe327 100644 --- a/pkgs/test_core/lib/src/executable.dart +++ b/pkgs/test_core/lib/src/executable.dart @@ -167,12 +167,6 @@ Future _execute(List args) async { await runner?.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['FORCE_TEST_EXIT'] == 'true') { - // exit(exitCode); - } - return; } diff --git a/pkgs/test_core/mono_pkg.yaml b/pkgs/test_core/mono_pkg.yaml index 5191f6fc4..15b2c8eb2 100644 --- a/pkgs/test_core/mono_pkg.yaml +++ b/pkgs/test_core/mono_pkg.yaml @@ -1 +1,8 @@ -stages: [] +dart: + - dev + +stages: + - analyze_and_format: + - group: + - dartfmt: sdk + - dartanalyzer: --enable-experiment=non-nullable --fatal-infos --fatal-warnings . diff --git a/tool/travis.sh b/tool/travis.sh index afc97f667..fb1232084 100755 --- a/tool/travis.sh +++ b/tool/travis.sh @@ -55,24 +55,36 @@ for PKG in ${PKGS}; do echo -e "\033[1mPKG: ${PKG}; TASK: ${TASK}\033[22m" case ${TASK} in command_0) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t1 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 0' + xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 0 || EXIT_CODE=$? ;; command_1) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t2 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 1' + xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 1 || EXIT_CODE=$? ;; command_2) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t3 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 2' + xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 2 || EXIT_CODE=$? ;; command_3) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t4 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 3' + xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 3 || EXIT_CODE=$? ;; command_4) - echo 'dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5' - dart bin/test.dart --preset travis test/runner/hybrid_test.dart --total-shards 5 --shard-index 3 -r expanded -x t5 || EXIT_CODE=$? + echo 'xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 4' + xvfb-run -s "-screen 0 1024x768x24" pub run --enable-experiment=non-nullable test --preset travis -x phantomjs -x node --total-shards 5 --shard-index 4 || EXIT_CODE=$? + ;; + command_5) + echo 'pub run --enable-experiment=non-nullable test --preset travis -x browser' + pub run --enable-experiment=non-nullable test --preset travis -x browser || EXIT_CODE=$? + ;; + dartanalyzer) + echo 'dartanalyzer --enable-experiment=non-nullable --fatal-infos --fatal-warnings .' + dartanalyzer --enable-experiment=non-nullable --fatal-infos --fatal-warnings . || EXIT_CODE=$? + ;; + dartfmt) + echo 'dartfmt -n --set-exit-if-changed .' + dartfmt -n --set-exit-if-changed . || EXIT_CODE=$? ;; *) echo -e "\033[31mNot expecting TASK '${TASK}'. Error!\033[0m" From f28164ffd39dcb4889d1946628e9bb8061be6391 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 13 Nov 2020 17:01:26 -0800 Subject: [PATCH 42/46] Dev versions --- pkgs/test_core/CHANGELOG.md | 2 ++ pkgs/test_core/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 2a4f782ca..168370c92 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.3.12-nullsafety.10-dev + ## 0.3.12-nullsafety.9 * Fix `spawnHybridUri` to respect language versioning of the spawned uri. diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml index 8c55b48a3..5065fb489 100644 --- a/pkgs/test_core/pubspec.yaml +++ b/pkgs/test_core/pubspec.yaml @@ -1,5 +1,5 @@ name: test_core -version: 0.3.12-nullsafety.9 +version: 0.3.12-nullsafety.10-dev description: A basic library for writing tests and running them on the VM. homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core From 735ec36f62066e58c482f7c6cfc4e157ee1a8832 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 23 Jun 2021 12:18:58 -0700 Subject: [PATCH 43/46] Try undoing the port closing - it doesn't currently repro on github actions, will this restore the problem? --- pkgs/test_core/lib/src/runner/spawn_hybrid.dart | 2 -- pkgs/test_core/lib/src/runner/vm/platform.dart | 1 - 2 files changed, 3 deletions(-) diff --git a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart index 9b5b4a8e3..28928284a 100644 --- a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart +++ b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart @@ -54,7 +54,6 @@ StreamChannel spawnHybridUri(String url, Object? message, Suite suite) { var disconnector = Disconnector(); onExitPort.listen((_) { disconnector.disconnect(); - port.close(); onExitPort.close(); }); @@ -63,7 +62,6 @@ StreamChannel spawnHybridUri(String url, Object? message, Suite suite) { .transformSink(StreamSinkTransformer.fromHandlers(handleDone: (sink) { // If the user closes the stream channel, kill the isolate. isolate.kill(); - port.close(); onExitPort.close(); sink.close(); })); diff --git a/pkgs/test_core/lib/src/runner/vm/platform.dart b/pkgs/test_core/lib/src/runner/vm/platform.dart index 9b001cab0..636792d37 100644 --- a/pkgs/test_core/lib/src/runner/vm/platform.dart +++ b/pkgs/test_core/lib/src/runner/vm/platform.dart @@ -63,7 +63,6 @@ class VMPlatform extends PlatformPlugin { StreamSubscription? eventSub; var channel = IsolateChannel.connectReceive(receivePort) .transformStream(StreamTransformer.fromHandlers(handleDone: (sink) { - receivePort.close(); isolate!.kill(); eventSub?.cancel(); client?.dispose(); From 628d062bd4d7f2c7c9870e05446e6a9ad6564f98 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 23 Jun 2021 13:20:43 -0700 Subject: [PATCH 44/46] Revert "Try undoing the port closing - it doesn't currently repro on github actions, will this restore the problem?" This reverts commit 735ec36f62066e58c482f7c6cfc4e157ee1a8832. --- pkgs/test_core/lib/src/runner/spawn_hybrid.dart | 2 ++ pkgs/test_core/lib/src/runner/vm/platform.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart index 28928284a..9b5b4a8e3 100644 --- a/pkgs/test_core/lib/src/runner/spawn_hybrid.dart +++ b/pkgs/test_core/lib/src/runner/spawn_hybrid.dart @@ -54,6 +54,7 @@ StreamChannel spawnHybridUri(String url, Object? message, Suite suite) { var disconnector = Disconnector(); onExitPort.listen((_) { disconnector.disconnect(); + port.close(); onExitPort.close(); }); @@ -62,6 +63,7 @@ StreamChannel spawnHybridUri(String url, Object? message, Suite suite) { .transformSink(StreamSinkTransformer.fromHandlers(handleDone: (sink) { // If the user closes the stream channel, kill the isolate. isolate.kill(); + port.close(); onExitPort.close(); sink.close(); })); diff --git a/pkgs/test_core/lib/src/runner/vm/platform.dart b/pkgs/test_core/lib/src/runner/vm/platform.dart index 636792d37..9b001cab0 100644 --- a/pkgs/test_core/lib/src/runner/vm/platform.dart +++ b/pkgs/test_core/lib/src/runner/vm/platform.dart @@ -63,6 +63,7 @@ class VMPlatform extends PlatformPlugin { StreamSubscription? eventSub; var channel = IsolateChannel.connectReceive(receivePort) .transformStream(StreamTransformer.fromHandlers(handleDone: (sink) { + receivePort.close(); isolate!.kill(); eventSub?.cancel(); client?.dispose(); From 3fed1c9cccbea75c79439c7c2c9ba30bb45bd677 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 23 Jun 2021 14:01:16 -0700 Subject: [PATCH 45/46] Clean up other references --- mono_repo.yaml | 2 -- pkgs/test/CHANGELOG.md | 2 ++ pkgs/test/pubspec.yaml | 4 ++-- pkgs/test/test/runner/runner_test.dart | 3 +-- pkgs/test_core/CHANGELOG.md | 4 ++++ pkgs/test_core/pubspec.yaml | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mono_repo.yaml b/mono_repo.yaml index dc1264e8c..6f8a7da44 100644 --- a/mono_repo.yaml +++ b/mono_repo.yaml @@ -2,8 +2,6 @@ self_validate: analyze_and_format github: - env: - FORCE_TEST_EXIT: true # Setting just `cron` keeps the defaults for `push` and `pull_request` cron: '0 0 * * 0' # “At 00:00 (UTC) on Sunday.” on_completion: diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index c527a3a20..66b7a00da 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -1,3 +1,5 @@ +## 1.17.10-dev + ## 1.17.9 * Fix a bug where a tag level configuration would cause test suites with that diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index c057e5c35..be4babaff 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -1,5 +1,5 @@ name: test -version: 1.17.9 +version: 1.17.10-dev description: >- A full featured library for writing and running Dart tests across platforms. repository: https://github.com/dart-lang/test/blob/master/pkgs/test @@ -34,7 +34,7 @@ dependencies: yaml: ^3.0.0 # Use an exact version until the test_api and test_core package are stable. test_api: 0.4.1 - test_core: 0.3.29 + test_core: 0.3.30 dev_dependencies: fake_async: ^1.0.0 diff --git a/pkgs/test/test/runner/runner_test.dart b/pkgs/test/test/runner/runner_test.dart index 66d4fe4c0..0386fbfef 100644 --- a/pkgs/test/test/runner/runner_test.dart +++ b/pkgs/test/test/runner/runner_test.dart @@ -714,8 +714,7 @@ void main(List args) async { test.completeShutdown(); }''').create(); var test = await runDart(['runner.dart', '--no-color', '--', 'test.dart'], - description: 'dart runner.dart -- test.dart', - environment: {'FORCE_TEST_EXIT': 'false'}); + description: 'dart runner.dart -- test.dart'); expect( test.stdout, emitsThrough(containsInOrder([ diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 60ad7425e..1a6935912 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.30-dev + +* Remove support for `FORCE_TEST_EXIT`. + ## 0.3.29 * Fix a bug where a tag level configuration would cause test suites with that diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml index 7258db508..24878e187 100644 --- a/pkgs/test_core/pubspec.yaml +++ b/pkgs/test_core/pubspec.yaml @@ -1,5 +1,5 @@ name: test_core -version: 0.3.29 +version: 0.3.30-dev description: A basic library for writing tests and running them on the VM. homepage: https://github.com/dart-lang/test/blob/master/pkgs/test_core From 211a5b3c1ed104b546a4bee518f85963aab8c8d0 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 23 Jun 2021 14:02:00 -0700 Subject: [PATCH 46/46] Update mono repo --- .github/workflows/dart.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index d811e268a..66e58798a 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -13,7 +13,6 @@ defaults: shell: bash env: PUB_ENVIRONMENT: bot.github - FORCE_TEST_EXIT: true jobs: job_001: