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
Args from launch configuration was ignored when running a test from codeLens #3462
Sorry for the bother. In the most recent version there was some tidying up of how args are passed to Dart/Flutter because the ordering or arguments can be important and was applied inconsistently. This was expected to not be breaking so was not called out in the release notes, but it looks like in the case of using args with flutter test this was not the case.
There are now two fields in launch.json, toolArgs and args. The toolArgs field always goes before the script being run, and the args field always goes after, eg.:
dart {toolArgs} script.dart {args}
dart run test:test {toolArgs} script.dart {args}
flutter run {toolArgs} script.dart {args}
flutter test {toolArgs} script.dart {args}
For dart run test:test it appears that switches are allowed after the test filenames:
dart run test:test test/foo_test.dart -r json
However the same thing is not true for Flutter:
flutter test test/widget_test.dart -r json
This tries to load -r and -json as tests:
00:00 +0 -1: loading /Users/danny/Desktop/flutter_application_1/-r [E]
Failed to load "/Users/danny/Desktop/flutter_application_1/-r": Does not exist.
00:00 +0 -2: loading /Users/danny/Desktop/flutter_application_1/json [E]
Failed to load "/Users/danny/Desktop/flutter_application_1/json": Does not exist.
00:02 +1 -2: Some tests failed.
As a fix, you can start using toolArgs instead of args for things like --update-goldens. I'll open an issue in Flutter for discussion on the behaviour about to see if it it's a bug and/or we could make it work like testing via Dart so that either would work (if not, it may be worth making args behave differently depending on the project type, although I'd prefer to keep it consistent if I can).
On second thoughts, I think running directly on the VM is probably an outlier here so I'm going to partially revert those changes. I'll make a release soon that will restore this behaviour without needing any changes in the launch configurations.
On third thoughts, I decided to just special-case flutter test for now. And I did file flutter/flutter#85891 for some discussion to see if that can be handled there which should simplify things.
I'll publish a release with the fix shortly and let you know when it's available.
Activity
DanTup commentedon Jul 5, 2021
Sorry for the bother. In the most recent version there was some tidying up of how
argsare passed to Dart/Flutter because the ordering or arguments can be important and was applied inconsistently. This was expected to not be breaking so was not called out in the release notes, but it looks like in the case of usingargswithflutter testthis was not the case.There are now two fields in
launch.json,toolArgsandargs. ThetoolArgsfield always goes before the script being run, and theargsfield always goes after, eg.:For
dart run test:testit appears that switches are allowed after the test filenames:However the same thing is not true for Flutter:
This tries to load
-rand-jsonas tests:As a fix, you can start using
toolArgsinstead ofargsfor things like--update-goldens. I'll open an issue in Flutter for discussion on the behaviour about to see if it it's a bug and/or we could make it work like testing via Dart so that either would work (if not, it may be worth makingargsbehave differently depending on the project type, although I'd prefer to keep it consistent if I can).DanTup commentedon Jul 5, 2021
On second thoughts, I think running directly on the VM is probably an outlier here so I'm going to partially revert those changes. I'll make a release soon that will restore this behaviour without needing any changes in the launch configurations.Insert [args] before script name for "flutter test"
DanTup commentedon Jul 5, 2021
On third thoughts, I decided to just special-case
flutter testfor now. And I did file flutter/flutter#85891 for some discussion to see if that can be handled there which should simplify things.I'll publish a release with the fix shortly and let you know when it's available.
DanTup commentedon Jul 5, 2021
Please run the Extension: Check for Updates command in VS Code to get v3.24.2 and this problem should be resolved.
If
flutter testis updated to support args in the same place as others, I may tweak the implementation but it should not impact the user of"args".Thanks!