Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Args from launch configuration was ignored when running a test from codeLens #3462

Closed
HelloCore opened this issue Jul 5, 2021 · 4 comments
Closed
Labels
in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps in testing Relates to test execution of Dart/Flutter tests for end users is bug
Milestone

Comments

@HelloCore
Copy link

Describe the bug
When running a test from codeLens, it doesn't pass args from the launch config.

To Reproduce

  1. git clone https://github.com/eBay/flutter_glove_box.git
  2. code flutter_glove_box/packages/golden_toolkit/
  3. Go to example/test/example_test.dart
  4. Click on Golden button on top of main function

Expected behavior
It should pass args from launch.json.

Versions (please complete the following information):

  • VS Code version: 1.57.1
  • Dart extension version: 3.24.1
  • Dart/Flutter SDK version: 2.2.1
@DanTup
Copy link
Member

DanTup commented Jul 5, 2021

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).

@DanTup DanTup added this to the v3.25.0 milestone Jul 5, 2021
@DanTup
Copy link
Member

DanTup commented 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.

@DanTup DanTup modified the milestones: v3.25.0, v3.24.2 Jul 5, 2021
@DanTup
Copy link
Member

DanTup commented Jul 5, 2021

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.

@DanTup DanTup closed this as completed in b619836 Jul 5, 2021
@DanTup
Copy link
Member

DanTup commented 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 test is 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!

@DanTup DanTup added in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps in testing Relates to test execution of Dart/Flutter tests for end users labels Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in debugger Relates to the debug adapter or process of launching a debug session in flutter Relates to running Flutter apps in testing Relates to test execution of Dart/Flutter tests for end users is bug
Projects
None yet
Development

No branches or pull requests

2 participants