Skip to content

flutter test sets current directory differently depending on how test was executed #20907

@DanTup

Description

@DanTup

Moving from Dart-Code/Dart-Code#1156 as this seems to happen from the command line. Depending on whether you pass a filename to flutter test or just run all tests (or filter using --plain-name or whatever) the value of Directory.current will be different.

Since flutter forces you to run flutter test from the root (eg. you can't influence the working directory yourself) these should probably be consistent.

dantup-macbookpro:flutter_hello_world dantup$ flutter test --plain-name 222
00:04 +0: /Users/dantup/Dev/Dart-Code/test/test_projects/flutter_hello_world/test/widget_test.dart: 222Hello world test                                        
Directory: '/Users/dantup/Dev/Dart-Code/test/test_projects/flutter_hello_world/test'

                                                                                                                                    
dantup-macbookpro:flutter_hello_world dantup$ flutter test test/widget_test.dart 
00:04 +0: 222Hello world test                                                                                                                                  
Directory: '/Users/dantup/Dev/Dart-Code/test/test_projects/flutter_hello_world'

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our testscustomer: crowdAffects or could affect many people, though not necessarily a specific customer.found in release: 1.21Found to occur in 1.21has reproducible stepsThe issue has been confirmed reproducible and is ready to work ontoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions