Skip to content

[flutter_tools] Remove testWithoutContext in favor of test - #197259

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
bkonyi:di/remove-test-without-context
Nov 25, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
bkonyi:di/remove-test-without-context

Conversation

@bkonyi

@bkonyi bkonyi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

testWithoutContext was added to help remove context globals (globals.dart) by throwing if code read from AppContext. Now that context globals have been removed from flutter_tools (globals.dart), tests can use test directly.

Removes testWithoutContext and _NoContext from packages/flutter_tools/test/src/common.dart and replaces all testWithoutContext usages and references across the repository with test. Also removes the dead on UnsupportedError catch in FlutterVersion.resetFlutterVersionFreshnessCheck (which previously masked FakeCache.getStampFileFor throwing UnimplementedError), implements FakeCache.getStampFileFor, removes the _NoContext UnsupportedError test from common_test.dart, updates dev/bots/analyze.dart, packages/flutter_tools/AGENTS.md, and packages/flutter_tools/README.md, and fixes the stale testWithoutContext.stamp filename in build_system_test.dart.

Part of #47161

Removes `testWithoutContext` and `_NoContext` from `packages/flutter_tools/test/src/common.dart` and replaces all `testWithoutContext` usages and references across the repository with `test`.

Also removes the dead `on UnsupportedError` catch in `FlutterVersion.resetFlutterVersionFreshnessCheck` (which previously masked `FakeCache.getStampFileFor` throwing `UnimplementedError`), implements `FakeCache.getStampFileFor`, removes the `_NoContext` `UnsupportedError` test from `common_test.dart`, updates `dev/bots/analyze.dart`, `packages/flutter_tools/AGENTS.md`, and `packages/flutter_tools/README.md`, and fixes the stale `testWithoutContext.stamp` filename in `build_system_test.dart`.

Part of flutter#47161
@bkonyi bkonyi added the CICD Run CI/CD label Nov 23, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Nov 23, 2026
…thout-context

Resolve conflicts in dependency_injection_test.dart and runner_test.dart, convert newly merged testWithoutContext calls to test, and pass required featureFlags: TestFeatureFlags() in localizations_test.dart.
@bkonyi
bkonyi marked this pull request as ready for review November 23, 2026 23:11
@bkonyi
bkonyi requested review from a team as code owners November 23, 2026 23:11
@bkonyi
bkonyi requested review from chingjun and mboetger and removed request for a team November 23, 2026 23:11

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates tests across the flutter_tools package and integration tests from using testWithoutContext to test. It also updates the analysis script analyze.dart and documentation in README.md and AGENTS.md to reflect this change, and removes obsolete error handling in version.dart. A review comment identifies a typo in a test description within dtd_services_test.dart and suggests correcting 'retreive' to 'retrieve'.

});
},
);
test('can set and retreive values from $PersistentPreferences', () async {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the test description: 'retreive' should be 'retrieve'.

Suggested change
test('can set and retreive values from $PersistentPreferences', () async {
test('can set and retrieve values from $PersistentPreferences', () async {

@loic-sharma

Copy link
Copy Markdown
Member

@bkonyi I'd consider updating the PR description to explain that testWithoutContext was added to help remove context globals, and that now that we've removed context globals we can use test directly :)

…thout-context

# Conflicts:
#	packages/flutter_tools/test/general.shard/build_system/targets/localizations_test.dart
chingjun
chingjun previously approved these changes Nov 24, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit

auto-submit Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/197259, because Pull request flutter/flutter/197259 is not in a mergeable state.

…thout-context

# Conflicts:
#	packages/flutter_tools/AGENTS.md
#	packages/flutter_tools/README.md
#	packages/flutter_tools/test/general.shard/build_system/targets/icon_tree_shaker_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
#	packages/flutter_tools/test/general.shard/compile_batch_test.dart
#	packages/flutter_tools/test/general.shard/compile_incremental_test.dart
#	packages/flutter_tools/test/src/common.dart
chingjun
chingjun previously approved these changes Nov 25, 2026
…thout-context

# Conflicts:
#	packages/flutter_tools/test/general.shard/base/logger_test.dart
#	packages/flutter_tools/test/general.shard/device_test.dart
#	packages/flutter_tools/test/general.shard/flutter_validator_test.dart
#	packages/flutter_tools/test/general.shard/isolated/native_assets_test.dart
#	packages/flutter_tools/test/general.shard/web/web_asset_server_test.dart
…thout-context

# Conflicts:
#	packages/flutter_tools/test/general.shard/build_system/depfile_test.dart
#	packages/flutter_tools/test/general.shard/build_system/targets/extension_test.dart
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
@auto-submit

auto-submit Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

auto label is removed for flutter/flutter/197259, Failed to enqueue flutter/flutter/197259 with HTTP 400: Something went wrong while executing your query on 2026-11-25T16:07:08Z. Please include CD58:FBB62:6BAD897:15174722:6B0707AA when reporting this issue..

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into flutter:master with commit f300d9c Nov 25, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 26, 2026
Roll Flutter from 06f1c24345a2 to 82ec4242da79 (33 revisions)

flutter/flutter@06f1c24...82ec424

2026-11-26 [email protected] Roll Dart SDK from 7663c79b8a29 to 7fcaf46b0308 (1 revision) (flutter/flutter#197465)
2026-11-26 [email protected] Roll Skia from 8bf5f2e2b358 to cef5963c1bb2 (1 revision) (flutter/flutter#197453)
2026-11-26 [email protected] Roll Dart SDK from 771539f4435a to 7663c79b8a29 (2 revisions) (flutter/flutter#197451)
2026-11-26 [email protected] Roll Skia from 535259fe7750 to 8bf5f2e2b358 (1 revision) (flutter/flutter#197449)
2026-11-26 [email protected] Roll Skia from f20b7f274ec8 to 535259fe7750 (4 revisions) (flutter/flutter#197442)
2026-11-26 [email protected] Roll Fuchsia Test Scripts from 56keLr8vaDtnH6vqW... to d5xIJpr0Hxkwjlpnr... (flutter/flutter#197441)
2026-11-26 [email protected] Roll Skia from 168ddb88c5b6 to f20b7f274ec8 (1 revision) (flutter/flutter#197438)
2026-11-26 [email protected] Roll Dart SDK from dcfa4247aa49 to 771539f4435a (1 revision) (flutter/flutter#197431)
2026-11-26 [email protected] Roll Skia from 67badb88843a to 168ddb88c5b6 (1 revision) (flutter/flutter#197430)
2026-11-26 [email protected] iOS: Pass composition order NSArray instead of std::vector (flutter/flutter#197418)
2026-11-26 [email protected] Migrate function type define to use the dart style define (flutter/flutter#197419)
2026-11-26 [email protected] iOS: Submit platform view frames from IOSExternalViewEmbedder (flutter/flutter#197411)
2026-11-26 [email protected] Roll Skia from fc1230e8afbb to 67badb88843a (1 revision) (flutter/flutter#197422)
2026-11-25 [email protected] Roll Fuchsia Linux SDK from HtAKfFLbfAQ6g96RY... to 0bgCrr76CM4IqPO0v... (flutter/flutter#197415)
2026-11-25 [email protected] Roll Dart SDK from 6155a47022d7 to dcfa4247aa49 (2 revisions) (flutter/flutter#197413)
2026-11-25 [email protected] Roll Skia from c2d40fc8f6b3 to fc1230e8afbb (2 revisions) (flutter/flutter#197407)
2026-11-25 [email protected] [flutter_tools] Add ProjectExtensionFinder and ExtensionKernelCompiler (flutter/flutter#194772)
2026-11-25 [email protected] [flutter_tools] Migrate resident runner, hot/cold, and TestBed tests off testUsingContext (flutter/flutter#197256)
2026-11-25 [email protected] [flutter_tools] Migrate create, packages, upgrade, runner, and args tests off testUsingContext (flutter/flutter#197255)
2026-11-25 [email protected] [flutter_tools] Migrate Darwin platform and build command tests off testUsingContext (flutter/flutter#197254)
2026-11-25 [email protected] [flutter_tools] Migrate Android, desktop, and web build tests off testUsingContext (flutter/flutter#197252)
2026-11-25 [email protected] iOS: Move platform view frame state to IOSExternalViewEmbedder (flutter/flutter#197362)
2026-11-25 [email protected] [flutter_tools] Migrate build target and native assets tests off testUsingContext (flutter/flutter#197246)
2026-11-25 [email protected] [flutter_tools] Migrate hermetic command tests off testUsingContext (flutter/flutter#197250)
2026-11-25 [email protected] [flutter_tools] Migrate widget preview, asset, plugin, compiler, and device tests off testUsingContext (flutter/flutter#197257)
2026-11-25 [email protected] Roll Skia from e84ecd98d9f2 to c2d40fc8f6b3 (2 revisions) (flutter/flutter#197398)
2026-11-25 [email protected] Roll Fuchsia Test Scripts from GPtykFNizlaauBqzs... to 56keLr8vaDtnH6vqW... (flutter/flutter#197382)
2026-11-25 [email protected] [flutter_tools] Remove last remaining context.get calls in lib/ (flutter/flutter#197253)
2026-11-25 [email protected] [Impeller] Subtract global pass position from backdrop filter local-to-pass transform (flutter/flutter#197324)
2026-11-25 [email protected] [Impeller] Skip mipmaps for decoded images that are resized on the GPU (flutter/flutter#197013)
2026-11-25 [email protected] [flutter_tools] Remove testWithoutContext in favor of test (flutter/flutter#197259)
2026-11-25 [email protected] Roll Packages from f455dfa to 105a874 (10 revisions) (flutter/flutter#197386)
2026-11-25 [email protected] Roll Dart SDK from 5202130a51b8 to 6155a47022d7 (1 revision) (flutter/flutter#197384)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
...
famio added a commit to famio/flutter that referenced this pull request Nov 26, 2026
Move the new buildXcodeProject test off testUsingContext like the tests
next to it (flutter#197254), and use test instead of testWithoutContext in
mac_test.dart (flutter#197259).
chingjun added a commit to chingjun/flutter that referenced this pull request Nov 27, 2026
The branch was rebased onto master (ba17b71, 90 commits after the
last base, ac8f87e), with which the pull request no longer merged:
nine files conflicted, the first of them since 689d7b9 ("Upgrade CI
to Xcode 27.2", flutter#196807). The replay gave each conflict
to the replayed commit, so in those files the commits below this one
hold the branch's old text, and they keep the lock file and the
generated files of the old base. Of the 656 commits replayed (the 634
of the last push and 22 new ones) 646 keep their patch ids, nine
changed (they touch files master changed too), and one is gone:
"[flutter_tools] A test added upstream passes featureFlags", whose one
line is upstream's own since flutter#197269.

This commit's tree is the tree of a merge of the same master into the
branch (those 656 commits), with the nine conflicts resolved by hand
and six files more that master's 90 commits need: fifteen files differ
from the merge as git writes it, and no other.

The nine conflicts:

- ci/builders/mac_clang_tidy.json: the branch's three builds, with
  upstream's Xcode (sdk_version 27b52, flutter#196807).
- lib/web_ui/dev/chrome.dart: the branch's --remote-debugging-port=0
  and upstream's --js-flags=--expose-gc (flutter#197245).
- Seven test files of flutter_tools. Upstream removed
  testWithoutContext in favour of test (flutter#197259) and moved tests off
  testUsingContext (flutter#197246, flutter#197254, flutter#197257).
  build_system/targets/android_test.dart and ios_test.dart are
  master's with the branch's one line (the include is
  HostArtifact.shaderLib). localizations_test.dart is master's: the
  branch's one-line fix of it is upstream's flutter#197269 now.
  runner/local_engine_test.dart, android/
  android_gradle_builder_test.dart, ios/xcodeproj_test.dart and
  tester/flutter_tester_test.dart are master's with the branch's
  tests as plain test() calls.

Not conflicts in the text, and needed all the same (the six files):

- artifacts_test.dart merged cleanly and called the removed
  testWithoutContext seven times: test() now.
- The Scenario app's simulator runtime is iOS 27.2, as upstream's
  run_ios_tests.dart and goldens have it since flutter#196807: the
  converter's manifest.dart and the generated
  testing/ios_scenario_app/BUILD.bazel.
- deps.lock.bzl for master's DEPS: the rolls of Skia, Dart and Dart's
  BoringSSL, the Fuchsia SDK and Fuchsia's test scripts.
  pub.lock.bzl does not change (upstream changed no pubspec).
- The converter's output for two BUILD.gn files upstream changed:
  shell/platform/darwin/ios/BUILD.bazel (the new test source
  FlutterPlatformViewsControllerObjCTest.m, flutter#197429) and
  shell/platform/embedder/BUILD.bazel (the dependency on
  //flutter/impeller/renderer/backend/vulkan and two fixtures,
  flutter#193004).
- dart format on two of the merged tests (artifacts_test.dart,
  xcodeproj_test.dart): test( is shorter than the name it replaces.

Checked on this tree, all of it on Linux, with the Dart SDK DEPS pins
(3.15.0-185.0.dev, the engine's prebuilt one):

- gen_deps.dart and gen_pub_lock.dart, and both with --check; the
  converter regenerated and with --check (112 generated files
  current): the three files named above changed and no other.
- dart format over the 98 Dart files that differ from master.
- The analyzer over flutter_tools, dev/bots, flutter_goldens, the
  converter, bazel_tools and lib/web_ui/dev: no issues.
- Tests: the ten tool test files the branch touches,
  localizations_test.dart and the test command's (399 tests); the
  converter's suite (319); dev/bots' bazel_test.dart,
  run_command_test.dart and test_test.dart (59). One of the 59 fails
  where no SHARD is set: upstream's "--dry-run prints every test that
  would run" inherits the environment, and without a shard a dry run
  on Linux ends at the first one, which throws off a Mac (master's
  code reads the same; not run there). With SHARD=framework_tests and
  SUBSHARD=misc, as its bot has them, it passes.
- check_build_configs.sh, check_generated_bazel_files.sh,
  bazel_ci_test.py (36), engine_build_configs (84), bazel_tools (62),
  GN's own check (tools/gn) for a host debug build, tools/gn_test.py
  (7), ci/pylint.sh, ci/format.sh (its Python step through yapf
  directly, 14 files).
- buildifier over the 364 Starlark files that differ from master. One
  warning, and an old one: build/bazel/toolchains/emscripten/spike/
  BUILD.bazel calls sh_test without loading it from rules_shell. The
  file is the last push's; earlier runs gave buildifier only the
  files a change touched. Left as it is here.
- Bazel analysis: ci_host_debug, host_release_test, //:tool_tests
  //:dart_tests, and every Linux build of builds.json with its
  install and its suite under its own configuration (47 of 47, 4 of
  them without RBE). The first analysis with the rolled Skia and
  Dart, whose BUILD files are generated when their repositories are
  set up.

Not run: nothing was built, linked or run under Bazel on this tree,
on Linux or on a Mac, and no Dart tool ran on a Mac. The merge's Mac
and iOS side (the clang-tidy builds' Xcode, the Scenario app's
runtime, the new iOS test source) and the new embedder dependency
have their first build on the bots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants