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

android_local_test on Windows: path doesn't exist in MANIFEST file #7809

Closed
jin opened this issue Mar 21, 2019 · 14 comments
Closed

android_local_test on Windows: path doesn't exist in MANIFEST file #7809

jin opened this issue Mar 21, 2019 · 14 comments
Assignees
Labels
area-Windows Windows-specific issues and feature requests P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@jin
Copy link
Member

jin commented Mar 21, 2019

Repro on Windows and Bazel 0.23.2:

git clone https://github.com/bazelbuild/rules_jvm_external
cd rules_jvm_external/examples/android_local_test
bazel test //... --test_output=errors

Error:

PS C:\Users\jingwen\Code\rules_jvm_external\examples\android_local_test> bazel test ... --test_output=errors
INFO: Analysed 6 targets (0 packages loaded, 0 targets configured).
INFO: Found 5 targets and 1 test target...
FAIL: //src/test:main_activity_test (see C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/testlogs/src/test/main_activity_test/test.log)
INFO: From Testing //src/test:main_activity_test:
==================== Test output for //src/test:main_activity_test:
LAUNCHER ERROR: Rlocation failed on __main__/external/androidsdk/platforms/android-28/android.jar, path doesn't exist in MANIFEST file
================================================================================
INFO: Elapsed time: 3.740s, Critical Path: 2.04s
INFO: 2 processes: 2 local.
INFO: Build completed, 1 test FAILED, 2 total actions
//src/test:main_activity_test                                            FAILED in 1.2s
  C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/testlogs/src/test/main_activity_test/test.log

INFO: Build completed, 1 test FAILED, 2 total actions
@jin jin self-assigned this Mar 21, 2019
@jin jin added P1 I'll work on this now. (Assignee required) team-Android Issues for Android team labels Mar 21, 2019
@jin
Copy link
Member Author

jin commented Mar 21, 2019

cc @laszlocsomor any ideas?

@jin
Copy link
Member Author

jin commented Mar 21, 2019

Here's the runfiles manifest for main_activity_test:

PS C:\Users\jingwen\Code\rules_jvm_external\examples\android_local_test\bazel-out> cat .\x64_windows-fastbuild\bin\src\test\main_activity_test.exe.runfiles\MANIFEST
__main__/bazel/robolectric/robolectric-deps.properties C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/genfiles/bazel/robolectric/robolectric-deps.properties
__main__/src/main/libmy_lib.jar C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/main/libmy_lib.jar
__main__/src/main/my_lib_resources.jar C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/main/my_lib_resources.jar
__main__/src/test/main_activity_test.ap_ C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/test/main_activity_test.ap_
__main__/src/test/main_activity_test.exe C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/test/main_activity_test.exe
__main__/src/test/main_activity_test.jar C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/test/main_activity_test.jar
__main__/src/test/main_activity_test_files/resource_files.zip C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/test/main_activity_test_files/resource_files.zip
__main__/src/test/main_activity_test_processed_manifest/AndroidManifest.xml C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/test/main_activity_test_processed_manifest/AndroidManifest.xml
__main__/src/test/main_activity_test_resources.jar C:/users/jingwen/_bazel_jingwen/ypfqostr/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/src/test/main_activity_test_resources.jar
androidsdk/platforms/android-28/android.jar C:/users/jingwen/_bazel_jingwen/ypfqostr/external/androidsdk/platforms/android-28/android.jar
<redacted for clarity>

It's correctly included in the runfiles.

@laszlocsomor
Copy link
Contributor

Runfiles paths are the first path in each manifest line.
No line starts with __main__/external/androidsdk/platforms/android-28/android.jar, so rlocation complains.

I can't repro the issue though (at bazel-contrib/rules_jvm_external@3d1120c). Instead I get:

C:\src\rules_jvm_external>bazel test //... --test_output=errors
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Reading 'startup' options from c:\users\laszlocsomor\.bazelrc: --output_user_root=c:/_bazel
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=120
INFO: Options provided by the client:
  Inherited 'build' options: --python_path=C:/python_27_amd64/files/python.exe
INFO: Reading rc options for 'test' from c:\users\laszlocsomor\.bazelrc:
  Inherited 'build' options: --verbose_failures --announce_rc
ERROR: error loading package 'third_party/bazel_json/test': Unable to load package for '//lib:json_rules.bzl': BUILD file not found on package path
INFO: Elapsed time: 5.521s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded)
FAILED: Build did NOT complete successfully (4 packages loaded)
    currently loading: tests/unit ... (2 packages)
    Fetching @bazel_skylib; fetching

@jin
Copy link
Member Author

jin commented Mar 25, 2019

Thanks for the explanation and reproing it. The test //... command should be run after cd rules_jvm_external/examples/android_local_test.

@laszlocsomor
Copy link
Contributor

Done.

Now I get:

ERROR: missing input file '@androidsdk//:emulator/qemu/linux-x86_64/qemu-system-i386'
ERROR: C:/src/rules_jvm_external/examples/android_instrumentation_test/src/test/BUILD:9:1: //src/test:greeter_test: missing input file '@androidsdk//:emulator/qemu/linux-x86_64/qemu-system-i386'
ERROR: C:/src/rules_jvm_external/examples/android_instrumentation_test/src/test/BUILD:9:1 1 input file(s) do not exist
INFO: Elapsed time: 135.488s, Critical Path: 42.81s
INFO: 387 processes: 352 local, 35 worker.
FAILED: Build did NOT complete successfully

My SDK:
android-sdk

@jin
Copy link
Member Author

jin commented Mar 26, 2019 via email

@laszlocsomor
Copy link
Contributor

Thanks! My bad. Successful repro! Taking a look.

@laszlocsomor
Copy link
Contributor

Behavior looks fine: runfiles manifest has androidsdk/platforms/android-28/android.jar but not __main__/external/androidsdk/platforms/android-28/android.jar.

On Linux:

  $ bazel query 'deps(//src/test:main_activity_test)' | grep 'android.jar'
@bazel_tools//tools/android:android_jar
@androidsdk//:platforms/android-27/android.jar

rlocation argument syntax is <repo_name>/<pkg_path>/<path_in_pkg>, so androidsdk/platforms/android-28/android.jar looks good.

Am I still missing something?

@laszlocsomor
Copy link
Contributor

Wait, it's a launcher error. Let me look further.

@laszlocsomor laszlocsomor self-assigned this Mar 26, 2019
@laszlocsomor
Copy link
Contributor

It's a launcher bug. Fixing it.

@laszlocsomor laszlocsomor added type: bug area-Windows Windows-specific issues and feature requests and removed team-Android Issues for Android team labels Mar 26, 2019
@jin
Copy link
Member Author

jin commented Mar 26, 2019

@laszlocsomor Thank you for looking into it!!

@laszlocsomor
Copy link
Contributor

Good news: I can fix it.
Bad news: only in 0.25.0, if I get the patch submitted today or tomorrow.

@laszlocsomor
Copy link
Contributor

laszlocsomor commented Mar 27, 2019

After fixing the bug, I get:

C:\src\rules_jvm_external\examples\android_local_test>c:\src\bazel\bazel-bin\src\bazel.exe test //src/test:main_activity_test --test_output=errors
...
FAIL: //src/test:main_activity_test (see C:/_bazel/n7ysgmgi/execroot/__main__/bazel-out/x64_windows-fastbuild/testlogs/src/test/main_activity_test/test.log)
INFO: From Testing //src/test:main_activity_test:
==================== Test output for //src/test:main_activity_test:
JUnit4 Test Runner
.E
Time: 0.009
There was 1 failure:
1) initializationError(com.example.bazel.MainActivityTest)
java.lang.RuntimeException: Delegate runner 'org.robolectric.RobolectricTestRunner' for AndroidJUnit4 could not be loaded.
        at androidx.test.ext.junit.runners.AndroidJUnit4.throwInitializationError(AndroidJUnit4.java:92)
        at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:82)
        at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:51)
        at androidx.test.ext.junit.runners.AndroidJUnit4.<init>(AndroidJUnit4.java:46)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
        at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
        at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
        at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
        at com.google.testing.junit.runner.internal.junit4.MemoizingRequest.createRunner(MemoizingRequest.java:48)
        at com.google.testing.junit.runner.internal.junit4.MemoizingRequest.getRunner(MemoizingRequest.java:34)
        at com.google.testing.junit.runner.junit4.JUnit4TestModelBuilder.get(JUnit4TestModelBuilder.java:49)
        at com.google.testing.junit.runner.junit4.JUnit4TestModelBuilder.get(JUnit4TestModelBuilder.java:27)
        at com.google.testing.junit.runner.util.MemoizingSupplier.get(MemoizingSupplier.java:42)
        at com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:92)
        at com.google.testing.junit.runner.BazelTestRunner.runTestsInSuite(BazelTestRunner.java:153)
        at com.google.testing.junit.runner.BazelTestRunner.main(BazelTestRunner.java:84)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:72)
        ... 20 more
Caused by: java.lang.RuntimeException: couldn't read dependencies
        at org.robolectric.RobolectricTestRunner.getJarResolver(RobolectricTestRunner.java:113)
        at org.robolectric.RobolectricTestRunner.<init>(RobolectricTestRunner.java:98)
        ... 25 more
Caused by: java.io.FileNotFoundException: bazel\robolectric\robolectric-deps.properties (The system cannot find the path specified)
        at java.io.FileInputStream.open0(Native Method)
        at java.io.FileInputStream.open(FileInputStream.java:195)
        at java.io.FileInputStream.<init>(FileInputStream.java:138)
        at org.robolectric.res.FileFsFile.getInputStream(FileFsFile.java:76)
        at org.robolectric.internal.dependency.PropertiesDependencyResolver.loadProperties(PropertiesDependencyResolver.java:24)
        at org.robolectric.internal.dependency.PropertiesDependencyResolver.<init>(PropertiesDependencyResolver.java:17)
        at org.robolectric.RobolectricTestRunner.getJarResolver(RobolectricTestRunner.java:110)
        ... 26 more

FAILURES!!!
Tests run: 1,  Failures: 1

@jin
Copy link
Member Author

jin commented Mar 27, 2019

Great, thank you! No worries, we can wait for 0.25.

That bug looks like it's unable to access a resource in the classpath from a dep. I'll take a look at it with your fix.

laszlocsomor added a commit to laszlocsomor/bazel that referenced this issue Mar 27, 2019
In this PR:

- //src/tools/launcher now uses the C++ runfiles
  library, depending on it's source and not on
  the released version under @bazel_tools (so it's
  built with the same runfiles library sources as
  those embedded into the Bazel binary)

- The launcher no longer discovers nor loads the
  runfiles manifest.

Fixes bazelbuild#7809
laszlocsomor added a commit to laszlocsomor/bazel that referenced this issue Mar 28, 2019
The native launcher's own Rlocation()
implementation correctly handles runfile paths
that start with "external/".

Fixes bazelbuild#7809

This PR subsumes bazelbuild#7853.
That PR changed the launcher to use the C++
runfiles library. Alas that broke some tests.
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

3 participants