From 6137a2234ac8807af2b9cace2d2800157c1c0e72 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Mon, 15 Sep 2025 18:18:24 +0200 Subject: [PATCH] Refactor `_test` into `integration_tests`. --- .github/workflows/dart.yml | 677 ++++++------------ _test/.gitignore | 9 - _test/LICENSE | 27 - _test/analysis_options.yaml | 7 - _test/build.both.yaml | 26 - _test/build.dart2js.yaml | 25 - _test/build.dart2wasm.yaml | 31 - _test/build.post_process.yaml | 19 - _test/build.yaml | 15 - _test/dart_test.yaml | 22 - _test/lib/app.dart | 12 - _test/lib/hello.txt | 1 - _test/mono_pkg.yaml | 31 - _test/pkgs/provides_builder/build.yaml | 23 - _test/pkgs/provides_builder/lib/builders.dart | 77 -- _test/pkgs/provides_builder/pubspec.yaml | 9 - _test/pubspec.yaml | 26 - _test/test/build_integration_test.dart | 147 ---- _test/test/common/message.dart | 5 - _test/test/common/message_export.dart | 8 - _test/test/common/message_html.dart | 5 - _test/test/common/message_io.dart | 5 - .../test/common/message_js_without_html.dart | 5 - _test/test/common/utils.dart | 274 ------- _test/test/configurable_uri_test.dart | 44 -- _test/test/dart2js_integration_test.dart | 102 --- _test/test/dart2wasm_integration_test.dart | 86 --- .../generated_script_integration_test.dart | 27 - .../test/goldens/generated_build_script.dart | 182 ----- _test/test/hello_world_custom_html_test.dart | 15 - _test/test/hello_world_custom_html_test.html | 12 - _test/test/hello_world_deferred_test.dart | 27 - _test/test/hello_world_test.dart | 32 - _test/test/serve_integration_test.dart | 260 ------- _test/test/sub-dir/subdir_source.dart | 10 - _test/test/sub-dir/subdir_test.dart | 12 - _test/test/subdir_source_test.dart | 44 -- _test/test/test_integration_test.dart | 93 --- _test/web/dir_without_index/hello.txt | 1 - _test/web/index.html | 14 - _test/web/main.dart | 14 - _test/web/sub/index.html | 14 - _test/web/sub/main.dart | 5 - _test/web/sub/message.dart | 3 - build_runner/dart_test.yaml | 2 + build_runner/mono_pkg.yaml | 9 +- .../test/common/build_runner_tester.dart | 48 +- ...ild_command_post_process_builder_test.dart | 133 ++++ .../build_command_resolve_test.dart | 77 ++ ...erve_command_serve_only_required_test.dart | 6 +- .../integration_tests/serve_command_test.dart | 38 +- .../integration_tests/web_compilers_test.dart | 152 ++++ pubspec.yaml | 2 - tool/ci.sh | 42 +- 54 files changed, 657 insertions(+), 2335 deletions(-) delete mode 100644 _test/.gitignore delete mode 100644 _test/LICENSE delete mode 100644 _test/analysis_options.yaml delete mode 100644 _test/build.both.yaml delete mode 100644 _test/build.dart2js.yaml delete mode 100644 _test/build.dart2wasm.yaml delete mode 100644 _test/build.post_process.yaml delete mode 100644 _test/build.yaml delete mode 100644 _test/dart_test.yaml delete mode 100644 _test/lib/app.dart delete mode 100644 _test/lib/hello.txt delete mode 100644 _test/mono_pkg.yaml delete mode 100644 _test/pkgs/provides_builder/build.yaml delete mode 100644 _test/pkgs/provides_builder/lib/builders.dart delete mode 100644 _test/pkgs/provides_builder/pubspec.yaml delete mode 100644 _test/pubspec.yaml delete mode 100644 _test/test/build_integration_test.dart delete mode 100644 _test/test/common/message.dart delete mode 100644 _test/test/common/message_export.dart delete mode 100644 _test/test/common/message_html.dart delete mode 100644 _test/test/common/message_io.dart delete mode 100644 _test/test/common/message_js_without_html.dart delete mode 100644 _test/test/common/utils.dart delete mode 100644 _test/test/configurable_uri_test.dart delete mode 100644 _test/test/dart2js_integration_test.dart delete mode 100644 _test/test/dart2wasm_integration_test.dart delete mode 100644 _test/test/generated_script_integration_test.dart delete mode 100644 _test/test/goldens/generated_build_script.dart delete mode 100644 _test/test/hello_world_custom_html_test.dart delete mode 100644 _test/test/hello_world_custom_html_test.html delete mode 100644 _test/test/hello_world_deferred_test.dart delete mode 100644 _test/test/hello_world_test.dart delete mode 100644 _test/test/serve_integration_test.dart delete mode 100644 _test/test/sub-dir/subdir_source.dart delete mode 100644 _test/test/sub-dir/subdir_test.dart delete mode 100644 _test/test/subdir_source_test.dart delete mode 100644 _test/test/test_integration_test.dart delete mode 100644 _test/web/dir_without_index/hello.txt delete mode 100644 _test/web/index.html delete mode 100644 _test/web/main.dart delete mode 100644 _test/web/sub/index.html delete mode 100644 _test/web/sub/main.dart delete mode 100644 _test/web/sub/message.dart create mode 100644 build_runner/test/integration_tests/build_command_post_process_builder_test.dart create mode 100644 build_runner/test/integration_tests/build_command_resolve_test.dart create mode 100644 build_runner/test/integration_tests/web_compilers_test.dart diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 5d07073e87..5fe3cfe827 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -38,16 +38,16 @@ jobs: - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyze_and_format; linux; PKGS: _benchmark, _test, build, build_config, build_daemon, build_modules, build_runner, build_test, build_web_compilers, example, scratch_space; `dart analyze --fatal-infos .`" + name: "analyze_and_format; linux; PKGS: _benchmark, build, build_config, build_daemon, build_modules, build_runner, build_test, build_web_compilers, example, scratch_space; `dart analyze --fatal-infos .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-_test-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space;commands:analyze" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space;commands:analyze" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-_test-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -67,15 +67,6 @@ jobs: run: dart analyze --fatal-infos . if: "always() && steps._benchmark_pub_upgrade.conclusion == 'success'" working-directory: _benchmark - - id: _test_pub_upgrade - name: _test; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart analyze --fatal-infos ." - run: dart analyze --fatal-infos . - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test - id: build_pub_upgrade name: build; dart pub upgrade run: dart pub upgrade @@ -158,16 +149,16 @@ jobs: if: "always() && steps.scratch_space_pub_upgrade.conclusion == 'success'" working-directory: scratch_space job_003: - name: "analyze_and_format; linux; PKGS: _benchmark, _test, build, build_config, build_daemon, build_modules, build_runner, build_test, build_web_compilers, example, scratch_space; `dart format --output=none --set-exit-if-changed .`" + name: "analyze_and_format; linux; PKGS: _benchmark, build, build_config, build_daemon, build_modules, build_runner, build_test, build_web_compilers, example, scratch_space; `dart format --output=none --set-exit-if-changed .`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-_test-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space;commands:format" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space;commands:format" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-_test-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_benchmark-build-build_config-build_daemon-build_modules-build_runner-build_test-build_web_compilers-example-scratch_space os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -187,15 +178,6 @@ jobs: run: "dart format --output=none --set-exit-if-changed ." if: "always() && steps._benchmark_pub_upgrade.conclusion == 'success'" working-directory: _benchmark - - id: _test_pub_upgrade - name: _test; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart format --output=none --set-exit-if-changed ." - run: "dart format --output=none --set-exit-if-changed ." - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test - id: build_pub_upgrade name: build; dart pub upgrade run: dart pub upgrade @@ -278,16 +260,16 @@ jobs: if: "always() && steps.scratch_space_pub_upgrade.conclusion == 'success'" working-directory: scratch_space job_004: - name: "unit_test; linux; PKG: _test; `dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random`" + name: "test; linux; PKG: build_runner; `../tool/leak_check.sh`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test;commands:command_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:command" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -298,30 +280,30 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_runner_pub_upgrade + name: build_runner; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random" - run: "dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_runner + - name: build_runner; ../tool/leak_check.sh + run: ../tool/leak_check.sh + if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" + working-directory: build_runner needs: - job_001 - job_002 - job_003 job_005: - name: "unit_test; linux; PKG: _test; `dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random`" + name: "test; linux; PKG: build_runner; `dart test -P experiments --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test;commands:command_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_3" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -332,266 +314,28 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_runner_pub_upgrade + name: build_runner; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random" - run: "dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_runner + - name: "build_runner; dart test -P experiments --test-randomize-ordering-seed=random" + run: "dart test -P experiments --test-randomize-ordering-seed=random" + if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" + working-directory: build_runner needs: - job_001 - job_002 - job_003 job_006: - name: "unit_test; linux; PKG: build; `dart test --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build;commands:test_3" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_pub_upgrade - name: build; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build - - name: "build; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.build_pub_upgrade.conclusion == 'success'" - working-directory: build - needs: - - job_001 - - job_002 - - job_003 - job_007: - name: "unit_test; linux; PKG: build_config; `dart test --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_config;commands:test_3" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_config - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_config_pub_upgrade - name: build_config; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_config - - name: "build_config; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.build_config_pub_upgrade.conclusion == 'success'" - working-directory: build_config - needs: - - job_001 - - job_002 - - job_003 - job_008: - name: "unit_test; linux; PKG: build_daemon; `dart test --test-randomize-ordering-seed=random`" + name: "test; linux; PKG: build_runner; `dart test -t integration1 --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_daemon;commands:test_3" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_daemon - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_daemon_pub_upgrade - name: build_daemon; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_daemon - - name: "build_daemon; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.build_daemon_pub_upgrade.conclusion == 'success'" - working-directory: build_daemon - needs: - - job_001 - - job_002 - - job_003 - job_009: - name: "unit_test; linux; PKG: build_test; `dart test --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_test;commands:test_3" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_test - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_test_pub_upgrade - name: build_test; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_test - - name: "build_test; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.build_test_pub_upgrade.conclusion == 'success'" - working-directory: build_test - needs: - - job_001 - - job_002 - - job_003 - job_010: - name: "unit_test; linux; PKG: build_web_compilers; `dart test --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_web_compilers;commands:test_3" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_web_compilers - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_web_compilers_pub_upgrade - name: build_web_compilers; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_web_compilers - - name: "build_web_compilers; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.build_web_compilers_pub_upgrade.conclusion == 'success'" - working-directory: build_web_compilers - needs: - - job_001 - - job_002 - - job_003 - job_011: - name: "unit_test; linux; PKG: scratch_space; `dart test --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:scratch_space;commands:test_3" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:scratch_space - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: scratch_space_pub_upgrade - name: scratch_space; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: scratch_space - - name: "scratch_space; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.scratch_space_pub_upgrade.conclusion == 'success'" - working-directory: scratch_space - needs: - - job_001 - - job_002 - - job_003 - job_012: - name: "unit_test; linux; PKG: build_modules; `dart test -P presubmit --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_modules;commands:test_4" - restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_modules - os:ubuntu-latest;pub-cache-hosted;sdk:dev - os:ubuntu-latest;pub-cache-hosted - os:ubuntu-latest - - name: Setup Dart SDK - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 - with: - sdk: dev - - id: checkout - name: Checkout repository - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_modules_pub_upgrade - name: build_modules; dart pub upgrade - run: dart pub upgrade - if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_modules - - name: "build_modules; dart test -P presubmit --test-randomize-ordering-seed=random" - run: "dart test -P presubmit --test-randomize-ordering-seed=random" - if: "always() && steps.build_modules_pub_upgrade.conclusion == 'success'" - working-directory: build_modules - needs: - - job_001 - - job_002 - - job_003 - job_013: - name: "unit_test; linux; PKG: build_runner; `dart test -P experiments --test-randomize-ordering-seed=random`" - runs-on: ubuntu-latest - steps: - - name: Cache Pub hosted dependencies - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 - with: - path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_6" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_4" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -609,23 +353,23 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -P experiments --test-randomize-ordering-seed=random" - run: "dart test -P experiments --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -t integration1 --test-randomize-ordering-seed=random" + run: "dart test -t integration1 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_014: - name: "unit_test; linux; PKG: build_runner; `dart test -t integration1 --test-randomize-ordering-seed=random`" + job_007: + name: "test; linux; PKG: build_runner; `dart test -t integration2 --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_7" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_5" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -643,23 +387,23 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -t integration1 --test-randomize-ordering-seed=random" - run: "dart test -t integration1 --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -t integration2 --test-randomize-ordering-seed=random" + run: "dart test -t integration2 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_015: - name: "unit_test; linux; PKG: build_runner; `dart test -t integration2 --test-randomize-ordering-seed=random`" + job_008: + name: "test; linux; PKG: build_runner; `dart test -t integration3 --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_8" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_6" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -677,23 +421,23 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -t integration2 --test-randomize-ordering-seed=random" - run: "dart test -t integration2 --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -t integration3 --test-randomize-ordering-seed=random" + run: "dart test -t integration3 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_016: - name: "unit_test; linux; PKG: build_runner; `dart test -t integration3 --test-randomize-ordering-seed=random`" + job_009: + name: "test; linux; PKG: build_runner; `dart test -t integration4 --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_9" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_7" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -711,23 +455,23 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -t integration3 --test-randomize-ordering-seed=random" - run: "dart test -t integration3 --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -t integration4 --test-randomize-ordering-seed=random" + run: "dart test -t integration4 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_017: - name: "unit_test; linux; PKG: build_runner; `dart test -x integration1 -x integration2 -x integration3 --test-randomize-ordering-seed=random`" + job_010: + name: "test; linux; PKG: build_runner; `dart test -x integration1 -x integration2 -x integration3 -x integration4 --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_5" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:test_2" restore-keys: | os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner os:ubuntu-latest;pub-cache-hosted;sdk:dev @@ -745,16 +489,16 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -x integration1 -x integration2 -x integration3 --test-randomize-ordering-seed=random" - run: "dart test -x integration1 -x integration2 -x integration3 --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -x integration1 -x integration2 -x integration3 -x integration4 --test-randomize-ordering-seed=random" + run: "dart test -x integration1 -x integration2 -x integration3 -x integration4 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_018: - name: "unit_test; windows; PKG: _test; `dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random`" + job_011: + name: "test; windows; PKG: build_runner; `dart test -t integration1 --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK @@ -764,21 +508,21 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_runner_pub_upgrade + name: build_runner; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random" - run: "dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_runner + - name: "build_runner; dart test -t integration1 --test-randomize-ordering-seed=random" + run: "dart test -t integration1 --test-randomize-ordering-seed=random" + if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" + working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_019: - name: "unit_test; windows; PKG: build_daemon; `dart test --test-randomize-ordering-seed=random`" + job_012: + name: "test; windows; PKG: build_runner; `dart test -t integration2 --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK @@ -788,21 +532,21 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_daemon_pub_upgrade - name: build_daemon; dart pub upgrade + - id: build_runner_pub_upgrade + name: build_runner; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_daemon - - name: "build_daemon; dart test --test-randomize-ordering-seed=random" - run: "dart test --test-randomize-ordering-seed=random" - if: "always() && steps.build_daemon_pub_upgrade.conclusion == 'success'" - working-directory: build_daemon + working-directory: build_runner + - name: "build_runner; dart test -t integration2 --test-randomize-ordering-seed=random" + run: "dart test -t integration2 --test-randomize-ordering-seed=random" + if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" + working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_020: - name: "unit_test; windows; PKG: build_runner; `dart test -t integration1 --test-randomize-ordering-seed=random`" + job_013: + name: "test; windows; PKG: build_runner; `dart test -t integration3 --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK @@ -817,16 +561,16 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -t integration1 --test-randomize-ordering-seed=random" - run: "dart test -t integration1 --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -t integration3 --test-randomize-ordering-seed=random" + run: "dart test -t integration3 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_021: - name: "unit_test; windows; PKG: build_runner; `dart test -t integration2 --test-randomize-ordering-seed=random`" + job_014: + name: "test; windows; PKG: build_runner; `dart test -t integration4 --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK @@ -841,18 +585,28 @@ jobs: run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" working-directory: build_runner - - name: "build_runner; dart test -t integration2 --test-randomize-ordering-seed=random" - run: "dart test -t integration2 --test-randomize-ordering-seed=random" + - name: "build_runner; dart test -t integration4 --test-randomize-ordering-seed=random" + run: "dart test -t integration4 --test-randomize-ordering-seed=random" if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" working-directory: build_runner needs: - job_001 - job_002 - job_003 - job_022: - name: "unit_test; windows; PKG: build_runner; `dart test -t integration3 --test-randomize-ordering-seed=random`" - runs-on: windows-latest + job_015: + name: "unit_test; linux; PKG: build; `dart test --test-randomize-ordering-seed=random`" + runs-on: ubuntu-latest steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build;commands:test_0" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build + os:ubuntu-latest;pub-cache-hosted;sdk:dev + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: @@ -860,30 +614,41 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_runner_pub_upgrade - name: build_runner; dart pub upgrade + - id: build_pub_upgrade + name: build; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_runner - - name: "build_runner; dart test -t integration3 --test-randomize-ordering-seed=random" - run: "dart test -t integration3 --test-randomize-ordering-seed=random" - if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" - working-directory: build_runner + working-directory: build + - name: "build; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.build_pub_upgrade.conclusion == 'success'" + working-directory: build needs: - job_001 - job_002 - job_003 - job_023: - name: "leak_check; linux; PKG: build_runner; `../tool/leak_check.sh`" + - job_004 + - job_005 + - job_006 + - job_007 + - job_008 + - job_009 + - job_010 + - job_011 + - job_012 + - job_013 + - job_014 + job_016: + name: "unit_test; linux; PKG: build_config; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner;commands:command_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_config;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_runner + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_config os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -894,15 +659,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: build_runner_pub_upgrade - name: build_runner; dart pub upgrade + - id: build_config_pub_upgrade + name: build_config; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: build_runner - - name: build_runner; ../tool/leak_check.sh - run: ../tool/leak_check.sh - if: "always() && steps.build_runner_pub_upgrade.conclusion == 'success'" - working-directory: build_runner + working-directory: build_config + - name: "build_config; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.build_config_pub_upgrade.conclusion == 'success'" + working-directory: build_config needs: - job_001 - job_002 @@ -918,25 +683,17 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - job_024: - name: "e2e_test; linux; PKG: _test; `dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random`" + job_017: + name: "unit_test; linux; PKG: build_daemon; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_daemon;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_daemon os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -947,15 +704,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_daemon_pub_upgrade + name: build_daemon; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random" - run: "dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_daemon + - name: "build_daemon; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.build_daemon_pub_upgrade.conclusion == 'success'" + working-directory: build_daemon needs: - job_001 - job_002 @@ -971,26 +728,17 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - - job_023 - job_025: - name: "e2e_test; linux; PKG: _test; `dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random`" + job_018: + name: "unit_test; linux; PKG: build_test; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_test;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_test os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -1001,15 +749,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_test_pub_upgrade + name: build_test; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random" - run: "dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_test + - name: "build_test; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.build_test_pub_upgrade.conclusion == 'success'" + working-directory: build_test needs: - job_001 - job_002 @@ -1025,26 +773,17 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - - job_023 - job_026: - name: "e2e_test; linux; PKG: _test; `dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random`" + job_019: + name: "unit_test; linux; PKG: build_web_compilers; `dart test --test-randomize-ordering-seed=random`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test;commands:test_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_web_compilers;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:_test + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_web_compilers os:ubuntu-latest;pub-cache-hosted;sdk:dev os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest @@ -1055,15 +794,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_web_compilers_pub_upgrade + name: build_web_compilers; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random" - run: "dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_web_compilers + - name: "build_web_compilers; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.build_web_compilers_pub_upgrade.conclusion == 'success'" + working-directory: build_web_compilers needs: - job_001 - job_002 @@ -1079,19 +818,20 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - - job_023 - job_027: - name: "e2e_test; windows; PKG: _test; `dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random`" - runs-on: windows-latest + job_020: + name: "unit_test; linux; PKG: scratch_space; `dart test --test-randomize-ordering-seed=random`" + runs-on: ubuntu-latest steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:scratch_space;commands:test_0" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:scratch_space + os:ubuntu-latest;pub-cache-hosted;sdk:dev + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: @@ -1099,15 +839,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: scratch_space_pub_upgrade + name: scratch_space; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random" - run: "dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: scratch_space + - name: "scratch_space; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.scratch_space_pub_upgrade.conclusion == 'success'" + working-directory: scratch_space needs: - job_001 - job_002 @@ -1123,19 +863,20 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - - job_023 - job_028: - name: "e2e_test; windows; PKG: _test; `dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random`" - runs-on: windows-latest + job_021: + name: "unit_test; linux; PKG: build_modules; `dart test -P presubmit --test-randomize-ordering-seed=random`" + runs-on: ubuntu-latest steps: + - name: Cache Pub hosted dependencies + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 + with: + path: "~/.pub-cache/hosted" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_modules;commands:test_1" + restore-keys: | + os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:build_modules + os:ubuntu-latest;pub-cache-hosted;sdk:dev + os:ubuntu-latest;pub-cache-hosted + os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: @@ -1143,15 +884,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_modules_pub_upgrade + name: build_modules; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random" - run: "dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_modules + - name: "build_modules; dart test -P presubmit --test-randomize-ordering-seed=random" + run: "dart test -P presubmit --test-randomize-ordering-seed=random" + if: "always() && steps.build_modules_pub_upgrade.conclusion == 'success'" + working-directory: build_modules needs: - job_001 - job_002 @@ -1167,17 +908,8 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - - job_023 - job_029: - name: "e2e_test; windows; PKG: _test; `dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random`" + job_022: + name: "unit_test; windows; PKG: build_daemon; `dart test --test-randomize-ordering-seed=random`" runs-on: windows-latest steps: - name: Setup Dart SDK @@ -1187,15 +919,15 @@ jobs: - id: checkout name: Checkout repository uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - id: _test_pub_upgrade - name: _test; dart pub upgrade + - id: build_daemon_pub_upgrade + name: build_daemon; dart pub upgrade run: dart pub upgrade if: "always() && steps.checkout.conclusion == 'success'" - working-directory: _test - - name: "_test; dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random" - run: "dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random" - if: "always() && steps._test_pub_upgrade.conclusion == 'success'" - working-directory: _test + working-directory: build_daemon + - name: "build_daemon; dart test --test-randomize-ordering-seed=random" + run: "dart test --test-randomize-ordering-seed=random" + if: "always() && steps.build_daemon_pub_upgrade.conclusion == 'success'" + working-directory: build_daemon needs: - job_001 - job_002 @@ -1211,12 +943,3 @@ jobs: - job_012 - job_013 - job_014 - - job_015 - - job_016 - - job_017 - - job_018 - - job_019 - - job_020 - - job_021 - - job_022 - - job_023 diff --git a/_test/.gitignore b/_test/.gitignore deleted file mode 100644 index 1410a619fc..0000000000 --- a/_test/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# Files and directories created by pub -.packages -.pub/ -build/ -# Remove the following pattern if you wish to check in your lock file -pubspec.lock - -# Directory created by dartdoc -doc/api/ diff --git a/_test/LICENSE b/_test/LICENSE deleted file mode 100644 index 03af64abe4..0000000000 --- a/_test/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright 2017, the Dart project authors. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google LLC nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/_test/analysis_options.yaml b/_test/analysis_options.yaml deleted file mode 100644 index 3e4efada9e..0000000000 --- a/_test/analysis_options.yaml +++ /dev/null @@ -1,7 +0,0 @@ -include: ../analysis_options.yaml - -analyzer: - exclude: - # Exclude this here because if added to ../analysis_options.yaml it also - # excludes package:build. - - "build/**" diff --git a/_test/build.both.yaml b/_test/build.both.yaml deleted file mode 100644 index 7b3aacb27b..0000000000 --- a/_test/build.both.yaml +++ /dev/null @@ -1,26 +0,0 @@ -targets: - $default: - builders: - build_web_compilers:entrypoint: - options: - compilers: - dart2wasm: - dart2js: - loader: .dart.js - generate_for: - - web/main.dart - - web/sub/main.dart - - test/configurable_uri_test.dart - - test/configurable_uri_test.dart.browser_test.dart - - test/hello_world_test.dart - - test/hello_world_test.dart.browser_test.dart - - test/hello_world_deferred_test.dart - - test/hello_world_deferred_test.dart.browser_test.dart - - test/hello_world_custom_html_test.dart - - test/hello_world_custom_html_test.dart.browser_test.dart - - test/subdir_source_test.dart - - test/subdir_source_test.dart.browser_test.dart - - test/other_test.dart.browser_test.dart - - test/sub-dir/subdir_source.dart - - test/sub-dir/subdir_test.dart - - test/sub-dir/subdir_test.dart.browser_test.dart diff --git a/_test/build.dart2js.yaml b/_test/build.dart2js.yaml deleted file mode 100644 index 965ce35d17..0000000000 --- a/_test/build.dart2js.yaml +++ /dev/null @@ -1,25 +0,0 @@ -targets: - $default: - builders: - build_web_compilers:entrypoint: - options: - compiler: dart2js - dart2js_args: - - --enable-asserts - generate_for: - - web/main.dart - - web/sub/main.dart - - test/configurable_uri_test.dart - - test/configurable_uri_test.dart.browser_test.dart - - test/hello_world_test.dart - - test/hello_world_test.dart.browser_test.dart - - test/hello_world_deferred_test.dart - - test/hello_world_deferred_test.dart.browser_test.dart - - test/hello_world_custom_html_test.dart - - test/hello_world_custom_html_test.dart.browser_test.dart - - test/subdir_source_test.dart - - test/subdir_source_test.dart.browser_test.dart - - test/other_test.dart.browser_test.dart - - test/sub-dir/subdir_source.dart - - test/sub-dir/subdir_test.dart - - test/sub-dir/subdir_test.dart.browser_test.dart diff --git a/_test/build.dart2wasm.yaml b/_test/build.dart2wasm.yaml deleted file mode 100644 index afd1d7970e..0000000000 --- a/_test/build.dart2wasm.yaml +++ /dev/null @@ -1,31 +0,0 @@ -targets: - $default: - builders: - build_web_compilers:entrypoint: - options: - compiler: dart2wasm - dart2wasm_args: - - --enable-asserts - - -O0 - release_options: - compiler: dart2wasm - dart2wasm_args: - - --enable-asserts - - -O4 - generate_for: - - web/main.dart - - web/sub/main.dart - - test/configurable_uri_test.dart - - test/configurable_uri_test.dart.browser_test.dart - - test/hello_world_test.dart - - test/hello_world_test.dart.browser_test.dart - - test/hello_world_deferred_test.dart - - test/hello_world_deferred_test.dart.browser_test.dart - - test/hello_world_custom_html_test.dart - - test/hello_world_custom_html_test.dart.browser_test.dart - - test/subdir_source_test.dart - - test/subdir_source_test.dart.browser_test.dart - - test/other_test.dart.browser_test.dart - - test/sub-dir/subdir_source.dart - - test/sub-dir/subdir_test.dart - - test/sub-dir/subdir_test.dart.browser_test.dart diff --git a/_test/build.post_process.yaml b/_test/build.post_process.yaml deleted file mode 100644 index cd997dc8b0..0000000000 --- a/_test/build.post_process.yaml +++ /dev/null @@ -1,19 +0,0 @@ -targets: - $default: - builders: - provides_builder:some_post_process_builder: - options: - default_content: goodbye - build_web_compilers:entrypoint: - generate_for: - - web/main.dart - - web/sub/main.dart - - test/hello_world_test.dart - - test/hello_world_test.dart.browser_test.dart - - test/hello_world_deferred_test.dart - - test/hello_world_deferred_test.dart.browser_test.dart - - test/hello_world_custom_html_test.dart - - test/hello_world_custom_html_test.dart.browser_test.dart - - test/other_test.dart.browser_test.dart - - test/sub-dir/subdir_test.dart - - test/sub-dir/subdir_test.dart.browser_test.dart diff --git a/_test/build.yaml b/_test/build.yaml deleted file mode 100644 index 9b76a096c1..0000000000 --- a/_test/build.yaml +++ /dev/null @@ -1,15 +0,0 @@ -targets: - $default: - builders: - build_web_compilers:entrypoint: - generate_for: - - web/main.dart - - web/sub/main.dart - - test/configurable_uri_test.dart.browser_test.dart - - test/hello_world_test.dart.browser_test.dart - - test/hello_world_deferred_test.dart.browser_test.dart - - test/hello_world_custom_html_test.dart.browser_test.dart - - test/other_test.dart.browser_test.dart - - test/subdir_source_test.dart.browser_test.dart - - test/sub-dir/subdir_source.dart - - test/sub-dir/subdir_test.dart.browser_test.dart diff --git a/_test/dart_test.yaml b/_test/dart_test.yaml deleted file mode 100644 index 89a9309348..0000000000 --- a/_test/dart_test.yaml +++ /dev/null @@ -1,22 +0,0 @@ -timeout: 16x -# These test suites must not run in parallel, they modify actual sources in the -# package. -concurrency: 1 - -tags: - # This tag is used for integration tests - we don't need special options at the - # moment, but want to avoid warnings from the test runner about using undefined - # targets. - integration: - -define_platforms: - chrome_without_wasm: - name: chrome_without_wasm - extends: chrome - settings: - arguments: "--js-flags=--noexpose_wasm" - -override_platforms: - chrome: - settings: - headless: true diff --git a/_test/lib/app.dart b/_test/lib/app.dart deleted file mode 100644 index 3e036bcb47..0000000000 --- a/_test/lib/app.dart +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2017, 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. - -import 'package:web/web.dart'; - -void startApp({String? text}) { - text ??= 'Hello World!'; - // ignore: deprecated_member_use - final component = HTMLDivElement()..text = text; - document.body!.append(component); -} diff --git a/_test/lib/hello.txt b/_test/lib/hello.txt deleted file mode 100644 index 391511543d..0000000000 --- a/_test/lib/hello.txt +++ /dev/null @@ -1 +0,0 @@ -hello world!!!!!! diff --git a/_test/mono_pkg.yaml b/_test/mono_pkg.yaml deleted file mode 100644 index b8c5349e35..0000000000 --- a/_test/mono_pkg.yaml +++ /dev/null @@ -1,31 +0,0 @@ -sdk: -- dev - -os: -- linux - -stages: -- analyze_and_format: - - format - - analyze: --fatal-infos . -- unit_test: - - command: dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random - os: - - linux - - windows - # TODO(https://github.com/dart-lang/build/issues/3423): restore this on windows - - command: dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random - os: linux -- e2e_test: - - test: --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random - os: linux - - test: --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random - os: linux - - test: --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random - os: linux - - test: --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random - os: windows - - test: --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random - os: windows - - test: --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random - os: windows diff --git a/_test/pkgs/provides_builder/build.yaml b/_test/pkgs/provides_builder/build.yaml deleted file mode 100644 index 21b8d8bf6a..0000000000 --- a/_test/pkgs/provides_builder/build.yaml +++ /dev/null @@ -1,23 +0,0 @@ -builders: - some_builder: - import: "package:provides_builder/builders.dart" - builder_factories: ["someBuilder"] - build_extensions: {".dart": [".something.dart"]} - auto_apply: dependents - applies_builders: - - provides_builder:some_post_process_builder - some_not_applied_builder: - import: "package:provides_builder/builders.dart" - builder_factories: ["notApplied"] - build_extensions: {".dart": [".something.dart"]} - throwing_builder: - import: "package:provides_builder/builders.dart" - builder_factories: ["throwingBuilder"] - build_extensions: {".fail": [".fail.message"]} - auto_apply: dependents -post_process_builders: - some_post_process_builder: - target: "provides_builder" - import: "package:provides_builder/builders.dart" - builder_factory: "somePostProcessBuilder" - input_extensions: [".txt"] diff --git a/_test/pkgs/provides_builder/lib/builders.dart b/_test/pkgs/provides_builder/lib/builders.dart deleted file mode 100644 index 52e3492472..0000000000 --- a/_test/pkgs/provides_builder/lib/builders.dart +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2017, 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. - -import 'dart:async'; - -import 'package:build/build.dart'; - -class _SomeBuilder implements Builder { - const _SomeBuilder(); - - factory _SomeBuilder.fromOptions(BuilderOptions options) { - if (options.config['throw_in_constructor'] == true) { - throw StateError('Throwing on purpose cause you asked for it!'); - } - return const _SomeBuilder(); - } - - @override - final buildExtensions = const { - '.dart': ['.something.dart'], - }; - - @override - Future build(BuildStep buildStep) async { - if (!await buildStep.canRead(buildStep.inputId)) return; - - final content = await buildStep.readAsString(buildStep.inputId); - - if (content.contains('// resolve_me')) { - await buildStep.resolver.libraryFor(buildStep.inputId); - } - - await buildStep.writeAsString( - buildStep.inputId.changeExtension('.something.dart'), - content, - ); - } -} - -class _SomePostProcessBuilder extends PostProcessBuilder { - @override - final inputExtensions = const ['.txt']; - - final String? defaultContent; - - _SomePostProcessBuilder.fromOptions(BuilderOptions options) - : defaultContent = options.config['default_content'] as String?; - - @override - Future build(PostProcessBuildStep buildStep) async { - final content = defaultContent ?? await buildStep.readInputAsString(); - await buildStep.writeAsString( - buildStep.inputId.changeExtension('.txt.post'), - content, - ); - } -} - -class _ThrowingBuilder extends Builder { - @override - final buildExtensions = { - '.fail': ['.fail.message'], - }; - - @override - Future build(BuildStep buildStep) async { - throw UnsupportedError(await buildStep.readAsString(buildStep.inputId)); - } -} - -Builder someBuilder(BuilderOptions options) => - _SomeBuilder.fromOptions(options); -Builder notApplied(BuilderOptions options) => _SomeBuilder.fromOptions(options); -PostProcessBuilder somePostProcessBuilder(BuilderOptions options) => - _SomePostProcessBuilder.fromOptions(options); -Builder throwingBuilder(BuilderOptions _) => _ThrowingBuilder(); diff --git a/_test/pkgs/provides_builder/pubspec.yaml b/_test/pkgs/provides_builder/pubspec.yaml deleted file mode 100644 index 8ca58baa78..0000000000 --- a/_test/pkgs/provides_builder/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: provides_builder -resolution: workspace -environment: - sdk: ^3.7.0 -publish_to: none - -dependencies: - build: - path: ../../../build diff --git a/_test/pubspec.yaml b/_test/pubspec.yaml deleted file mode 100644 index 6e81bc7742..0000000000 --- a/_test/pubspec.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: _test -publish_to: none -resolution: workspace - -environment: - sdk: ^3.7.0 - -dependencies: - web: ^1.0.0 - -dev_dependencies: - analyzer: any - build: any - build_config: any - build_modules: any - build_runner: any - build_test: any - build_web_compilers: any - dart_flutter_team_lints: ^3.1.0 - io: ^1.0.0 - path: ^1.8.0 - provides_builder: - path: pkgs/provides_builder/ - test: ^1.16.0 - test_descriptor: ^2.0.1 - test_process: ^2.0.0 diff --git a/_test/test/build_integration_test.dart b/_test/test/build_integration_test.dart deleted file mode 100644 index 1046c6ee99..0000000000 --- a/_test/test/build_integration_test.dart +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2018, 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('vm') -library; - -import 'dart:io'; - -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; - -import 'common/utils.dart'; - -void main() { - setUp(() async { - ensureCleanGitClient(); - // Run a regular build in known clean state to speed up these tests. - await runBuild(); - }); - - group('PostProcessBuilder', () { - test('creates expected outputs', () async { - final generated = await readGeneratedFileAsString( - '_test/lib/hello.txt.post', - ); - final original = await File('lib/hello.txt').readAsString(); - expect(generated, equals(original)); - }); - - test('can be configured with build.yaml', () async { - await runBuild(trailingArgs: ['--config', 'post_process']); - final generated = await readGeneratedFileAsString( - '_test/lib/hello.txt.post', - ); - expect(generated, equals('goodbye')); - }); - - test('can be configured with --define', () async { - final content = 'cool'; - await runBuild( - trailingArgs: [ - '--define', - 'provides_builder:some_post_process_builder=default_content=$content', - ], - ); - final generated = await readGeneratedFileAsString( - '_test/lib/hello.txt.post', - ); - expect(generated, equals(content)); - }); - - test('rebuilds if the input file changes and not otherwise', () async { - var result = await runBuild(); - expect(result.stdout, contains('wrote 0 outputs')); - await replaceAllInFile('lib/hello.txt', 'hello', 'goodbye'); - result = await runBuild(); - expect(result.stdout, contains('wrote 1 output')); - final content = await readGeneratedFileAsString( - '_test/lib/hello.txt.post', - ); - expect(content, contains('goodbye')); - }); - }); - - group('experiments', () { - test('can serve a single app with experiments enabled', () async { - final result = await runBuild( - trailingArgs: ['--enable-experiment=fake-experiment'], - ); - - expect(result.exitCode, isNot(0)); - expect(result.stdout, contains('Failed to compile build script')); - expect( - result.stdout, - contains('Unknown experiment: fake-experiment'), - skip: 'https://github.com/dart-lang/webdev/issues/2003', - ); - }); - }); - - group('regression tests', () { - test( - 'Failing optional outputs which are required during the next build', - () async { - // Run a build with DDC that should fail - final path = p.join('lib', 'bad_file.dart'); - await createFile(path, 'not valid dart syntax'); - final testFile = p.join('test', 'hello_world_test.dart'); - await replaceAllInFile( - testFile, - '//import_anchor', - "import: 'package:_test/bad_file.dart';", - ); - final result = await runBuild(trailingArgs: ['--fail-on-severe']); - expect(result.exitCode, isNot(0)); - expect(result.stdout, contains('Failed')); - - // Remove the import to the bad file so it is no longer a requirement - // for the overall build - await replaceAllInFile( - testFile, - "import: 'package:_test/bad_file.dart';", - '//import_anchor', - ); - final nextBuild = await runBuild(trailingArgs: ['--fail-on-severe']); - expect(nextBuild.exitCode, 0); - }, - ); - - test('Restores previously deleted outputs if they are not deleted in ' - 'subsequent builds', () async { - final dartSource = File( - p.join('build', 'web', 'packages', '_test', 'app.dart'), - ); - await runBuild( - trailingArgs: [ - '--define=build_web_compilers:dart_source_cleanup=enabled=true', - '--output', - 'build', - ], - ); - expect(dartSource.existsSync(), false); - - await runBuild(trailingArgs: ['--output', 'build']); - expect(dartSource.existsSync(), true); - }); - - test('incremental build after resolve missing import', () async { - final dartSource = File(p.join('lib', 'app.dart')); - dartSource.writeAsStringSync( - // Trigger resolving source in pkgs/provides_builder/lib/builders.dart. - '// resolve_me\n' - // Resolve an import that does not exist. - "import 'package:missing/missing.dart';\n" - '${dartSource.readAsStringSync()}', - ); - await runBuild(); - - // Rebuild and check the previously-missing import does not cause a crash. - dartSource.writeAsStringSync('//\n${dartSource.readAsStringSync()}'); - - final result = await runBuild(); - expect(result.stdout, isNot(contains('PackageNotFoundException'))); - }); - }); -} diff --git a/_test/test/common/message.dart b/_test/test/common/message.dart deleted file mode 100644 index 939626e943..0000000000 --- a/_test/test/common/message.dart +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2017, 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. - -String get message => 'Hello World!'; diff --git a/_test/test/common/message_export.dart b/_test/test/common/message_export.dart deleted file mode 100644 index 1e17c06f0a..0000000000 --- a/_test/test/common/message_export.dart +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2019, 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. - -export 'message.dart' - if (dart.library.io) 'message_io.dart' - if (dart.library.html) 'message_html.dart' - if (dart.library.js_interop) 'message_js_without_html.dart'; diff --git a/_test/test/common/message_html.dart b/_test/test/common/message_html.dart deleted file mode 100644 index c1c707deea..0000000000 --- a/_test/test/common/message_html.dart +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2018, 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. - -String get message => 'Hello World from Javascript!'; diff --git a/_test/test/common/message_io.dart b/_test/test/common/message_io.dart deleted file mode 100644 index 100ee523e2..0000000000 --- a/_test/test/common/message_io.dart +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2018, 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. - -String get message => 'Hello World from the VM!'; diff --git a/_test/test/common/message_js_without_html.dart b/_test/test/common/message_js_without_html.dart deleted file mode 100644 index f11366b4e1..0000000000 --- a/_test/test/common/message_js_without_html.dart +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2024, 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. - -String get message => 'Hello World from WebAssembly!'; diff --git a/_test/test/common/utils.dart b/_test/test/common/utils.dart deleted file mode 100644 index e84e026262..0000000000 --- a/_test/test/common/utils.dart +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright (c) 2017, 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. - -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:build_runner/src/internal.dart'; -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; -import 'package:test_process/test_process.dart'; - -Directory _generatedDir = Directory(p.join(_toolDir.path, 'generated')); -Directory _toolDir = Directory(p.join('.dart_tool', 'build')); - -Process? _process; -Stream? _stdOutLines; -Stream? get stdOutLines => _stdOutLines; - -/// Runs a single build using `dart run build_runner build`, and returns the -/// [ProcessResult]. -Future runBuild({List trailingArgs = const []}) => - _runBuild('dart', ['run', 'build_runner', 'build', ...trailingArgs]); - -/// Runs `dart run build_runner `, and returns the [ProcessResult]. -Future runCommand(List args) => - _runBuild('dart', ['run', 'build_runner', ...args]); - -/// Runs `dart run build_runner serve` in this package, and waits for the first -/// build to complete. -/// -/// To ensure a clean build, set [ensureCleanBuild] to `true`. -Future startServer({ - bool? ensureCleanBuild, - List? buildArgs, -}) async => _startServer('dart', [ - '--packages=${(await Isolate.packageConfig).toString()}', - p.join('..', 'build_runner', 'bin', 'build_runner.dart'), - 'serve', - '--verbose', - if (buildArgs != null) ...buildArgs, -], ensureCleanBuild: ensureCleanBuild); - -Future _runBuild( - String command, - List args, { - bool? ensureCleanBuild, -}) async { - ensureCleanBuild ??= false; - - // Make sure this is a clean build - if (ensureCleanBuild && await _toolDir.exists()) { - await _toolDir.delete(recursive: true); - } - - final result = await Process.run(command, args); - printOnFailure('${result.stdout}'); - printOnFailure('${result.stderr}'); - return result; -} - -Future _startServer( - String command, - List buildArgs, { - bool? ensureCleanBuild, -}) async { - ensureCleanBuild ??= false; - - // Make sure this is a clean build - if (ensureCleanBuild && await _toolDir.exists()) { - await _toolDir.delete(recursive: true); - } - - final proc = _process = await Process.start(command, buildArgs); - unawaited( - proc.exitCode.then((_) { - if (_process != null) _process = null; - }), - ); - final stdOutLines = - _stdOutLines = - proc.stdout - .transform(utf8.decoder) - .transform(const LineSplitter()) - .asBroadcastStream(); - - final stdErrLines = - proc.stderr - .transform(utf8.decoder) - .transform(const LineSplitter()) - .asBroadcastStream(); - - stdOutLines.listen((line) => printOnFailure('StdOut: $line')); - stdErrLines.listen((line) => printOnFailure('StdErr: $line')); - - await nextSuccessfulBuild; -} - -/// Kills the current build script. -/// -/// To clean up the `.dart_tool` directory as well, set [cleanUp] to `true`. -Future stopServer({bool? cleanUp}) async { - cleanUp ??= false; - final process = _process; - if (process != null) { - expect(process.kill(), true); - final exitCode = process.exitCode; - _process = null; - await exitCode; - } - _stdOutLines = null; - - if (cleanUp && await _toolDir.exists()) { - await _toolDir.delete(recursive: true); - } -} - -/// Checks whether the current git client is "clean" (no pending changes) for -/// this package directory. -bool _gitIsClean() { - final gitStatus = - Process.runSync('git', ['status', '.', '--porcelain']).stdout as String; - return gitStatus.isEmpty; -} - -/// Ensures that the current directory is a "clean" git client (no pending -/// changes). -/// -/// This also calls `addTearDown` with a method that will reset the current git -/// state for this directory after running the test. -void ensureCleanGitClient() { - final gitWasClean = _gitIsClean(); - expect( - gitWasClean, - isTrue, - reason: 'Not running on a clean git client, aborting test.\n', - ); - - addTearDown(_resetGitClient); -} - -Future _resetGitClient() async { - if (_gitIsClean()) return; - - // Reset our state after each test, assuming we didn't abandon tests due - // to a non-pristine git environment. - Process.runSync('git', ['checkout', 'HEAD', '--', '.']); - - Future? nextBuild; - if (_process != null) nextBuild = nextSuccessfulBuild; - // Delete the untracked files. - await Process.run('git', ['clean', '-df', '.']); - if (nextBuild != null) await nextBuild; -} - -Future get nextSuccessfulBuild async { - await _stdOutLines!.firstWhere( - (line) => line.contains(BuildLog.successPattern), - ); -} - -Future get nextFailedBuild async { - await _stdOutLines!.firstWhere( - (line) => line.contains(BuildLog.failurePattern), - ); -} - -Future nextStdOutLine(String message) => - _stdOutLines!.firstWhere((line) => line.contains(message)); - -/// Runs tests using the auto build script. -Future runTests({ - bool? usePrecompiled, - List? buildArgs, - List? testArgs, -}) async { - return _runTests( - 'dart', - ['run', 'build_runner'], - usePrecompiled: usePrecompiled, - buildArgs: buildArgs, - testArgs: testArgs, - ); -} - -Future _runTests( - String executable, - List scriptArgs, { - bool? usePrecompiled, - List? buildArgs, - List? testArgs, -}) async { - usePrecompiled ??= true; - if (usePrecompiled) { - final args = - scriptArgs.toList() - ..add('test') - ..add('--verbose') - ..addAll(buildArgs ?? []) - ..add('--') - ..addAll([...?testArgs, '-p', 'chrome', '-r', 'expanded']); - return TestProcess.start(executable, args); - } else { - final args = ['run', 'test', '--pub-serve', '8081', ...?testArgs]; - return TestProcess.start('dart', args); - } -} - -Future expectTestsFail({ - bool? usePrecompiled, - List? buildArgs, - List? testArgs, -}) async { - // Skip on Windows due to Chrome test flakiness, see - // https://github.com/dart-lang/build/issues/4123. - final result = await runTests( - usePrecompiled: usePrecompiled, - buildArgs: buildArgs, - testArgs: testArgs, - ); - expect(result.stdout, emitsThrough(contains('Some tests failed'))); - expect(await result.exitCode, isNot(0)); -} - -Future expectTestsPass({ - int? expectedNumRan, - bool? usePrecompiled, - List? buildArgs, - List? testArgs, -}) async { - // Skip on Windows due to Chrome test flakiness, see - // https://github.com/dart-lang/build/issues/4123. - if (Platform.isWindows) return; - final result = await runTests( - usePrecompiled: usePrecompiled, - buildArgs: buildArgs, - testArgs: testArgs, - ); - final allLines = await result.stdout.rest.toList(); - expect(allLines, contains(contains('All tests passed!'))); - if (expectedNumRan != null) { - expect(allLines, contains(contains('+$expectedNumRan'))); - expect(allLines, isNot(contains(contains('+${expectedNumRan + 1}')))); - } - expect(await result.exitCode, 0); -} - -Future createFile(String path, String contents) async { - final file = File(path); - expect(await file.exists(), isFalse); - await file.create(recursive: true); - await file.writeAsString(contents); -} - -Future deleteFile(String path) async { - final file = File(path); - expect(await file.exists(), isTrue); - await file.delete(); -} - -Future readGeneratedFileAsString(String path) async { - final file = File(p.join(_generatedDir.path, path)); - expect(await file.exists(), isTrue); - return file.readAsString(); -} - -Future replaceAllInFile(String path, Pattern from, String replace) async { - final file = File(path); - expect(await file.exists(), isTrue); - final content = await file.readAsString(); - await file.writeAsString(content.replaceAll(from, replace)); -} diff --git a/_test/test/configurable_uri_test.dart b/_test/test/configurable_uri_test.dart deleted file mode 100644 index 6f2c9f3d66..0000000000 --- a/_test/test/configurable_uri_test.dart +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2018, 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. - -import 'package:test/test.dart'; - -import 'common/message.dart' - if (dart.library.io) 'common/message_io.dart' - if (dart.library.html) 'common/message_html.dart' - if (dart.library.js_interop) 'common/message_js_without_html.dart'; - -import 'common/message_export.dart' as exported; - -void main() { - group('browser', () { - test('imports', () { - expect(message, contains('Javascript')); - }); - - test('exports', () { - expect(exported.message, contains('Javascript')); - }); - }, testOn: 'js'); - - group('wasm', () { - test('imports', () { - expect(message, contains('WebAssembly')); - }); - - test('exports', () { - expect(exported.message, contains('WebAssembly')); - }); - }, testOn: 'dart2wasm && !chrome_without_wasm'); - - group('vm', () { - test('imports', () { - expect(message, contains('VM')); - }); - - test('exports', () { - expect(exported.message, contains('VM')); - }); - }, testOn: 'vm'); -} diff --git a/_test/test/dart2js_integration_test.dart b/_test/test/dart2js_integration_test.dart deleted file mode 100644 index e15b75dea2..0000000000 --- a/_test/test/dart2js_integration_test.dart +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2017, 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('vm') -@Tags(['integration']) -library; - -import 'dart:async'; -import 'dart:io'; - -import 'package:test/test.dart'; - -import 'common/utils.dart'; - -const _outputDir = 'dart2js_test'; - -void main() { - group('Can run tests using dart2js', () { - tearDown(() async { - final dir = Directory(_outputDir); - if (await dir.exists()) { - await dir.delete(recursive: true); - } - }); - - test( - 'via build.yaml config flag', - () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: ['--config=dart2js', '--output=$_outputDir'], - ); - await _expectWasCompiledWithDart2JS(minified: false); - }, - onPlatform: {'windows': const Skip('flaky on windows')}, - ); - - test('via --define flag', () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: [ - '--define', - 'build_web_compilers:entrypoint=compiler=dart2js', - '--define', - 'build_web_compilers:entrypoint=dart2js_args=["--minify"]', - '--output=$_outputDir', - ], - ); - await _expectWasCompiledWithDart2JS(minified: true); - }, onPlatform: {'windows': const Skip('flaky on windows')}); - - test('via --release mode', () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: ['--release', '--output=$_outputDir'], - ); - await _expectWasCompiledWithDart2JS(minified: true); - }, onPlatform: {'windows': const Skip('flaky on windows')}); - - test( - '--define overrides --config', - () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: [ - '--config', - 'dart2js', - '--define', - 'build_web_compilers:entrypoint=compiler=dart2js', - '--define', - 'build_web_compilers:entrypoint=dart2js_args=["--minify"]', - '--output=$_outputDir', - ], - ); - await _expectWasCompiledWithDart2JS(minified: true); - }, - onPlatform: {'windows': const Skip('flaky on windows')}, - ); - }); -} - -Future _expectWasCompiledWithDart2JS({bool minified = false}) async { - final jsFile = File( - '$_outputDir/test/hello_world_deferred_test.dart.browser_test.dart.js', - ); - expect(await jsFile.exists(), isTrue); - // sanity check that it was indeed compiled with dart2js - final content = await jsFile.readAsString(); - if (minified) { - expect(content, isNot(startsWith('//'))); - expect(content, contains('typeof dartMainRunner==="function"')); - } else { - expect(content, startsWith('// Generated by dart2js')); - } - - final jsDeferredPartFile = File( - '$_outputDir/test/hello_world_deferred_test.dart.browser_test.dart.js' - '_1.part.js', - ); - expect(await jsDeferredPartFile.exists(), isTrue); -} diff --git a/_test/test/dart2wasm_integration_test.dart b/_test/test/dart2wasm_integration_test.dart deleted file mode 100644 index 5cb0f88bc2..0000000000 --- a/_test/test/dart2wasm_integration_test.dart +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2024, 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('vm') -@Tags(['integration']) -library; - -import 'dart:async'; - -import 'package:test/test.dart'; -import 'package:test_descriptor/test_descriptor.dart' as d; - -import 'common/utils.dart'; - -// This doesn't actually change anything since we're using precompiled tests, -// but it gets the compiler selector in tests right. -const _testArgs = ['-c', 'dart2wasm']; - -void main() { - group('Can run tests using dart2wasm', timeout: const Timeout.factor(2), () { - test( - 'via build.yaml config flag', - () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: ['--config=dart2wasm', '--output=${d.sandbox}'], - testArgs: _testArgs, - ); - await _expectWasCompiledWithDart2Wasm(); - }, - onPlatform: {'windows': const Skip('flaky on windows')}, - ); - - test('via --define flag', () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: [ - '--define', - 'build_web_compilers:entrypoint=compiler=dart2wasm', - '--define', - 'build_web_compilers:entrypoint=dart2wasm_args=' - '["--enable-asserts", "-E--enable-experimental-ffi"]', - '--output=${d.sandbox}', - ], - testArgs: _testArgs, - ); - await _expectWasCompiledWithDart2Wasm(); - }, onPlatform: {'windows': const Skip('flaky on windows')}); - - test('via --release mode', () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: ['--release', '--config=dart2wasm', '--output=${d.sandbox}'], - testArgs: _testArgs, - ); - await _expectWasCompiledWithDart2Wasm(); - }, onPlatform: {'windows': const Skip('flaky on windows')}); - - test( - 'when also enabling dart2js', - () async { - await expectTestsPass( - usePrecompiled: true, - buildArgs: ['--release', '--config=both', '--output=${d.sandbox}'], - testArgs: [..._testArgs, '-p', 'chrome_without_wasm', '-p', 'chrome'], - ); - await _expectWasCompiledWithDart2Wasm(); - - await d.dir('test', [ - d.file( - 'hello_world_deferred_test.dart.browser_test.dart2js.js', - startsWith('// Generated by dart2js'), - ), - ]).validate(); - }, - onPlatform: {'windows': const Skip('flaky on windows')}, - ); - }); -} - -Future _expectWasCompiledWithDart2Wasm() async { - await d.dir('test', [ - d.file('hello_world_deferred_test.dart.browser_test.wasm', anything), - ]).validate(); -} diff --git a/_test/test/generated_script_integration_test.dart b/_test/test/generated_script_integration_test.dart deleted file mode 100644 index 0cb00544a8..0000000000 --- a/_test/test/generated_script_integration_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2017, 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('vm') -library; - -import 'dart:io' show File; - -import 'package:test/test.dart'; - -import 'common/utils.dart'; - -void main() { - setUpAll(() async { - await runCommand(['build', 'missing-folder']); - }); - - test('Generates a build script matching the golden', () { - final generatedScript = - File('.dart_tool/build/entrypoint/build.dart').readAsStringSync(); - final expected = File( - 'test/goldens/generated_build_script.dart', - ).readAsStringSync().replaceAll('\r', ''); - expect(generatedScript, expected); - }); -} diff --git a/_test/test/goldens/generated_build_script.dart b/_test/test/goldens/generated_build_script.dart deleted file mode 100644 index 0d119e64e2..0000000000 --- a/_test/test/goldens/generated_build_script.dart +++ /dev/null @@ -1,182 +0,0 @@ -// @dart=3.6 -// ignore_for_file: directives_ordering -// build_runner >=2.4.16 -// ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:build_runner/src/build_plan/builder_application.dart' as _i1; -import 'package:build_runner/src/bootstrap/apply_builders.dart' as _i2; -import 'package:provides_builder/builders.dart' as _i3; -import 'package:build_web_compilers/builders.dart' as _i4; -import 'package:build_test/builder.dart' as _i5; -import 'package:build_config/build_config.dart' as _i6; -import 'package:build_modules/builders.dart' as _i7; -import 'package:build/build.dart' as _i8; -import 'dart:isolate' as _i9; -import 'package:build_runner/src/bootstrap/build_process_state.dart' as _i10; -import 'package:build_runner/build_runner.dart' as _i11; -import 'dart:io' as _i12; - -final _builders = <_i1.BuilderApplication>[ - _i2.apply( - r'provides_builder:throwing_builder', - [_i3.throwingBuilder], - _i2.toDependentsOf(r'provides_builder'), - hideOutput: true, - ), - _i2.apply( - r'provides_builder:some_not_applied_builder', - [_i3.notApplied], - _i2.toNoneByDefault(), - hideOutput: true, - ), - _i2.apply( - r'provides_builder:some_builder', - [_i3.someBuilder], - _i2.toDependentsOf(r'provides_builder'), - hideOutput: true, - appliesBuilders: const [r'provides_builder:some_post_process_builder'], - ), - _i2.apply( - r'build_web_compilers:sdk_js', - [ - _i4.sdkJsCompile, - _i4.sdkJsCopyRequirejs, - ], - _i2.toNoneByDefault(), - isOptional: true, - hideOutput: true, - ), - _i2.apply( - r'build_test:test_bootstrap', - [ - _i5.debugIndexBuilder, - _i5.debugTestBuilder, - _i5.testBootstrapBuilder, - ], - _i2.toRoot(), - hideOutput: true, - defaultGenerateFor: const _i6.InputSet(include: [ - r'$package$', - r'test/**', - ]), - ), - _i2.apply( - r'build_modules:module_library', - [_i7.moduleLibraryBuilder], - _i2.toAllPackages(), - isOptional: true, - hideOutput: true, - appliesBuilders: const [r'build_modules:module_cleanup'], - ), - _i2.apply( - r'build_web_compilers:ddc_modules', - [ - _i4.ddcMetaModuleBuilder, - _i4.ddcMetaModuleCleanBuilder, - _i4.ddcModuleBuilder, - ], - _i2.toNoneByDefault(), - isOptional: true, - hideOutput: true, - appliesBuilders: const [r'build_modules:module_cleanup'], - ), - _i2.apply( - r'build_web_compilers:ddc', - [ - _i4.ddcKernelBuilder, - _i4.ddcBuilder, - ], - _i2.toAllPackages(), - isOptional: true, - hideOutput: true, - appliesBuilders: const [ - r'build_web_compilers:ddc_modules', - r'build_web_compilers:dart2js_modules', - r'build_web_compilers:dart2wasm_modules', - r'build_web_compilers:dart_source_cleanup', - ], - ), - _i2.apply( - r'build_web_compilers:dart2wasm_modules', - [ - _i4.dart2wasmMetaModuleBuilder, - _i4.dart2wasmMetaModuleCleanBuilder, - _i4.dart2wasmModuleBuilder, - ], - _i2.toNoneByDefault(), - isOptional: true, - hideOutput: true, - appliesBuilders: const [r'build_modules:module_cleanup'], - ), - _i2.apply( - r'build_web_compilers:dart2js_modules', - [ - _i4.dart2jsMetaModuleBuilder, - _i4.dart2jsMetaModuleCleanBuilder, - _i4.dart2jsModuleBuilder, - ], - _i2.toNoneByDefault(), - isOptional: true, - hideOutput: true, - appliesBuilders: const [r'build_modules:module_cleanup'], - ), - _i2.apply( - r'build_web_compilers:entrypoint', - [_i4.webEntrypointBuilder], - _i2.toRoot(), - hideOutput: true, - defaultGenerateFor: const _i6.InputSet( - include: [ - r'web/**', - r'test/**.dart.browser_test.dart', - r'example/**', - r'benchmark/**', - ], - exclude: [ - r'test/**.node_test.dart', - r'test/**.vm_test.dart', - ], - ), - defaultOptions: const _i8.BuilderOptions({ - r'dart2js_args': [r'--minify'] - }), - defaultDevOptions: const _i8.BuilderOptions({ - r'dart2wasm_args': [r'--enable-asserts'], - r'dart2js_args': [r'--enable-asserts'], - }), - defaultReleaseOptions: - const _i8.BuilderOptions({r'compiler': r'dart2js'}), - appliesBuilders: const [r'build_web_compilers:dart2js_archive_extractor'], - ), - _i2.applyPostProcess( - r'build_modules:module_cleanup', - _i7.moduleCleanup, - ), - _i2.applyPostProcess( - r'build_web_compilers:dart2js_archive_extractor', - _i4.dart2jsArchiveExtractor, - defaultReleaseOptions: - const _i8.BuilderOptions({r'filter_outputs': true}), - ), - _i2.applyPostProcess( - r'build_web_compilers:dart_source_cleanup', - _i4.dartSourceCleanup, - defaultReleaseOptions: - const _i8.BuilderOptions({r'enabled': true}), - ), - _i2.applyPostProcess( - r'provides_builder:some_post_process_builder', - _i3.somePostProcessBuilder, - ), -]; -void main( - List args, [ - _i9.SendPort? sendPort, -]) async { - await _i10.buildProcessState.receive(sendPort); - _i10.buildProcessState.isolateExitCode = await _i11.run( - args, - _builders, - ); - _i12.exitCode = _i10.buildProcessState.isolateExitCode!; - await _i10.buildProcessState.send(sendPort); -} diff --git a/_test/test/hello_world_custom_html_test.dart b/_test/test/hello_world_custom_html_test.dart deleted file mode 100644 index 52f3a88a4c..0000000000 --- a/_test/test/hello_world_custom_html_test.dart +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2017, 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('browser') -library; - -import 'package:test/test.dart'; -import 'package:web/web.dart'; - -void main() { - test('can use custom html', () { - expect(document.getElementById('my-element'), isNotNull); - }); -} diff --git a/_test/test/hello_world_custom_html_test.html b/_test/test/hello_world_custom_html_test.html deleted file mode 100644 index ca7987ea2e..0000000000 --- a/_test/test/hello_world_custom_html_test.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -
My pre-existing element!
- - - diff --git a/_test/test/hello_world_deferred_test.dart b/_test/test/hello_world_deferred_test.dart deleted file mode 100644 index ac61f99527..0000000000 --- a/_test/test/hello_world_deferred_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2017, 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('browser') -library; - -import 'dart:js_interop'; - -import 'package:_test/app.dart'; -import 'package:test/test.dart'; -import 'package:web/web.dart'; - -import 'common/message.dart' deferred as m; - -void main() { - setUp(startApp); - - tearDown(() { - document.body!.innerHTML = ''.toJS; - }); - - test('hello world', () async { - await m.loadLibrary(); - expect(document.body?.innerText, contains(m.message)); - }); -} diff --git a/_test/test/hello_world_test.dart b/_test/test/hello_world_test.dart deleted file mode 100644 index 8023208ed1..0000000000 --- a/_test/test/hello_world_test.dart +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2017, 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('browser') -library; - -import 'dart:js_interop'; - -import 'package:_test/app.dart'; -import 'package:test/test.dart'; -import 'package:web/web.dart'; - -//import_anchor - -import 'common/message.dart'; - -void main() { - setUp(startApp); - - tearDown(() { - document.body!.innerHTML = ''.toJS; - }); - - test('hello world', () { - expect(document.body!.innerText, contains(message)); - }); - - test('failing test', skip: 'Expected failure', () { - expect(true, isFalse); - }); -} diff --git a/_test/test/serve_integration_test.dart b/_test/test/serve_integration_test.dart deleted file mode 100644 index 3572dbf869..0000000000 --- a/_test/test/serve_integration_test.dart +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright (c) 2017, 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('vm') -library; - -import 'dart:convert'; -import 'dart:io' - show - HttpClient, - HttpClientRequest, - HttpClientResponse, - HttpHeaders, - HttpStatus; - -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; - -import 'common/utils.dart'; - -void main() { - late HttpClient httpClient; - - setUpAll(() { - // Configure the client so it is possible to download a large number - // of files simultaneously. This prevents getting SocketException on - // too many connections. - httpClient = - HttpClient() - ..maxConnectionsPerHost = 200 - ..idleTimeout = const Duration(seconds: 30) - ..connectionTimeout = const Duration(seconds: 30); - }); - - tearDownAll(() { - httpClient.close(); - }); - - group('basic serve', () { - setUpAll(() async { - // These tests depend on running `test` while a `serve` is ongoing. - await startServer(ensureCleanBuild: true); - }); - - tearDownAll(() async { - await stopServer(cleanUp: true); - }); - - test('Doesn\'t compile submodules into the root module', () { - expect( - readGeneratedFileAsString('_test/test/hello_world_test.ddc.js'), - isNot(contains('Hello World!')), - ); - }); - - test( - 'Can run passing tests with --pub-serve', - skip: 'TODO: Get non-custom html tests passing with pub serve', - () async { - await expectTestsPass(usePrecompiled: false); - }, - ); - - test( - 'Serves a directory list when it fails to fallback on index.html', - () async { - final request = await httpClient.get( - 'localhost', - 8080, - 'dir_without_index/', - ); - final firstResponse = await request.close(); - expect(firstResponse.statusCode, HttpStatus.notFound); - expect( - await utf8.decodeStream(firstResponse.cast>()), - contains('dir_without_index/hello.txt'), - ); - }, - ); - - group('File changes', () { - setUp(() async { - ensureCleanGitClient(); - }); - - test('ddc errors can be fixed', () async { - final path = p.join('test', 'common', 'message.dart'); - final error = nextStdOutLine( - 'Error compiling dartdevc module:' - '_test|test/common/message.ddc.js', - ); - var nextBuild = nextFailedBuild; - await replaceAllInFile(path, "'Hello World!';", '1;'); - await error; - await nextBuild; - - nextBuild = nextSuccessfulBuild; - await replaceAllInFile(path, '1;', "'Hello World!';"); - await nextBuild; - await expectTestsPass(); - }); - - test('build errors can be fixed', () async { - final path = p.join('lib', 'expected.fail'); - - var nextBuild = nextFailedBuild; - await createFile(path, 'some error'); - await nextBuild; - - nextBuild = nextSuccessfulBuild; - await deleteFile(path); - await nextBuild; - }); - - test('can hit the server and get cached results', () async { - final firstRequest = await httpClient.get( - 'localhost', - 8080, - 'main.dart.js', - ); - final firstResponse = await firstRequest.close(); - expect(firstResponse.statusCode, HttpStatus.ok); - final etag = firstResponse.headers[HttpHeaders.etagHeader]; - expect(etag, isNotNull); - - final cachedRequest = await httpClient.get( - 'localhost', - 8080, - 'main.dart.js', - ); - cachedRequest.headers.add(HttpHeaders.ifNoneMatchHeader, etag!); - final cachedResponse = await cachedRequest.close(); - expect(cachedResponse.statusCode, HttpStatus.notModified); - }); - - group('regression tests', () { - test('can get changes to files not read during build', () async { - final firstRequest = await httpClient.get( - 'localhost', - 8080, - 'index.html', - ); - final firstResponse = await firstRequest.close(); - expect(firstResponse.statusCode, HttpStatus.ok); - final etag = firstResponse.headers[HttpHeaders.etagHeader]; - expect(etag, isNotNull); - - final cachedRequest = await httpClient.get( - 'localhost', - 8080, - 'index.html', - ) - ..headers.add(HttpHeaders.ifNoneMatchHeader, etag!); - final cachedResponse = await cachedRequest.close(); - expect(cachedResponse.statusCode, HttpStatus.notModified); - - final nextBuild = nextSuccessfulBuild; - await replaceAllInFile( - 'web/index.html', - 'integration tests', - 'modified example', - ); - await nextBuild; - final changedRequest = await httpClient.get( - 'localhost', - 8080, - 'index.html', - ) - ..headers.add(HttpHeaders.ifNoneMatchHeader, etag); - final changedResponse = await changedRequest.close(); - expect(changedResponse.statusCode, HttpStatus.ok); - final newEtag = changedResponse.headers[HttpHeaders.etagHeader]; - expect(newEtag, isNot(etag)); - }); - }); - }); - }); - - test('can serve a single app with custom environment defines', () async { - await startServer( - buildArgs: [ - 'web', - '--build-filter', - 'web/sub/main.dart.js', - '--define', - 'build_web_compilers:ddc=environment={"message": "goodbye"}', - ], - ); - - addTearDown(() async { - await stopServer(); - }); - - final response = - await (await httpClient.get( - 'localhost', - 8080, - 'sub/main.dart.js', - )).close(); - expect(response.statusCode, HttpStatus.ok); - - final badResponse = - await (await httpClient.get('localhost', 8080, 'main.dart.js')).close(); - expect(badResponse.statusCode, HttpStatus.notFound); - - final ddcFileResponse = - await (await httpClient.get('localhost', 8080, 'main.ddc.js')).close(); - expect(await utf8.decodeStream(ddcFileResponse), contains('"goodbye"')); - }); - - test('should serve files in parallel', () async { - await startServer( - buildArgs: [ - 'web', - '--build-filter', - 'web/sub/main.dart.js', - '--verbose', - '--define', - 'build_web_compilers:ddc=generate-full-dill=true', - ], - ); - - addTearDown(() async { - await stopServer(); - }); - - Future read(String path) async { - HttpClientRequest? request; - HttpClientResponse? response; - try { - request = await httpClient.get('localhost', 8080, path); - response = await request.close(); - expect( - response.statusCode, - HttpStatus.ok, - reason: '$path ${response.reasonPhrase}', - ); - } catch (e, s) { - fail('Error reading $path: $e:$s'); - } finally { - request?.abort(); - await response?.drain().catchError((_) {}); - } - } - - const n = 1000; - final futures = [ - for (var i = 0; i < n; i++) read('main.ddc.js'), - for (var i = 0; i < n; i++) read('main.ddc.js.map'), - for (var i = 0; i < n; i++) read('main.ddc.dill'), - for (var i = 0; i < n; i++) read('main.ddc.full.dill'), - for (var i = 0; i < n; i++) read('sub/message.ddc.js'), - for (var i = 0; i < n; i++) read('sub/message.ddc.js.map'), - for (var i = 0; i < n; i++) read('sub/message.ddc.dill'), - for (var i = 0; i < n; i++) read('sub/message.ddc.full.dill'), - ]; - await Future.wait(futures); - }); -} diff --git a/_test/test/sub-dir/subdir_source.dart b/_test/test/sub-dir/subdir_source.dart deleted file mode 100644 index c10383522b..0000000000 --- a/_test/test/sub-dir/subdir_source.dart +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2024, 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. - -import 'dart:js_interop'; -import 'dart:js_interop_unsafe'; - -void main() { - globalContext['otherScriptLoaded'] = true.toJS; -} diff --git a/_test/test/sub-dir/subdir_test.dart b/_test/test/sub-dir/subdir_test.dart deleted file mode 100644 index b17629975d..0000000000 --- a/_test/test/sub-dir/subdir_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2017, 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('browser') -library; - -import 'package:test/test.dart'; - -import '../hello_world_test.dart' as original; - -void main() => original.main(); diff --git a/_test/test/subdir_source_test.dart b/_test/test/subdir_source_test.dart deleted file mode 100644 index 01018eebeb..0000000000 --- a/_test/test/subdir_source_test.dart +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2024, 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('browser') -library; - -import 'dart:js_interop'; -import 'dart:js_interop_unsafe'; - -import 'package:test/test.dart'; -import 'package:web/web.dart'; - -void main() { - final wasCompiledWithDdc = globalContext.has('define'); - - test( - 'did load script from a subdirectory', - () async { - final scriptTag = document.createElement('script') as HTMLScriptElement; - scriptTag - ..type = 'application/javascript' - ..src = 'sub-dir/subdir_source.dart.js'; - document.head!.append(scriptTag); - - await Future.any([ - scriptTag.onLoad.first, - scriptTag.onError.first.then( - (_) => fail('Script from sub directory failed to load'), - ), - ]); - - await pumpEventQueue(); - - // `sub-dir/subdir_source.dart.js` should have set the `otherScriptLoader` - // propery. - expect(globalContext.has('otherScriptLoaded'), isTrue); - }, - skip: - wasCompiledWithDdc - ? 'This requires multiple Dart entrypoints, which appears to break ' - 'DDC' - : null, - ); -} diff --git a/_test/test/test_integration_test.dart b/_test/test/test_integration_test.dart deleted file mode 100644 index 8385f7f2a8..0000000000 --- a/_test/test/test_integration_test.dart +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2017, 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('vm') -library; - -import 'dart:io'; - -import 'package:io/io.dart'; -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; - -import 'common/utils.dart'; - -void main() { - test('Can run passing tests with --precompiled', () async { - await expectTestsPass(usePrecompiled: true); - }); - - test( - 'Can build and run a single test with --precompiled and --build-filter', - () async { - final buildArgs = ['--build-filter', 'test/hello_world_test.*.dart.js']; - await expectTestsPass( - usePrecompiled: true, - testArgs: ['test/hello_world_test.dart'], - buildArgs: buildArgs, - ); - - // This wasn't built so it should fail - await expectTestsFail( - usePrecompiled: true, - testArgs: ['test/hello_world_custom_html_test.dart'], - buildArgs: buildArgs, - ); - }, - ); - - test('Failing tests print mapped stack traces', () async { - // Skip on Windows due to Chrome test flakiness, see - // https://github.com/dart-lang/build/issues/4123. - if (Platform.isWindows) return; - final result = await runTests( - testArgs: ['--run-skipped', 'test/hello_world_test.dart'], - ); - expect( - result.stdout, - emitsThrough(matches(RegExp(r'hello_world_test.dart [\d]+:[\d]+'))), - ); - expect(result.stdout, neverEmits(contains('.js'))); - expect(await result.exitCode, isNot(ExitCode.success)); - }); - - group('file edits', () { - setUp(() async { - ensureCleanGitClient(); - }); - - test('edit test to fail and rerun', () async { - await replaceAllInFile( - 'test/common/message.dart', - 'Hello World!', - 'Goodbye World!', - ); - await expectTestsFail(); - }); - - test('edit dependency lib causing test to fail and rerun', () async { - await replaceAllInFile('lib/app.dart', 'Hello World!', 'Goodbye World!'); - await expectTestsFail(); - }); - - test('create new test', () async { - await createFile(p.join('test', 'other_test.dart'), basicTestContents); - await expectTestsPass(expectedNumRan: 7); - }); - - test('delete test', () async { - await deleteFile(p.join('test', 'sub-dir', 'subdir_test.dart')); - await expectTestsPass(expectedNumRan: 5); - }); - }); -} - -final basicTestContents = ''' -import 'package:test/test.dart'; - -main() { - test('1 == 1', () { - expect(1, equals(1)); - }); -}'''; diff --git a/_test/web/dir_without_index/hello.txt b/_test/web/dir_without_index/hello.txt deleted file mode 100644 index ce01362503..0000000000 --- a/_test/web/dir_without_index/hello.txt +++ /dev/null @@ -1 +0,0 @@ -hello diff --git a/_test/web/index.html b/_test/web/index.html deleted file mode 100644 index 5b0cf00a44..0000000000 --- a/_test/web/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - build integration tests - - - - - - - - - diff --git a/_test/web/main.dart b/_test/web/main.dart deleted file mode 100644 index 1b3efc0d32..0000000000 --- a/_test/web/main.dart +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2017, 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. - -import 'package:_test/app.dart'; - -import 'sub/message.dart' deferred as message; - -void main() async { - await message.loadLibrary(); - var text = const String.fromEnvironment('message'); - if (text.isEmpty) text = message.message; - startApp(text: text); -} diff --git a/_test/web/sub/index.html b/_test/web/sub/index.html deleted file mode 100644 index 5b0cf00a44..0000000000 --- a/_test/web/sub/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - build integration tests - - - - - - - - - diff --git a/_test/web/sub/main.dart b/_test/web/sub/main.dart deleted file mode 100644 index 39220e95e2..0000000000 --- a/_test/web/sub/main.dart +++ /dev/null @@ -1,5 +0,0 @@ -import '../main.dart' as other; - -void main() { - other.main(); -} diff --git a/_test/web/sub/message.dart b/_test/web/sub/message.dart deleted file mode 100644 index 6044067d54..0000000000 --- a/_test/web/sub/message.dart +++ /dev/null @@ -1,3 +0,0 @@ -import 'package:path/path.dart' as p; - -String get message => p.join('Hello', 'World'); diff --git a/build_runner/dart_test.yaml b/build_runner/dart_test.yaml index 4c4175cca7..1dc0744d8d 100644 --- a/build_runner/dart_test.yaml +++ b/build_runner/dart_test.yaml @@ -9,6 +9,8 @@ tags: timeout: 4x integration3: timeout: 4x + integration4: + timeout: 4x experiments: skip: 'Only ran if `-P experiments` is passed' presets: {experiments: {skip: false}} diff --git a/build_runner/mono_pkg.yaml b/build_runner/mono_pkg.yaml index ed9a3f1564..58feb2451b 100644 --- a/build_runner/mono_pkg.yaml +++ b/build_runner/mono_pkg.yaml @@ -8,8 +8,8 @@ stages: - analyze_and_format: - format - analyze: --fatal-infos . -- unit_test: - - test: -x integration1 -x integration2 -x integration3 --test-randomize-ordering-seed=random +- test: + - test: -x integration1 -x integration2 -x integration3 -x integration4 --test-randomize-ordering-seed=random - test: -P experiments --test-randomize-ordering-seed=random - test: -t integration1 --test-randomize-ordering-seed=random os: @@ -23,5 +23,8 @@ stages: os: - linux - windows -- leak_check: + - test: -t integration4 --test-randomize-ordering-seed=random + os: + - linux + - windows - command: ../tool/leak_check.sh diff --git a/build_runner/test/common/build_runner_tester.dart b/build_runner/test/common/build_runner_tester.dart index 47b86cbda0..697ea798c1 100644 --- a/build_runner/test/common/build_runner_tester.dart +++ b/build_runner/test/common/build_runner_tester.dart @@ -5,6 +5,7 @@ import 'dart:convert'; import 'dart:io'; import 'dart:isolate'; +import 'dart:typed_data'; import 'package:async/async.dart'; import 'package:build_runner/src/logging/build_log.dart'; @@ -68,6 +69,12 @@ class BuildRunnerTester { return file.existsSync() ? file.readAsStringSync() : null; } + /// Reads workspace-relative [path], or returns `null` if it does not exist. + Uint8List? readBytes(String path) { + final file = File(p.join(tempDirectory.path, path)); + return file.existsSync() ? file.readAsBytesSync() : null; + } + /// Writes [contents] to workspace-relative [path]. void write(String path, String contents) { final file = File(p.join(tempDirectory.path, path)); @@ -223,24 +230,39 @@ class BuildRunnerProcess { _port = port; } - /// Requests [path] from the server and expects it returns a 404 - /// response. - Future expect404(String path) async { - if (_port == null) throw StateError('Call expectServing first.'); - final request = await _client.get('localhost', _port!, path); - final response = await request.close(); - test.expect(response.statusCode, 404); - await response.drain(); + /// Requests [path] from the server and expects it returns + /// [expectResponseCode]. + /// + /// Returns the response content. + Future fetchContent( + String path, { + int expectResponseCode = 200, + }) async { + final response = await fetch(path, expectResponseCode: expectResponseCode); + return await utf8.decodeStream(response.cast>()); } - /// Requests [path] from the server and expects it returns a 200 - /// response with the body [content]. - Future expectContent(String path, String content) async { + /// Requests [path] from the server and expects it returns + /// [expectResponseCode]. + /// + /// Optionally, pass [headers] to set on the request. + /// + /// Returns the full response. + Future fetch( + String path, { + Map? headers, + int expectResponseCode = 200, + }) async { if (_port == null) throw StateError('Call expectServing first.'); final request = await _client.get('localhost', _port!, path); + if (headers != null) { + for (final entry in headers.entries) { + request.headers.add(entry.key, entry.value); + } + } final response = await request.close(); - test.expect(response.statusCode, 200); - test.expect(await utf8.decodeStream(response.cast>()), content); + test.expect(response.statusCode, expectResponseCode); + return response; } } diff --git a/build_runner/test/integration_tests/build_command_post_process_builder_test.dart b/build_runner/test/integration_tests/build_command_post_process_builder_test.dart new file mode 100644 index 0000000000..2bda56c11f --- /dev/null +++ b/build_runner/test/integration_tests/build_command_post_process_builder_test.dart @@ -0,0 +1,133 @@ +// Copyright (c) 2025, 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. + +@Tags(['integration4']) +library; + +import 'package:test/test.dart'; + +import '../common/common.dart'; + +void main() async { + test('build command with post process builder', () async { + final pubspecs = await Pubspecs.load(); + final tester = BuildRunnerTester(pubspecs); + + tester.writePackage( + name: 'builder_pkg', + dependencies: ['build', 'build_runner'], + files: { + 'build.yaml': ''' +builders: + test_builder: + import: "package:builder_pkg/builder.dart" + builder_factories: ["testBuilder"] + build_extensions: {".dart": [".g.dart"]} + auto_apply: root_package + build_to: source + applies_builders: + - builder_pkg:test_post_process_builder +post_process_builders: + test_post_process_builder: + import: "package:builder_pkg/builder.dart" + builder_factory: "testPostProcessBuilder" + input_extensions: [".txt"] + defaults: + options: + output_extension: ".post" +''', + 'lib/builder.dart': ''' +import 'package:build/build.dart'; + +TestBuilder testBuilder(BuilderOptions options) + => TestBuilder(); +TestPostProcessBuilder testPostProcessBuilder(BuilderOptions options) + => TestPostProcessBuilder(options.config['output_extension'] as String); + +class TestBuilder implements Builder { + @override + Map> get buildExtensions => {'.dart': ['.g.dart']}; + + @override + Future build(BuildStep buildStep) async {} +} + +class TestPostProcessBuilder implements PostProcessBuilder { + final String outputExtension; + + TestPostProcessBuilder(this.outputExtension); + + @override + List get inputExtensions => ['.txt']; + + @override + Future build(PostProcessBuildStep buildStep) async { + await buildStep.writeAsString( + buildStep.inputId.addExtension(outputExtension), + await buildStep.readInputAsString(), + ); + } +} +''', + }, + ); + tester.writePackage( + name: 'root_pkg', + dependencies: ['build_runner'], + pathDependencies: ['builder_pkg'], + files: {'lib/a.txt': 'a'}, + ); + + // Initial build. + await tester.run('root_pkg', 'dart run build_runner build --output build'); + expect(tester.readFileTree('root_pkg/build/packages/root_pkg'), { + 'a.txt': 'a', + 'a.txt.post': 'a', + }); + + // No rebuild if nothing changed. + var output = await tester.run( + 'root_pkg', + 'dart run build_runner build --output build', + ); + expect(output, contains('wrote 0 outputs')); + + // Do rebuild if a file changed. + tester.write('root_pkg/lib/a.txt', 'b'); + output = await tester.run( + 'root_pkg', + 'dart run build_runner build --output build', + ); + expect(output, contains('wrote 1 output')); + // Restore the original input. + tester.write('root_pkg/lib/a.txt', 'a'); + + // Configure via `build.yaml`. + tester.write('root_pkg/build.yaml', r''' +targets: + $default: + builders: + builder_pkg:test_post_process_builder: + options: + output_extension: ".other_post" +'''); + await tester.run('root_pkg', 'dart run build_runner build --output build'); + expect(tester.readFileTree('root_pkg/build/packages/root_pkg'), { + 'a.txt': 'a', + 'a.txt.other_post': 'a', + }); + + // Configure with `--define`. + await tester.run( + 'root_pkg', + 'dart run build_runner build --output build ' + '--define=builder_pkg:test_post_process_builder=output_extension=' + '.third_post', + ); + expect(tester.readFileTree('root_pkg/build/packages/root_pkg'), { + 'a.txt': 'a', + 'a.txt.third_post': 'a', + }); + }); +} diff --git a/build_runner/test/integration_tests/build_command_resolve_test.dart b/build_runner/test/integration_tests/build_command_resolve_test.dart new file mode 100644 index 0000000000..21dfb02b8f --- /dev/null +++ b/build_runner/test/integration_tests/build_command_resolve_test.dart @@ -0,0 +1,77 @@ +// Copyright (c) 2025, 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. + +@Tags(['integration4']) +library; + +import 'package:test/test.dart'; + +import '../common/common.dart'; + +void main() async { + test('build with resolution', () async { + final pubspecs = await Pubspecs.load(); + final tester = BuildRunnerTester(pubspecs); + + tester.writePackage( + name: 'builder_pkg', + dependencies: ['build', 'build_runner'], + files: { + 'build.yaml': ''' +builders: + test_builder: + import: 'package:builder_pkg/builder.dart' + builder_factories: ['testBuilderFactory'] + build_extensions: {'.dart': ['.g.dart']} + auto_apply: root_package + build_to: source +''', + 'lib/builder.dart': ''' +import 'package:build/build.dart'; + +Builder testBuilderFactory(BuilderOptions options) => TestBuilder(); + +class TestBuilder implements Builder { + @override + Map> get buildExtensions => {'.dart': ['.g.dart']}; + + @override + Future build(BuildStep buildStep) async { + await buildStep.inputLibrary; + } +} +''', + }, + ); + tester.writePackage( + name: 'root_pkg', + dependencies: ['build_runner'], + pathDependencies: ['builder_pkg'], + files: { + 'lib/a.dart': ''' +import 'missing_import.dart'; +syntax error +''', + }, + ); + + // Syntax error. + var output = await tester.run( + 'root_pkg', + 'dart run build_runner build', + expectExitCode: 1, + ); + expect(output, contains("Expected to find ';'")); + + // Unreadable inputs are allowed. + tester.write('root_pkg/lib/a.dart', ''' +import 'missing_import.dart'; +'''); + output = await tester.run('root_pkg', 'dart run build_runner build'); + + // Unreadable inputs in previousd build do not break incremental build. + tester.update('root_pkg/lib/a.dart', (script) => '$script\n'); + output = await tester.run('root_pkg', 'dart run build_runner build'); + }); +} diff --git a/build_runner/test/integration_tests/serve_command_serve_only_required_test.dart b/build_runner/test/integration_tests/serve_command_serve_only_required_test.dart index feb3d498a9..86c5264e8f 100644 --- a/build_runner/test/integration_tests/serve_command_serve_only_required_test.dart +++ b/build_runner/test/integration_tests/serve_command_serve_only_required_test.dart @@ -31,17 +31,17 @@ void main() async { // Initial build produces no output as the copy is not required. await serve.expectServing(); await serve.expect(BuildLog.successPattern); - await serve.expect404('a.txt.copy'); + await serve.fetch('a.txt.copy', expectResponseCode: 404); // Read a copy so that it is now required. tester.write('root_pkg/web/new.read', 'root_pkg|web/a.txt.copy'); await serve.expect(BuildLog.successPattern); - await serve.expectContent('a.txt.copy', 'a'); + expect(await serve.fetchContent('a.txt.copy'), 'a'); // Stop requiring the copy and it is no longer served. tester.delete('root_pkg/web/new.read'); await serve.expect(BuildLog.successPattern); - await serve.expect404('a.txt.copy'); + await serve.fetch('a.txt.copy', expectResponseCode: 404); // But it is not removed from the source tree. expect(tester.readFileTree('root_pkg/web'), { diff --git a/build_runner/test/integration_tests/serve_command_test.dart b/build_runner/test/integration_tests/serve_command_test.dart index 7caf205962..1021baac94 100644 --- a/build_runner/test/integration_tests/serve_command_test.dart +++ b/build_runner/test/integration_tests/serve_command_test.dart @@ -7,6 +7,7 @@ library; import 'dart:io'; +import 'package:build_runner/src/logging/build_log.dart'; import 'package:io/io.dart'; import 'package:test/test.dart'; @@ -23,7 +24,7 @@ void main() async { files: {}, ); - final serve = await tester.start('root_pkg', 'dart run build_runner serve'); + var serve = await tester.start('root_pkg', 'dart run build_runner serve'); await serve.expect( 'Missing dev dependency on package:build_web_compilers, ' 'which is required to serve Dart compiled to JavaScript.', @@ -31,8 +32,41 @@ void main() async { await serve.expect('Nothing to serve.'); await serve.kill(); - // Create some source to serve. + // Create some source to serve, serve it. tester.write('root_pkg/web/a.txt', 'a'); + tester.write('root_pkg/web/subdirectory/b.txt', 'b'); + serve = await tester.start('root_pkg', 'dart run build_runner serve web:0'); + await serve.expectServing(); + + // Initial build. + await serve.expect(BuildLog.successPattern); + + // Serves directory index as 404 for subdirectory without index.html. + expect( + await serve.fetchContent('subdirectory/', expectResponseCode: 404), + contains('web/subdirectory/b.txt'), + ); + + // Responds with etags, accepts and checks them. + final etag = + (await serve.fetch('a.txt')).headers[HttpHeaders.etagHeader]!.single; + await serve.fetch( + 'a.txt', + headers: {HttpHeaders.ifNoneMatchHeader: etag}, + expectResponseCode: HttpStatus.notModified, + ); + + // Etag changes if file changes. + final etag2 = + (await serve.fetch('a.txt')).headers[HttpHeaders.etagHeader]!.single; + tester.write('root_pkg/web/a.txt', 'b'); + await serve.expect(BuildLog.successPattern); + final etag3 = + (await serve.fetch('a.txt')).headers[HttpHeaders.etagHeader]!.single; + expect(etag, etag2); + expect(etag, isNot(etag3)); + + await serve.kill(); // Start a server serve on the same port, check the error. final server = await HttpServer.bind('localhost', 0); diff --git a/build_runner/test/integration_tests/web_compilers_test.dart b/build_runner/test/integration_tests/web_compilers_test.dart new file mode 100644 index 0000000000..8de66d8277 --- /dev/null +++ b/build_runner/test/integration_tests/web_compilers_test.dart @@ -0,0 +1,152 @@ +// Copyright (c) 2025, 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. + +@Tags(['integration4']) +library; + +import 'package:build_runner/src/logging/build_log.dart'; +import 'package:test/test.dart'; + +import '../common/common.dart'; + +void main() async { + test('web compilers', () async { + final pubspecs = await Pubspecs.load(); + final tester = BuildRunnerTester(pubspecs); + + tester.writeFixturePackage(FixturePackages.copyBuilder()); + + tester.writePackage( + name: 'root_pkg', + dependencies: [ + 'build', + 'build_config', + 'build_daemon', + 'build_modules', + 'build_runner', + 'build_web_compilers', + 'build_test', + ], + pathDependencies: ['builder_pkg'], + files: { + 'build.yaml': r''' +targets: + $default: + builders: + build_web_compilers:entrypoint: + generate_for: + - web/main.dart +''', + 'lib/a.dart': ''' + final stringInA = 'string in a.dart'; +''', + 'web/main.dart': ''' +import 'package:root_pkg/a.dart'; + +void main() { + print(stringInA); +} +''', + 'web/unused.dart': '', + }, + ); + + // Initial build. + await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build', + ); + expect( + tester.readFileTree('root_pkg/build')!.keys, + containsAll([ + 'main.dart.js', + 'main.digests', + 'main.dart.ddc_merged_metadata', + 'main.dart.bootstrap.js', + 'main.ddc.js.metadata', + 'main.ddc.js.map', + 'main.ddc.js', + 'main.dart', + r'packages/$sdk/dev_compiler/amd/require.js', + r'packages/$sdk/dev_compiler/ddc/ddc_module_loader.js', + r'packages/$sdk/dev_compiler/web/dart_stack_trace_mapper.js', + ]), + ); + + // DDC by default. Does not compile submodules into the root module. + expect( + tester.read('root_pkg/build/main.dart.js'), + isNot(contains('// Generated by dart2js')), + ); + expect( + tester.read('root_pkg/build/main.dart.js'), + isNot(contains('string in a.dart')), + ); + + // With dart2js. Does compile into a single file. + await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build ' + '--define build_web_compilers:entrypoint=compiler=dart2js', + ); + expect( + tester.read('root_pkg/build/main.dart.js'), + contains('string in a.dart'), + ); + expect( + tester.read('root_pkg/build/main.dart.js'), + contains('// Generated by dart2js'), + ); + + // With dart2js + minify. + await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build ' + '--define build_web_compilers:entrypoint=compiler=dart2js ' + '--define build_web_compilers:entrypoint=dart2js_args=["--minify"]', + ); + expect( + tester.read('root_pkg/build/main.dart.js'), + isNot(contains('// Generated by dart2js')), + ); + expect( + tester.read('root_pkg/build/main.dart.js'), + contains('typeof dartMainRunner==="function"'), + ); + + // With dart2wasm. + await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build ' + '--define build_web_compilers:entrypoint=compiler=dart2wasm', + ); + expect(tester.readBytes('root_pkg/build/main.wasm'), isNotNull); + + // Introduce an error, build fails. + tester.write('root_pkg/lib/a.dart', 'error'); + var output = await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build', + expectExitCode: 1, + ); + expect(output, contains(BuildLog.failurePattern)); + + // Stop importing the file with the error, build succeeds. + tester.write('root_pkg/web/main.dart', 'void main() {}'); + output = await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build', + ); + expect(output, contains(BuildLog.successPattern)); + + // With dart_source_cleanup unused source is removed. + expect(tester.read('root_pkg/build/unused.dart'), ''); + await tester.run( + 'root_pkg', + 'dart run build_runner build --output web:build ' + '--define=build_web_compilers:dart_source_cleanup=enabled=true', + ); + expect(tester.read('root_pkg/build/unused.dart'), null); + }); +} diff --git a/pubspec.yaml b/pubspec.yaml index ada302efd3..9e1ec9fbce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,8 +7,6 @@ dev_dependencies: workspace: - _benchmark -- _test -- _test/pkgs/provides_builder - build - build_config - build_daemon diff --git a/tool/ci.sh b/tool/ci.sh index 6ece3512c0..706f54784a 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -67,15 +67,7 @@ for PKG in ${PKGS}; do echo 'dart analyze --fatal-infos .' dart analyze --fatal-infos . || EXIT_CODE=$? ;; - command_0) - echo 'dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random' - dart run build_runner test -- -p chrome --test-randomize-ordering-seed=random || EXIT_CODE=$? - ;; - command_1) - echo 'dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random' - dart run build_runner test -- -p vm test/configurable_uri_test.dart --test-randomize-ordering-seed=random || EXIT_CODE=$? - ;; - command_2) + command) echo '../tool/leak_check.sh' ../tool/leak_check.sh || EXIT_CODE=$? ;; @@ -84,45 +76,37 @@ for PKG in ${PKGS}; do dart format --output=none --set-exit-if-changed . || EXIT_CODE=$? ;; test_0) - echo 'dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random' - dart test --total-shards 3 --shard-index 0 --test-randomize-ordering-seed=random || EXIT_CODE=$? - ;; - test_1) - echo 'dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random' - dart test --total-shards 3 --shard-index 1 --test-randomize-ordering-seed=random || EXIT_CODE=$? - ;; - test_2) - echo 'dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random' - dart test --total-shards 3 --shard-index 2 --test-randomize-ordering-seed=random || EXIT_CODE=$? - ;; - test_3) echo 'dart test --test-randomize-ordering-seed=random' dart test --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; - test_4) + test_1) echo 'dart test -P presubmit --test-randomize-ordering-seed=random' dart test -P presubmit --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; - test_5) - echo 'dart test -x integration1 -x integration2 -x integration3 --test-randomize-ordering-seed=random' - dart test -x integration1 -x integration2 -x integration3 --test-randomize-ordering-seed=random || EXIT_CODE=$? + test_2) + echo 'dart test -x integration1 -x integration2 -x integration3 -x integration4 --test-randomize-ordering-seed=random' + dart test -x integration1 -x integration2 -x integration3 -x integration4 --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; - test_6) + test_3) echo 'dart test -P experiments --test-randomize-ordering-seed=random' dart test -P experiments --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; - test_7) + test_4) echo 'dart test -t integration1 --test-randomize-ordering-seed=random' dart test -t integration1 --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; - test_8) + test_5) echo 'dart test -t integration2 --test-randomize-ordering-seed=random' dart test -t integration2 --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; - test_9) + test_6) echo 'dart test -t integration3 --test-randomize-ordering-seed=random' dart test -t integration3 --test-randomize-ordering-seed=random || EXIT_CODE=$? ;; + test_7) + echo 'dart test -t integration4 --test-randomize-ordering-seed=random' + dart test -t integration4 --test-randomize-ordering-seed=random || EXIT_CODE=$? + ;; *) echo -e "\033[31mUnknown TASK '${TASK}' - TERMINATING JOB\033[0m" exit 64