Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

Description

We'd like to support flutter run -d chrome testfile in the flutter framework (#55512), since this supports a significantly better debugging experience than flutter test --platform chrome. A blocker to adopting that is compilation errors caused by the usage of test helpers imported via relative paths.

Due to the generated entry point required in web builds (to bootstrap the rendering, much like the android/iOS hosts do on mobile), the compiler has difficulty resolving these paths.

For regular apps this isn't an issue since the compiler can convert the imports using the package scheme information. Since test files don't actually live in a package, this doesn't work for them.

To fix this, we can hoist these test helpers into their own package and make them a dev_dependency of the framework.

@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Apr 24, 2020
@jonahwilliams
Copy link
Contributor Author

And for completeness, here is the compilation problem:

[  +12 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[ +204 ms] 
                    Compiler message:
[        ] org-dartlang-app:/input_decorator_test.dart:11:8: Error: Error when reading 'org-dartlang-app:/rendering/mock_canvas.dart': File not
found
[        ] import '../rendering/mock_canvas.dart';
[        ]        ^
[+1496 ms] org-dartlang-app:/input_decorator_test.dart:3143:17: Error: Getter not found: 'paints'.
[        ]     expect(box, paints..path(
[        ]                 ^^^^^^
[        ] org-dartlang-app:/input_decorator_test.dart:3156:17: Error: Getter not found: 'paints'.
[        ]     expect(box, paints..rrect(
[        ]                 ^^^^^^
[        ] org-dartlang-app:/input_decorator_test.dart:3184:17: Error: Getter not found: 'paints'.
[        ]     expect(box, paints..path(
[        ]                 ^^^^^^
[   +1 ms] org-dartlang-app:/input_decorator_test.dart:3614:33: Error: Getter not found: 'paints'.
[        ]     expect(findBorderPainter(), paints
[        ]                                 ^^^^^^
[+11422 ms] Syncing files to device Chrome... (completed in 13,185ms, longer than expected)

This is not a bug in dart, its doing entirely the right thing here

@jonahwilliams
Copy link
Contributor Author

I wonder if a better solution is setting an additional compilation root to the location of the test file. If that fixes, its a much simpler change.

@jonahwilliams
Copy link
Contributor Author

Nevermind! changing the compilation root is a much simpler fix, and works with other projects

#55531

@jonahwilliams jonahwilliams deleted the move_mock_canvas branch April 24, 2020 03:50
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants