strongback / strongback-java

A library for FIRST Robotics Competition robots that makes it easier to write and test your robot code.
MIT License
41 stars 38 forks source link

ant test fails for Ubuntu 14.04 #47

Open jaimeyu opened 9 years ago

jaimeyu commented 9 years ago

Hey, pretty stock ubuntu 14.04 VM with FRC toolchain and I'm trying to build Strongback from scratch. I get test failures (looks like junit is not in the classpath).

Raw logs at https://gist.github.com/jaimeyu/010dc9328c25e1ecb1b3 If you want the VM, let me know, I will privately share it.

(I also get the same issue when I run 'ant test' for newly made strongback.sh projects).

rhauch commented 8 years ago

@Zabot, can you try to replicate this on Ubuntu?

rhauch commented 8 years ago

This looks similar to the errors reported in #49; I think Travis uses Ubuntu in their images. Funny thing is that our Travis builds are working. Would appreciate anyone on Ubuntu giving this a whirl to see if they can identify the problem or a fix.

agausmann commented 7 years ago

This is definitely related to #49 and I am able to reproduce a similar problem. I get a NoClassDefFoundError when it tries to access classes from hamcrest. There must be some inconsistency in how/when dependencies are managed between systems.

Here is my output when running ant test for reference: test.txt

WawerOS commented 7 years ago

I found that adding the jars in libs/test to CLASSPATH fixed the issue. I don't know how to implement it in ant though.

agausmann commented 7 years ago

That's what I'm assuming. We can probably figure out how to do that in Ant, or have Ant download them to a designated place instead of hosting them in the repository. Alternatively, if we migrate to Maven builds ( #92 ), that will likely also fix our issue.

rhauch commented 7 years ago

I found that adding the jars in libs/test to CLASSPATH fixed the issue. I don't know how to implement it in ant though.

The Ant build file is already doing this, or at least it is supposed to be doing this. This currently works on OS X on Ubuntu 12.04 (as evidenced by Travis-CI and, for example, this recent pull request). Note that I and Travis-CI are using Ant 1.10.0 (mostly because of recent fixes to Ant's HTTP GET utility, which we need to download 3rd party libraries).

It works this way: the Ant build file (actually build-common.xml) is defining a classpath named test.class.path at line 46 comprised of the normal compile.class.path (defined on line 37) plus the *.jar files (except *-sources.jar) files in the ${strongback.dir}/libs/test directory or subdirectories, then using this classpath when compiling the tests and running the tests.

Bottom line is that this definitely varies on different systems. @jaimeyu is running Ubuntu 14.04, but what OS are you running, @AGausmann and @WawerOS? And what version of Ant are you all running? Do you each have all of the following files are in the lib/test directory?

Are the permissions okay on that directory and the files inside?

One thing you might try if you haven't already is to run Ant with verbose mode via ant -v clean test.

rhauch commented 7 years ago

BTW, #49 had this in the output:

Trying to override old definition of task classloader

@AGausmann, you didn't include enough output to see whether you're getting the same thing. And @jaimeyu's file didn't have it either.

agausmann commented 7 years ago

I am not getting that message in Strongback itself, but I have seen it in WPILib robot projects that are using Strongback.

Here is ant -v test output from a fresh clone: out.txt

I am running Arch Linux with ant 1.9.7, the latest release for this distro.

rhauch commented 7 years ago

Ok, I may have found the problem but I'd like someone to try a potential fix first. Here's ine 93-96 of build-common.xml:

        <classpath refid="test.class.path" />
        <classpath> 
            <pathelement location="${project.test.output.dir}"/>
        </classpath>

Note how there are two <classpath> elements? I think these lines should be changed to:

        <classpath> 
            <path refid="test.class.path" />
            <pathelement location="${project.test.output.dir}"/>
        </classpath>

@AGausmann, @WawerOS, or @jaimeyu, would one of you be willing to make this change locally and try it? If that works, can you submit a PR? It's not clear from the Ant documentation or other sites whether this is valid, so we might have to try some alternatives, like maybe inserting the following lines just before the <javac element on line 87:

      <path id="test.run.class.path">
        <path refid="test.class.path" />
        <pathelement location="${project.test.output.dir}"/>
      </path>

to define a path named test.run.class.path and then changing lines 93-96 to be:

        <classpath refid="test.run.class.path" /> 
agausmann commented 7 years ago

Just tried, and it didn't work. Got the exact same results.

WawerOS commented 7 years ago

I am running Xubuntu version 16.10 and ant version 1.10, here is the log from the ant -v test. I tried both variations of the build file and they didn't work.