You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
flutter test --name not accepting lookahead syntax due to SETLOCAL ENABLEDELAYEDEXPANSION in batch entrypoint #84270
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.
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))) {
returnfalse;
}
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.
@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.
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.
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
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
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.
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.
Activity
TahaTesser commentedon Jun 10, 2021
HI @robertohuertasm
Looking at the source, all names parameters are taken as they're and sent to
test_coreThis capturing all the names into
testArgsllist sourceWhich then feeds into
testWrappaerwithout modifying any sourcetestWrapper's main simply feeds into
test_coresourceI am not sure
test_coreis suppose to be looking for lookahead or Flutter tools itselftest_core is actually a dart package
In either case, this doesn't seem to be supported
robertohuertasm commentedon Jun 10, 2021
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_corerunner is doing is this: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.TahaTesser commentedon Jun 10, 2021
@robertohuertasm
That's excellent, I haven't looked into
test_coreas 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
asashour commentedon Jun 22, 2021
This comes from Dart, as shown in the minimal test case:
test.dart
Result
bkonyi commentedon Jun 24, 2021
This is an issue with the various
.batscripts we have which are settingSETLOCAL ENABLEDELAYEDEXPANSIONwhich 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
jonahwilliams commentedon Jun 24, 2021
hmm, I wonder why we set that in the first place 🤔
This is from before my time
8 remaining items
fzyzcjy commentedon Nov 30, 2023
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
bkonyi commentedon Nov 30, 2023
FYI @christopherfujino
christopherfujino commentedon Dec 1, 2023
I think the "fix" here would be to port this script to powershell. we could leave the
flutter.batfile, 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.
christopherfujino commentedon Dec 1, 2023
@eliasyishak just wondering, is this the same underlying issue as that bug you were looking at a while ago?
eliasyishak commentedon Dec 1, 2023
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 knowDanTup commentedon Nov 26, 2024
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.batfile, 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.batcompiled a native executable (instead of just the Dart snapshot), or provided a supported way to invoke the snapshot viadart.exedirectly, I think that would solve these issues from the IDE/debug adapters perspective.[flutter_tools] Add tests for negative lookahead regex in test runner…
github-actions commentedon Sep 5, 2026
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 -vand a minimal reproduction of the issue.