[flutter_tools] Consistently set the working directory for Flutter Test#74622
Conversation
00deb12 to
a161c02
Compare
a161c02 to
147b8ff
Compare
147b8ff to
8a10bb1
Compare
8a10bb1 to
c9f5cf3
Compare
|
CI seems to have stalled, but the tool tests pass locally, so marking it as ready for review first. |
|
I think IDEs may be already compensating for this in some way. I would double check with @devoncarew and @DanTup that this is safe to change |
|
(Otherwise I'm all for the idea) |
|
Not doing anything to handle this in VS Code (the inconsistency occurs there unless there's a workaround in the user code), so fixing this here would be beneficial for VS Code users :-) |
|
For IntelliJ, when launching |
|
It should be pretty easy to validate that |
|
(but please verify in AS/Intellij too) |
|
Yup, verified locally with the IntelliJ and VSCode plugins, we still can run individual tests via the UI. |
Fixes #20907. This makes
Directory.currentin tests always return the root of the flutter project, irregardless of whether the test command isflutter test(run all tests in$project/test), orflutter test test/foo_test.dart(run a specific test file).Context: I was trying to initialize an application package as a follow up to #74236 (to run integration tests with
flutter test). I got it to work for a single test, but running multiple tests did not work, because theFlutterProject.current()used in creating an application package works differently depending on the current working directory.Not sure if this is alright though, it seems a bit breaking for users depending on the incorrect behavior. This is somewhat mitigated because users probably use
flutter testto run all tests on CI, and the cases where I had to fix in this PR are probably less common (invokingflutter testin a subprocess from the test script). I also patched this and ran a global presubmit internally and there are no failures.