Compile error when using "main" as test file name
Opened this issue · 4 comments
rekire commented
Steps to reproduce
- Follow your tutorial including the sample test
- Rename the test file to
main.dart
- Set in
pubspec.yaml
test_file_suffix
to.dart
- Run
patrol test -t integration_test/main.dart
Actual results
The test fails with the error:
• Building apk with entrypoint test_bundle.dart...
integration_test/test_bundle.dart:12:23: Error: 'main' is already declared in this scope.
import 'main.dart' as main;
^^^^
integration_test/test_bundle.dart:15:14: Context: Previous declaration of 'main'.
Future<void> main() async {
^^^^
It seems that the file name is used as some kind of namespace. I could guess some other file names like default.dart
which will cause compile errors.
Logs
Logs
<!-- Replace this line with your logs. Do not remove the backticks! -->
Patrol version
patrol: ^3.7.3
Patrol Doctor output
Patrol Doctor output
Patrol CLI version: 2.7.0
Flutter command: flutter
Flutter 3.22.1 • channel stable
Android:
• Program adb found in /censored/adb
• Env var $ANDROID_HOME set to /censored/
iOS / macOS:
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller
Flutter Doctor output
Flutter Doctor output
<!-- Replace this line with your logs. Do not remove the backticks! -->
bartekpacia commented
In the generated test bundle file, there's already a function named main
.
I could guess some other file names like default.dart which will cause compile errors.
Why would default.dart
cause compile errors?
rekire commented
I think that all dart keywords would cause trouble, since I got the impression that the file name get used as prefix or namespace (I'm right now not sure how it is called in dart)
bartekpacia commented
ah yeah, this makes sense
jBorkowska commented
Hi @rekire , thank you for creating this issue.
That is a bug, though we're leaving it for now as it has low priority