Skip to content

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

Closed

Description

@HelloCore

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

Activity

  1. DanTup commented on Jul 5, 2021

    @DanTup
    Member

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

  2. added this to the v3.25.0 milestone on Jul 5, 2021
  3. DanTup commented on Jul 5, 2021

    @DanTup
    Member

    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.

  4. added a commit that references this issue on Jul 5, 2021
    b619836
  5. modified the milestones: v3.25.0, v3.24.2 on Jul 5, 2021
  6. DanTup commented on Jul 5, 2021

    @DanTup
    Member

    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.

  7. DanTup commented on Jul 5, 2021

    @DanTup
    Member

    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!

  8. added
    in debuggingRelates to the debug adapter or process of running debug sessions
    in flutterRelates to running Flutter apps
    in testingRelates to test execution of Dart/Flutter tests for end users
    on Jul 5, 2021
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

    in debuggingRelates to the debug adapter or process of running debug sessionsin flutterRelates to running Flutter appsin testingRelates to test execution of Dart/Flutter tests for end usersis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions