From a713711a01c0e26bdfff7c7b2be3a042b15aa7fc Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Wed, 3 May 2023 19:24:24 -0700 Subject: [PATCH 1/8] Don't do direct casts to int to prevent dart2wasm breakages. --- pkgs/test/tool/host.dart | 4 ++-- pkgs/test_api/lib/src/backend/metadata.dart | 4 ++-- pkgs/test_core/lib/src/runner/plugin/platform_helpers.dart | 2 +- pkgs/test_core/lib/src/runner/runner_test.dart | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/test/tool/host.dart b/pkgs/test/tool/host.dart index 23d83aec6..c9b171fa6 100644 --- a/pkgs/test/tool/host.dart +++ b/pkgs/test/tool/host.dart @@ -130,9 +130,9 @@ void main() { serverChannel.stream.listen((message) { if (message['command'] == 'loadSuite') { var suiteChannel = - serverChannel.virtualChannel(message['channel'] as int); + serverChannel.virtualChannel((message['channel'] as num).toInt()); var iframeChannel = - _connectToIframe(message['url'] as String, message['id'] as int); + _connectToIframe(message['url'] as String, (message['id'] as num).toInt()); suiteChannel.pipe(iframeChannel); } else if (message['command'] == 'displayPause') { dom.document.body!.classList.add('paused'); diff --git a/pkgs/test_api/lib/src/backend/metadata.dart b/pkgs/test_api/lib/src/backend/metadata.dart index 0404dbfbc..9bf4863ea 100644 --- a/pkgs/test_api/lib/src/backend/metadata.dart +++ b/pkgs/test_api/lib/src/backend/metadata.dart @@ -264,7 +264,7 @@ class Metadata { skipReason = serialized['skipReason'] as String?, _verboseTrace = serialized['verboseTrace'] as bool?, _chainStackTraces = serialized['chainStackTraces'] as bool?, - _retry = serialized['retry'] as int?, + _retry = (serialized['retry'] as num?)?.toInt(), tags = Set.from(serialized['tags'] as Iterable), onPlatform = { for (var pair in serialized['onPlatform'] as List) @@ -282,7 +282,7 @@ class Metadata { if (serialized == 'none') return Timeout.none; var scaleFactor = serialized['scaleFactor']; if (scaleFactor != null) return Timeout.factor(scaleFactor as num); - return Timeout(Duration(microseconds: serialized['duration'] as int)); + return Timeout(Duration(microseconds: (serialized['duration'] as num).toInt())); } /// Throws an [ArgumentError] if any tags in [tags] aren't hyphenated diff --git a/pkgs/test_core/lib/src/runner/plugin/platform_helpers.dart b/pkgs/test_core/lib/src/runner/plugin/platform_helpers.dart index 660c4374b..58e9f2483 100644 --- a/pkgs/test_core/lib/src/runner/plugin/platform_helpers.dart +++ b/pkgs/test_core/lib/src/runner/plugin/platform_helpers.dart @@ -155,7 +155,7 @@ class _Deserializer { var metadata = Metadata.deserialize(test['metadata']); var trace = test['trace'] == null ? null : Trace.parse(test['trace'] as String); - var testChannel = _channel.virtualChannel(test['channel'] as int); + var testChannel = _channel.virtualChannel((test['channel'] as num).toInt()); return RunnerTest(test['name'] as String, metadata, trace, testChannel); } } diff --git a/pkgs/test_core/lib/src/runner/runner_test.dart b/pkgs/test_core/lib/src/runner/runner_test.dart index 68658da9f..da75458aa 100644 --- a/pkgs/test_core/lib/src/runner/runner_test.dart +++ b/pkgs/test_core/lib/src/runner/runner_test.dart @@ -70,7 +70,7 @@ class RunnerTest extends Test { // this virtual channel and cause the spawned isolate to close as // well. spawnHybridUri(message['url'] as String, message['message'], suite) - .pipe(testChannel.virtualChannel(message['channel'] as int)); + .pipe(testChannel.virtualChannel((message['channel'] as num).toInt())); break; } }, onDone: () { From 4b77c214a31afa71757483f445241c0457b637f1 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Wed, 3 May 2023 21:25:34 -0700 Subject: [PATCH 2/8] Dart format. --- pkgs/test/tool/host.dart | 4 ++-- pkgs/test_api/lib/src/backend/metadata.dart | 3 ++- pkgs/test_core/lib/src/runner/runner_test.dart | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/test/tool/host.dart b/pkgs/test/tool/host.dart index c9b171fa6..5ba8b06ba 100644 --- a/pkgs/test/tool/host.dart +++ b/pkgs/test/tool/host.dart @@ -131,8 +131,8 @@ void main() { if (message['command'] == 'loadSuite') { var suiteChannel = serverChannel.virtualChannel((message['channel'] as num).toInt()); - var iframeChannel = - _connectToIframe(message['url'] as String, (message['id'] as num).toInt()); + var iframeChannel = _connectToIframe( + message['url'] as String, (message['id'] as num).toInt()); suiteChannel.pipe(iframeChannel); } else if (message['command'] == 'displayPause') { dom.document.body!.classList.add('paused'); diff --git a/pkgs/test_api/lib/src/backend/metadata.dart b/pkgs/test_api/lib/src/backend/metadata.dart index 9bf4863ea..59ffa5c78 100644 --- a/pkgs/test_api/lib/src/backend/metadata.dart +++ b/pkgs/test_api/lib/src/backend/metadata.dart @@ -282,7 +282,8 @@ class Metadata { if (serialized == 'none') return Timeout.none; var scaleFactor = serialized['scaleFactor']; if (scaleFactor != null) return Timeout.factor(scaleFactor as num); - return Timeout(Duration(microseconds: (serialized['duration'] as num).toInt())); + return Timeout( + Duration(microseconds: (serialized['duration'] as num).toInt())); } /// Throws an [ArgumentError] if any tags in [tags] aren't hyphenated diff --git a/pkgs/test_core/lib/src/runner/runner_test.dart b/pkgs/test_core/lib/src/runner/runner_test.dart index da75458aa..35bdecfc0 100644 --- a/pkgs/test_core/lib/src/runner/runner_test.dart +++ b/pkgs/test_core/lib/src/runner/runner_test.dart @@ -70,7 +70,8 @@ class RunnerTest extends Test { // this virtual channel and cause the spawned isolate to close as // well. spawnHybridUri(message['url'] as String, message['message'], suite) - .pipe(testChannel.virtualChannel((message['channel'] as num).toInt())); + .pipe(testChannel + .virtualChannel((message['channel'] as num).toInt())); break; } }, onDone: () { From 39bc95a77dc8942f9e5e8bbf26a9ad27d9ccc62b Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 4 May 2023 13:26:13 -0700 Subject: [PATCH 3/8] Have wasm unit tests pass `--timeout` and `--retry`. --- .github/workflows/dart.yml | 12 ++++++------ integration_tests/wasm/mono_pkg.yaml | 2 +- tool/ci.sh | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 55e48f9d4..fe7fdee14 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.5.4 +# Created with package:mono_repo v6.5.5 name: Dart CI on: push: @@ -36,7 +36,7 @@ jobs: name: Checkout repository uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - name: mono_repo self validate - run: dart pub global activate mono_repo 6.5.4 + run: dart pub global activate mono_repo 6.5.5 - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: @@ -1033,14 +1033,14 @@ jobs: - job_005 - job_006 job_027: - name: "unit_test; linux; Dart main; PKG: integration_tests/wasm; `pushd /tmp && wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb && sudo dpkg -i google-chrome-beta_current_amd64.deb && popd && which google-chrome-beta`, `dart test`" + name: "unit_test; linux; Dart main; PKG: integration_tests/wasm; `pushd /tmp && wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb && sudo dpkg -i google-chrome-beta_current_amd64.deb && popd && which google-chrome-beta`, `dart test --timeout=60s --retry=2`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:main;packages:integration_tests/wasm;commands:command_00-command_01" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:main;packages:integration_tests/wasm;commands:command_00-test_1" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:main;packages:integration_tests/wasm os:ubuntu-latest;pub-cache-hosted;sdk:main @@ -1062,8 +1062,8 @@ jobs: run: "pushd /tmp && wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb && sudo dpkg -i google-chrome-beta_current_amd64.deb && popd && which google-chrome-beta" if: "always() && steps.integration_tests_wasm_pub_upgrade.conclusion == 'success'" working-directory: integration_tests/wasm - - name: integration_tests/wasm; dart test - run: dart test + - name: "integration_tests/wasm; dart test --timeout=60s --retry=2" + run: "dart test --timeout=60s --retry=2" if: "always() && steps.integration_tests_wasm_pub_upgrade.conclusion == 'success'" working-directory: integration_tests/wasm needs: diff --git a/integration_tests/wasm/mono_pkg.yaml b/integration_tests/wasm/mono_pkg.yaml index b360a9986..c2f5ace5f 100644 --- a/integration_tests/wasm/mono_pkg.yaml +++ b/integration_tests/wasm/mono_pkg.yaml @@ -18,6 +18,6 @@ stages: - which google-chrome-beta os: - linux - - test: + - test: --timeout=60s --retry=2 os: - linux diff --git a/tool/ci.sh b/tool/ci.sh index 11c9fa32a..6d39dd237 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Created with package:mono_repo v6.5.4 +# Created with package:mono_repo v6.5.5 # Support built in commands on windows out of the box. # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") @@ -135,6 +135,10 @@ for PKG in ${PKGS}; do echo 'dart test -p chrome,vm,node' dart test -p chrome,vm,node || EXIT_CODE=$? ;; + test_1) + echo 'dart test --timeout=60s --retry=2' + dart test --timeout=60s --retry=2 || EXIT_CODE=$? + ;; *) echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m" exit 64 From 97b65ced0930afdec3acfae139bd169b71a44635 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 4 May 2023 20:32:23 +0000 Subject: [PATCH 4/8] Bump to -wip version in test_api Fix dependencies in test to use the latest test_core in addition to the latest test_api --- pkgs/test/CHANGELOG.md | 2 ++ pkgs/test/pubspec.yaml | 4 ++-- pkgs/test_api/CHANGELOG.md | 4 ++++ pkgs/test_api/pubspec.yaml | 2 +- pkgs/test_core/CHANGELOG.md | 2 ++ pkgs/test_core/pubspec.yaml | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 828fb16fd..8c0254eca 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -1,5 +1,7 @@ ## 1.24.3-wip +* Fix compatibility with wasm number semantics. + ## 1.24.2 * Copy an existing nonce from a script on the test HTML page to the script diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 58cb29648..8667d3698 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -32,8 +32,8 @@ dependencies: webkit_inspection_protocol: ^1.0.0 yaml: ^3.0.0 # Use an exact version until the test_api and test_core package are stable. - test_api: 0.5.2 - test_core: 0.5.2 + test_api: 0.5.3 + test_core: 0.5.3 # Use a tight version constraint to ensure that a constraint on matcher # properly constrains all features it provides. matcher: '>=0.12.15 <0.12.16' diff --git a/pkgs/test_api/CHANGELOG.md b/pkgs/test_api/CHANGELOG.md index ec38d0ca0..4d79f0a59 100644 --- a/pkgs/test_api/CHANGELOG.md +++ b/pkgs/test_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.3-wip + +* Fix compatibility with wasm number semantics. + ## 0.5.2 * Remove deprecation for the `scaffolding.dart` and `backend.dart` libraries. diff --git a/pkgs/test_api/pubspec.yaml b/pkgs/test_api/pubspec.yaml index 91e0126ab..651b4b9c5 100644 --- a/pkgs/test_api/pubspec.yaml +++ b/pkgs/test_api/pubspec.yaml @@ -1,5 +1,5 @@ name: test_api -version: 0.5.2 +version: 0.5.3-wip description: >- The user facing API for structuring Dart tests and checking expectations. repository: https://github.com/dart-lang/test/tree/master/pkgs/test_api diff --git a/pkgs/test_core/CHANGELOG.md b/pkgs/test_core/CHANGELOG.md index 6542bf473..2f6be0845 100644 --- a/pkgs/test_core/CHANGELOG.md +++ b/pkgs/test_core/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.5.3-wip +* Fix compatibility with wasm number semantics. + ## 0.5.2 * Use the version `0.5.2` of `packge:test_api`. diff --git a/pkgs/test_core/pubspec.yaml b/pkgs/test_core/pubspec.yaml index 6cf8cb15e..a19ded379 100644 --- a/pkgs/test_core/pubspec.yaml +++ b/pkgs/test_core/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: # matcher is tightly constrained by test_api matcher: ^0.12.11 # Use an exact version until the test_api package is stable. - test_api: 0.5.2 + test_api: 0.5.3 dev_dependencies: lints: '>=1.0.0 <3.0.0' From 47c6c628536c56651968e893deb49522199a2b79 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 4 May 2023 14:35:25 -0700 Subject: [PATCH 5/8] Use an annotation for @Retry instead of a command line flag. --- .github/workflows/dart.yml | 6 +++--- integration_tests/wasm/mono_pkg.yaml | 2 +- integration_tests/wasm/test/hello_world_test.dart | 3 +++ tool/ci.sh | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index fe7fdee14..506c6be54 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1033,7 +1033,7 @@ jobs: - job_005 - job_006 job_027: - name: "unit_test; linux; Dart main; PKG: integration_tests/wasm; `pushd /tmp && wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb && sudo dpkg -i google-chrome-beta_current_amd64.deb && popd && which google-chrome-beta`, `dart test --timeout=60s --retry=2`" + name: "unit_test; linux; Dart main; PKG: integration_tests/wasm; `pushd /tmp && wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb && sudo dpkg -i google-chrome-beta_current_amd64.deb && popd && which google-chrome-beta`, `dart test --timeout=60s`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies @@ -1062,8 +1062,8 @@ jobs: run: "pushd /tmp && wget https://dl.google.com/linux/direct/google-chrome-beta_current_amd64.deb && sudo dpkg -i google-chrome-beta_current_amd64.deb && popd && which google-chrome-beta" if: "always() && steps.integration_tests_wasm_pub_upgrade.conclusion == 'success'" working-directory: integration_tests/wasm - - name: "integration_tests/wasm; dart test --timeout=60s --retry=2" - run: "dart test --timeout=60s --retry=2" + - name: "integration_tests/wasm; dart test --timeout=60s" + run: "dart test --timeout=60s" if: "always() && steps.integration_tests_wasm_pub_upgrade.conclusion == 'success'" working-directory: integration_tests/wasm needs: diff --git a/integration_tests/wasm/mono_pkg.yaml b/integration_tests/wasm/mono_pkg.yaml index c2f5ace5f..b95f5a851 100644 --- a/integration_tests/wasm/mono_pkg.yaml +++ b/integration_tests/wasm/mono_pkg.yaml @@ -18,6 +18,6 @@ stages: - which google-chrome-beta os: - linux - - test: --timeout=60s --retry=2 + - test: --timeout=60s os: - linux diff --git a/integration_tests/wasm/test/hello_world_test.dart b/integration_tests/wasm/test/hello_world_test.dart index 5d911a79f..ff3dd7852 100644 --- a/integration_tests/wasm/test/hello_world_test.dart +++ b/integration_tests/wasm/test/hello_world_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @TestOn('wasm') +@Retry(2) +library; + import 'package:test/test.dart'; void main() { diff --git a/tool/ci.sh b/tool/ci.sh index 6d39dd237..b6efae0f9 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -136,8 +136,8 @@ for PKG in ${PKGS}; do dart test -p chrome,vm,node || EXIT_CODE=$? ;; test_1) - echo 'dart test --timeout=60s --retry=2' - dart test --timeout=60s --retry=2 || EXIT_CODE=$? + echo 'dart test --timeout=60s' + dart test --timeout=60s || EXIT_CODE=$? ;; *) echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m" From bb55324a433f7a2e3c7d40e947db1f53a155f13b Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 4 May 2023 14:37:37 -0700 Subject: [PATCH 6/8] Add comment about regression test. --- integration_tests/wasm/mono_pkg.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/integration_tests/wasm/mono_pkg.yaml b/integration_tests/wasm/mono_pkg.yaml index b95f5a851..b09a8da9d 100644 --- a/integration_tests/wasm/mono_pkg.yaml +++ b/integration_tests/wasm/mono_pkg.yaml @@ -18,6 +18,7 @@ stages: - which google-chrome-beta os: - linux + # The config here is a regression test for https://github.com/dart-lang/test/issues/2006 - test: --timeout=60s os: - linux From 2bd49860ab9d5e853ccd2ca49922a06555cc72f8 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Thu, 4 May 2023 14:39:36 -0700 Subject: [PATCH 7/8] Don't use unnamed library. --- integration_tests/wasm/test/hello_world_test.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integration_tests/wasm/test/hello_world_test.dart b/integration_tests/wasm/test/hello_world_test.dart index ff3dd7852..f456988dc 100644 --- a/integration_tests/wasm/test/hello_world_test.dart +++ b/integration_tests/wasm/test/hello_world_test.dart @@ -1,10 +1,9 @@ // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. + @TestOn('wasm') @Retry(2) -library; - import 'package:test/test.dart'; void main() { From 9b6143760ae0699602d681f85ea6395535622430 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 5 May 2023 08:48:44 -0700 Subject: [PATCH 8/8] Update integration_tests/wasm/test/hello_world_test.dart Co-authored-by: Jacob MacDonald --- integration_tests/wasm/test/hello_world_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/integration_tests/wasm/test/hello_world_test.dart b/integration_tests/wasm/test/hello_world_test.dart index f456988dc..40d4a74f3 100644 --- a/integration_tests/wasm/test/hello_world_test.dart +++ b/integration_tests/wasm/test/hello_world_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('wasm') +// This retry is a regression test for https://github.com/dart-lang/test/issues/2006 @Retry(2) import 'package:test/test.dart';