Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path of generated test import is broken, when the test file is not in the integration_test folder #2162

Closed
DevFreeze opened this issue Mar 25, 2024 · 8 comments

Comments

@DevFreeze
Copy link

Steps to reproduce

  1. Move the integration test file in any other location than integration_test, e.g. a folder named patrol_test.

Actual results

The generated test_bundle.dart will contain the following import line:

// START: GENERATED TEST IMPORTS
import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as
  D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
// END: GENERATED TEST IMPORTS
  1. It is the absolute path, rather than the relative path
  2. The generated name has a problem with the : and the -

Logs

Logs
$ patrol test -t patrol_test/login_test.dart --verbose

Verbose mode enabled. More logs will be printed.
$ flutter --suppress-analytics --no-version-check pub deps --style=list
Received 1 test target(s)
Received test target: D:\Development\AndroidStudioProjects\my-app\patrol_test/login_test.dart
Generated entrypoint D:\Development\AndroidStudioProjects\my-app\integration_test\test_bundle.dart with 1 bundled test(s)
$ flutter --no-version-check --suppress-analytics devices --machine
No device specified, using the first one (emulator-5554)
Received 1 device(s) to run on
Received device: emulator-5554
Received 9 --dart-define(s) (0 custom, 9 internal)
Received internal --dart-define: PATROL_WAIT=0
Received internal --dart-define: PATROL_APP_PACKAGE_NAME=com.example.myapp
Received internal --dart-define: PATROL_APP_BUNDLE_ID=com.example.myapp
Received internal --dart-define: PATROL_ANDROID_APP_NAME=My-App
Received internal --dart-define: PATROL_IOS_APP_NAME=My-App
Received internal --dart-define: INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false
Received internal --dart-define: PATROL_TEST_LABEL_ENABLED=true
Received internal --dart-define: PATROL_TEST_SERVER_PORT=8081
Received internal --dart-define: PATROL_APP_SERVER_PORT=8082
• Building apk with entrypoint test_bundle.dart...
$ .\gradlew.bat :app:assembleDebug -Ptarget=D:\Development\AndroidStudioProjects\my-app\integration_test\test_bundle.dart -Pdart-defines=UEFUUk9MX
1dBSVQ9MA==,UEFUUk9MX0FQUF9QQUNLQUdFX05BTUU9Y29tLnRhbGxlbmNlLmR0aWNrZXQ=,UEFUUk9MX0FQUF9CVU5ETEVfSUQ9Y29tLnRhbGxlbmNlLmR0aWNrZXQ=,UEFUUk9MX0FORFJPSURfQVBQX05BTUU9RC1
UaWNrZXQ=,UEFUUk9MX0lPU19BUFBfTkFNRT1ELVRpY2tldA==,SU5URUdSQVRJT05fVEVTVF9TSE9VTERfUkVQT1JUX1JFU1VMVFNfVE9fTkFUSVZFPWZhbHNl,UEFUUk9MX1RFU1RfTEFCRUxfRU5BQkxFRD10cnVl,UEFUUk9MX1RFU1RfU0VSVkVSX1BPUlQ9ODA4MQ==,UEFUUk9MX0FQUF9TRVJWRVJfUE9SVD04MDgy -Papp-server-port=8082 -Ptest-server-port=8081
        : Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
        You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply

        : 
        : > Configure project :app
        You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply

        : WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34
        :
        : This Android Gradle plugin (7.3.0) was tested up to compileSdk = 33
        :
        : This warning can be suppressed by adding
        :     android.suppressUnsupportedCompileSdk=34
        : to this project's gradle.properties
        :
        : The build will continue, but you are strongly encouraged to update your project to
        : use a newer Android Gradle Plugin that has been tested with compileSdk = 34
        : 
        : > Task :app:preBuild UP-TO-DATE
        : > Task :app:preDebugBuild UP-TO-DATE
        : > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
        : 
        : > Task :app:compileFlutterBuildDebug
        integration_test/test_bundle.dart:12:96: Error: Expected ';' after this.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
                                                                                  ^
        integration_test/test_bundle.dart:12:97: Error: Expected a declaration, but got ':'.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
                                                                                  ^
        integration_test/test_bundle.dart:12:98: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
        Try adding the name of the type of the variable or the keyword 'var'.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
                                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        integration_test/test_bundle.dart:12:98: Error: Expected ';' after this.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
                                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        integration_test/test_bundle.dart:12:147: Error: Expected a declaration, but got '-'.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
                                                                                  ^
        integration_test/test_bundle.dart:12:148: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
        Try adding the name of the type of the variable or the keyword 'var'.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
                                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        integration_test/test_bundle.dart:12:8: Error: Error when reading 'd:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart': File d:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart does not exist.
        import 'D:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart' as D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test;
               ^
        integration_test/test_bundle.dart:69:8: Error: Too few positional arguments: 2 required, 1 given.
          group('D:.Development.AndroidStudioProjects.my-app.patrol_test.login_test', D:__Development__AndroidStudioProjects__my-app__patrol_test__login_test.main);
               ^
        /C:/flutter/packages/flutter_test/lib/src/test_compat.dart:190:6: Context: Found this candidate, but the arguments don't match.
        void group(Object description, void Function() body, { dynamic skip, int? retry }) {
             ^^^^^
        Unhandled exception:
        FileSystemException(uri=d:/Development/AndroidStudioProjects/my-app/patrol_test/login_test.dart; message=StandardFileSystem only supports file:* and data:* URIs)
        #0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34)
        #1      asFileUri (package:vm/kernel_front_end.dart:748)
        #2      writeDepfile (package:vm/kernel_front_end.dart:886)
        <asynchronous suspension>
        #3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:673)
        <asynchronous suspension>
        #4      starter (package:frontend_server/starter.dart:101)
        <asynchronous suspension>
        #5      main (file:///C:/b/s/w/ir/x/w/sdk/pkg/frontend_server/bin/frontend_server_starter.dart:13)
        <asynchronous suspension>

        Target kernel_snapshot failed: Exception

        : 
        : > Task :app:compileFlutterBuildDebug FAILED

        FAILURE: Build failed with an exception.

        * Where:
        Script 'C:\flutter\packages\flutter_tools\gradle\src\main\groovy\flutter.groovy' line: 1419

        * What went wrong:
        Execution failed for task ':app:compileFlutterBuildDebug'.
        > Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

        * Try:
        > Run with --stacktrace option to get the stack trace.
        > Run with --info or --debug option to get more log output.
        > Run with --scan to get full insights.

        * Get more help at https://help.gradle.org

        :
        : Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
        :
        : You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
        :
        : See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings
        : 1 actionable task: 1 executed
        BUILD FAILED in 23s
✗ Failed to build apk with entrypoint test_bundle.dart (Gradle build failed with code 1) (24.7s)
Exception: Gradle build failed with code 1
#0      AndroidTestBackend.build.<anonymous closure> (package:patrol_cli/src/android/android_test_backend.dart:67:9)
<asynchronous suspension>
#1      DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
<asynchronous suspension>
#2      AndroidTestBackend.build (package:patrol_cli/src/android/android_test_backend.dart:42:5)
<asynchronous suspension>
#3      TestCommand._build (package:patrol_cli/src/commands/test.dart:268:7)
<asynchronous suspension>
#4      TestCommand.run (package:patrol_cli/src/commands/test.dart:202:5)
<asynchronous suspension>
#5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6      PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:341:18)
<asynchronous suspension>
#7      PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:285:18)
<asynchronous suspension>
#8      patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:70:20)
<asynchronous suspension>
#9      main (file:///C:/Users/johnn/AppData/Local/Pub/Cache/hosted/pub.dev/patrol_cli-2.6.5/bin/main.dart:6:20)
<asynchronous suspension>

See the logs above to learn what happened. Also consider running with --verbose. If the logs still aren't useful, then it's a bug - please report it.
Exception: Gradle build failed with code 1
#0      AndroidTestBackend.build.<anonymous closure> (package:patrol_cli/src/android/android_test_backend.dart:67:9)
<asynchronous suspension>
#1      DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
<asynchronous suspension>
#2      AndroidTestBackend.build (package:patrol_cli/src/android/android_test_backend.dart:42:5)
<asynchronous suspension>
#3      TestCommand._build (package:patrol_cli/src/commands/test.dart:268:7)
<asynchronous suspension>
#4      TestCommand.run (package:patrol_cli/src/commands/test.dart:202:5)
<asynchronous suspension>
#5      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6      PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:341:18)
<asynchronous suspension>
#7      PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:285:18)
<asynchronous suspension>
#8      patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:70:20)
<asynchronous suspension>
#9      main (file:///C:/Users/johnn/AppData/Local/Pub/Cache/hosted/pub.dev/patrol_cli-2.6.5/bin/main.dart:6:20)
<asynchronous suspension>

Patrol version

patrol: 3.6.0

Patrol Doctor output

Patrol Doctor output
Patrol doctor:
Patrol CLI version: 2.6.5
Android:
• Program adb found in C:\Users\johnn\AppData\Local\Android\Sdk\platform-tools\adb.exe
• Env var $ANDROID_HOME set to C:\Users\johnn\AppData\Local\Android\Sdk

Flutter Doctor output

Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.4, on Microsoft Windows [Version 10.0.22631.3296], locale de-DE)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.6)
[√] Android Studio (version 2023.2)
[√] Connected device (3 available)
[√] Network resources

• No issues found!
@bartekpacia
Copy link
Contributor

Your tests must be in the integration_test directory. Other locations are not supported and I don't think it's a bug.

@DevFreeze
Copy link
Author

Thanks for the reply :)

Alright. Is there some specific reason it is not supported? Otherwise I would just create a feature request for storing the files in a chosen directory, e.g. the test directory.

@bartekpacia
Copy link
Contributor

This is how Flutter does it (placing end-to-end/integration tests inside integration_test directory). This project decided to embrace this convention. I think it's a useful distinction.

@DevFreeze
Copy link
Author

Ok, then let's keep it how it is :D

So the ticket can be closed then :)

@zltnDC
Copy link
Contributor

zltnDC commented Apr 16, 2024

I've encountered a similar issue on Windows. The command patrol test -t integration_test\login_test.dart works fine, but using patrol test -t .\integration_test\login_test.dart causes this problem.

@mvarendorff2
Copy link
Contributor

Dupe of #1814 ?

@mateuszwojtczak
Copy link
Contributor

Closing this one as it's resolved, let's continue the .\ bug in #1814 :)

Copy link

github-actions bot commented May 6, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants