Skip to content

flutter test --name not accepting lookahead syntax due to SETLOCAL ENABLEDELAYEDEXPANSION in batch entrypoint #84270

Description

@robertohuertasm

Hi, I was just trying to ignore some of my golden tests, whose name starts by Golden and decided to use this:

flutter test --name "^(?!Golden).+"

What I receive from the CLI is this instead: Couldn't parse --name "[(?Golden).+]": Invalid group(?Golden).+

Note that the ! from the lookahead is gone.

I've tried to review the code but I can't see any kind of sanitizer process. I've also seen that you're using the args package and I did a quick test of that library without success. It works as expected. So there may be another place where this substitution of the ! is taking place.

Maybe I'm missing something obvious. If you could point me in the right direction I would create a PR in order to fix this.

Activity

  1. TahaTesser commented on Jun 10, 2021

    @TahaTesser
    Contributor

    HI @robertohuertasm
    Looking at the source, all names parameters are taken as they're and sent to test_core

    This capturing all the names into testArgs llist source

          for (final String name in names)
            ...<String>['--name', name],

    Which then feeds into testWrappaer without modifying any source

          await testWrapper.main(testArgs);

    testWrapper's main simply feeds into test_core source

    I am not sure test_coreis suppose to be looking for lookahead or Flutter tools itself

    test_core is actually a dart package

    In either case, this doesn't seem to be supported

  2. added
    a: tests"flutter test", flutter_test, or one of our tests
    c: new featureNothing broken; request for a new capability
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: qualityA truly polished experience
    and removed
    in triagePresently being triaged by the triage team
    on Jun 10, 2021
  3. robertohuertasm commented on Jun 10, 2021

    @robertohuertasm
    Author

    Hi @TahaTesser, yes I followed the code exactly like you mention.

    My understading is that in the end, at least for what it looks from these lines of code what the test_core runner is doing is this:

    if (!suite.config.patterns.every((pattern) => test.name.contains(pattern))) {
        return false;
    }

    In Dart, lookaheads are supported so if the pattern arrives intact here, when calling to .contains, it should work right away... That's why I thought all this was just some piece of code sanitizing the string at some point.

  4. TahaTesser commented on Jun 10, 2021

    @TahaTesser
    Contributor

    @robertohuertasm
    That's excellent, I haven't looked into test_core as mentioned. If the Flutter cleaning this and leaving something out, it would be a bug than a new feature.

    Somebody from the tools team can add more here

  5. asashour commented on Jun 22, 2021

    @asashour
    Contributor

    This comes from Dart, as shown in the minimal test case:

    test.dart

    void main(List<String> args) {
      print('args: $args');
    }

    Result

    >dart test.dart "^(?!Golden).+"
    args: [(?Golden).+]
    
  6. bkonyi commented on Jun 24, 2021

    @bkonyi
    Contributor

    This is an issue with the various .bat scripts we have which are setting SETLOCAL ENABLEDELAYEDEXPANSION which will swallow unescaped !s and ^s. We should avoid setting this, if possible, to prevent this sort of unexpected behavior for user provided arguments.

    cc @jonahwilliams @christopherfujino

  7. jonahwilliams commented on Jun 24, 2021

    @jonahwilliams
    Contributor

    hmm, I wonder why we set that in the first place 🤔

    This is from before my time

  8. added
    P2Important issues not at the top of the work list
    on Jun 24, 2021
  9. 8 remaining items

  10. removed
    r: fixedIssue is closed as already fixed in a newer version
    on Jul 9, 2021
  11. fzyzcjy commented on Nov 30, 2023

    @fzyzcjy
    Contributor

    Hi, I am having the same issue dart-lang/sdk#54191 (that's a dart report, but the cause seems to be here). Is there any updates after two years? Thanks

  12. bkonyi commented on Nov 30, 2023

    @bkonyi
    Contributor
  13. christopherfujino commented on Dec 1, 2023

    @christopherfujino
    Contributor

    I think the "fix" here would be to port this script to powershell. we could leave the flutter.bat file, which would trivially just be:

    Powershell.exe -File flutter.ps1 %*

    This would still leave cmd users with this bug, but at least they would have the option to invoke it via powershell.

  14. christopherfujino commented on Dec 1, 2023

    @christopherfujino
    Contributor

    @eliasyishak just wondering, is this the same underlying issue as that bug you were looking at a while ago?

  15. eliasyishak commented on Dec 1, 2023

    @eliasyishak
    Contributor

    This seems related, the previous bug was around properly escaping the & character on windows for a dart define. I didn't know powershell would help solve this though, good to know

  16. DanTup commented on Nov 26, 2024

    @DanTup
    Contributor

    This seems related, the previous bug was around properly escaping the & character on windows for a dart define. I didn't know powershell would help solve this though, good to know

    I'm wrestling with something very similar now, see Dart-Code/Dart-Code#5322 / dart-lang/sdk#59604. In this case the command is being run by the IDE (or debug adapter) though, using Process.start(), which has to spawn a shell and therefore requires us to escape correctly. However, the use of %* seems to require another level of escaping that I think belongs inside the .bat file, but I've failed to make work (see dart-lang/sdk#59604 (comment)).

    I feel like it would be better if we (at least the IDE/debug adapter) could bypass the shell script entirely so there's no argument escaping to go wrong. For example if flutter.bat compiled a native executable (instead of just the Dart snapshot), or provided a supported way to invoke the snapshot via dart.exe directly, I think that would solve these issues from the IDE/debug adapters perspective.

  17. added
    tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.
    on Jul 10, 2025
  18. github-actions commented on Sep 5, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: qualityA truly polished experiencea: tests"flutter test", flutter_test, or one of our teststeam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions