Skip to content

Conversation

@andrewkolos
Copy link
Contributor

@andrewkolos andrewkolos commented Jan 25, 2024

Part of work on #101077. This is done as a separate PR to avoid a massive diff.

Context

  1. The FakeCommand class accepts a list of patterns that's used to match a command given to its FakeProcessManager. Since FakeCommand can match a list of patterns, not just specifically strings, it can be used to match commands where the exact value of some arguments can't (easily) known ahead of time. For example, a part of the tool may invoke a command with an argument that is the path of a temporarily file that has a randomly-generated basename.
  2. The FakeCommand class provides on onRun parameter, which is a callback that is run when the FakeProcessManager runs a command that matches the FakeCommand in question.

Issue

In the event that a FakeCommand is constructed using regex pattenrs, the test code can't know the exact values used for arguments in the command. This PR proposes changing the type of onRun from VoidCallback? to void Function(List<String>)?. When run, the value List<String> parameter will be the full command that the FakeCommand matched.

Example:

FakeCommand(
  command: <Pattern>[
    artifacts.getArtifactPath(Artifact.engineDartBinary),
    'run',
    'vector_graphics_compiler',
    RegExp(r'--input=/.*\.temp'),
    RegExp(r'--output=/.*\.temp'),
  ],
  onRun: (List<String> command) {
    final outputPath = (() { 
      // code to parse `--output` from `command`
    })();
    testFileSystem.file(outputPath).createSync(recursive: true);
  },
)

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@andrewkolos andrewkolos added the tool Affects the "flutter" command-line tool. See also t: labels. label Jan 25, 2024
@andrewkolos andrewkolos marked this pull request as ready for review January 25, 2024 06:23
Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

nit about the dartdoc, but otherwise this change makes sense

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 25, 2024
@auto-submit auto-submit bot merged commit 295a9a2 into flutter:master Jan 25, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 25, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 25, 2024
Roll Flutter from 19b06f4 to a8efa77 (38 revisions)

flutter/flutter@19b06f4...a8efa77

2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from e2014f007f61 to 7c4ed15cb271 (1 revision) (flutter/flutter#142221)
2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5fa2e2920274 to e2014f007f61 (1 revision) (flutter/flutter#142213)
2024-01-25 andrewrkolos@gmail.com provide command to `FakeCommand::onRun` (flutter/flutter#142206)
2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from c346fd3d9ca1 to 5fa2e2920274 (1 revision) (flutter/flutter#142212)
2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from d4d8f668159b to c346fd3d9ca1 (1 revision) (flutter/flutter#142209)
2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from 499ed00bbda2 to d4d8f668159b (2 revisions) (flutter/flutter#142205)
2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4880592ca5ba to 499ed00bbda2 (6 revisions) (flutter/flutter#142202)
2024-01-25 ditman@gmail.com [ci] Adds test for web hot restart with const App. (flutter/flutter#141824)
2024-01-25 godofredoc@google.com Migrate android_view to linux_android_emu platform. (flutter/flutter#142184)
2024-01-25 matanlurey@users.noreply.github.com Refactor `external_ui` without making any name changes (I think) (flutter/flutter#142192)
2024-01-25 rmolivares@renzo-olivares.dev Fix text selection edge scrolling when inside a horizontal scrollable (flutter/flutter#140250)
2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from d7bf5ec1dcdd to 4880592ca5ba (2 revisions) (flutter/flutter#142186)
2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6a7f963dc751 to d7bf5ec1dcdd (2 revisions) (flutter/flutter#142185)
2024-01-24 polinach@google.com Reland "Remove hack from PageView." (flutter/flutter#142172)
2024-01-24 polinach@google.com Upgrade leak_tracker. (flutter/flutter#142162)
2024-01-24 godofredoc@google.com Migrate android views to devicelab. (flutter/flutter#142081)
2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from ed498f111d53 to 6a7f963dc751 (4 revisions) (flutter/flutter#142176)
2024-01-24 jaeyoi.dev@gmail.com Support wireless debugging for iOS 12 or earlier (flutter/flutter#141439)
2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4bc368ee5f74 to ed498f111d53 (5 revisions) (flutter/flutter#142167)
2024-01-24 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Refactor `external_ui` � `external_textures`" (flutter/flutter#142173)
2024-01-24 matanlurey@users.noreply.github.com Refactor `external_ui` � `external_textures` (flutter/flutter#142062)
2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0b9fce355df9 to 4bc368ee5f74 (3 revisions) (flutter/flutter#142157)
2024-01-24 jhy03261997@gmail.com Update navigationBar label's maxScaleFactor to meet GAR requirement (flutter/flutter#141998)
2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from b65556fa543e to 0b9fce355df9 (1 revision) (flutter/flutter#142147)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_2_4 to be unflaky (flutter/flutter#142115)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_2_4 to be unflaky (flutter/flutter#142111)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_1_4 to be unflaky (flutter/flutter#142110)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_3_4 to be unflaky (flutter/flutter#142112)
2024-01-24 greg@zulip.com Revise tooltip theme docs, including more cross-references (flutter/flutter#137316)
2024-01-24 godofredoc@google.com Run some tests explicitly in both arm and x64. (flutter/flutter#141910)
2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from ba3a70ce7722 to b65556fa543e (3 revisions) (flutter/flutter#142140)
2024-01-24 31859944+LongCatIsLooong@users.noreply.github.com Fixes #138773, port autocomplete to OverlayPortal (flutter/flutter#140285)
2024-01-24 jesus_sguerrero@hotmail.com Revert "[web] - Fix broken `TextField` in semantics mode when it's a sibling of `Navigator`" (flutter/flutter#142129)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_1_4 to be unflaky (flutter/flutter#142114)
2024-01-24 engine-flutter-autoroll@skia.org Roll Packages from 841fe90 to 8fbdf65 (2 revisions) (flutter/flutter#142139)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_3_4 to be unflaky (flutter/flutter#142116)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_4_4 to be unflaky (flutter/flutter#142113)
2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_4_4 to be unflaky (flutter/flutter#142117)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com 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
...
@andrewkolos andrewkolos deleted the add-command-to-fake-command-on-run branch April 29, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants