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

Unit tests using wrong version of joda-time with bazel #1660

Closed
mightyguava opened this issue Aug 18, 2016 · 2 comments
Closed

Unit tests using wrong version of joda-time with bazel #1660

mightyguava opened this issue Aug 18, 2016 · 2 comments

Comments

@mightyguava
Copy link

mightyguava commented Aug 18, 2016

Hi,

I'm trying to migrate our repo to bazel, and am running into a rather strange error in unit tests only. The error reproduced below.

I'm using joda-time 2.8.2, which has the DateTime#withTime(LocalTime time) method. When running as a java_binary, the method works just fine. When running as a java_test, the method is missing...

I suspect that the unit test deploy jar is overriding my joda_time dependency with bazel's own, specifically this one right here! https://github.com/bazelbuild/bazel/blob/master/third_party/joda_time/joda-time-2.3.jar

A minimal repro case is here https://github.com/mightyguava/bazeldatetime.

Running bazel run src/main/yunchi:yunchi_bin will work, but running bazel test src/test/yunchi:AllTests will fail with the error below.

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
-----------------------------------------------------------------------------
JUnit4 Test Runner
.E
Time: 0.081
There was 1 failure:
1) testGetDateTime(yunchi.JodaAppTest)
java.lang.NoSuchMethodError: org.joda.time.DateTime.withTime(Lorg/joda/time/LocalTime;)Lorg/joda/time/DateTime;
    at yunchi.JodaApp.getDateTime(JodaApp.java:10)
    at yunchi.JodaAppTest.testGetDateTime(JodaAppTest.java:9)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at com.google.testing.junit.runner.junit4.CancellableRequestFactory$CancellableRunner.run(CancellableRequestFactory.java:90)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
    at com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:114)
    at com.google.testing.junit.runner.BazelTestRunner.runTestsInSuite(BazelTestRunner.java:152)
    at com.google.testing.junit.runner.BazelTestRunner.main(BazelTestRunner.java:91)

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


BazelTestRunner exiting with a return value of 1
JVM shutdown hooks (if any) will run now.
The JVM will exit once they complete.

-- JVM shutdown starting at 2016-08-18 11:22:14 --
@mightyguava mightyguava changed the title Bazel unit tests using wrong version of joda-time Unit tests using wrong version of joda-time with bazel Aug 18, 2016
@mightyguava
Copy link
Author

@ulfjack I saw you are working on the Bazel Java Test Runner. Do you mind taking a look at this issue? I'm reasonably convinced it's due to the Bazel test runner not shading its dependencies.

@mightyguava
Copy link
Author

Fixed by 7a45855

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant