Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353222

Summary: port tycho-surefire to surefire 2.10
Product: z_Archived Reporter: Steffen Pingel <steffen.pingel>
Component: TychoAssignee: Jan Sievers <jan.sievers>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: igor, jan.sievers, sochotnicky
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 351100    
Attachments:
Description Flags
pom
none
log file
none
patch to port tycho-surefire to surefire 2.9 none

Description Steffen Pingel CLA 2011-07-27 11:16:12 EDT
Java tests are not being executed.

pre.. 
[INFO] 
[INFO] --- tycho-source-plugin:0.13.0-SNAPSHOT:plugin-source (attach-source) @ org.eclipse.mylyn.java.tests ---
[INFO] Building jar: /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/org.eclipse.mylyn.java.tests-3.7.0-SNAPSHOT-sources.jar
[INFO] 
[INFO] --- maven-resources-plugin:2.4.1:testResources (default-testResources) @ org.eclipse.mylyn.java.tests ---
[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/src/test/resources
[INFO] 
[INFO] --- tycho-compiler-plugin:0.13.0-SNAPSHOT:testCompile (default-testCompile) @ org.eclipse.mylyn.java.tests ---
[INFO] Using compile source roots from build.properties
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- tycho-packaging-plugin:0.13.0-SNAPSHOT:package-plugin (default-package-plugin) @ org.eclipse.mylyn.java.tests ---
[INFO] Building jar: /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/org.eclipse.mylyn.java.tests-3.7.0-SNAPSHOT.jar
[INFO] 
[INFO] --- tycho-p2-plugin:0.13.0-SNAPSHOT:p2-metadata (default-p2-metadata) @ org.eclipse.mylyn.java.tests ---
[INFO] 
[INFO] --- tycho-surefire-plugin:0.13.0-SNAPSHOT:test (default-test) @ org.eclipse.mylyn.java.tests ---
[INFO] Adding repository (cached) https://hudson.eclipse.org/hudson/job/mylyn-commons-nightly/lastSuccessfulBuild/artifact/org.eclipse.mylyn.commons-site/target/site/
[INFO] Adding repository (cached) https://hudson.eclipse.org/hudson/job/mylyn-tasks-nightly/lastSuccessfulBuild/artifact/org.eclipse.mylyn.tasks-site/target/site/
[INFO] Adding repository (cached) http://download.eclipse.org/releases/indigo/
[INFO] Adding repository (cached) http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository/
[INFO] Expected eclipse log file: /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/work/data/.metadata/.log
[INFO] Command line:
	/bin/sh -c cd /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests && /opt/public/common/sun-jdk1.6.0_21_x64/jre/bin/java -Dosgi.noShutdown=false -Dosgi.os=linux -Dosgi.ws=gtk -Dosgi.arch=x86_64 -Xmx1024m -XX:MaxPermSize=256m -Djava.io.tmpdir=/opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target -ea -Dmylyn.credentials=/home/data/httpd/download-staging.priv/tools/mylyn/hudson/.credentials.properties -Dorg.eclipse.mylyn.wikitext.tests.disableOutput=true -Dhttp.proxyHost=proxy.eclipse.org -Dhttp.proxyPort=9898 -DhttpnonProxyHosts=wiki.eclipse.org -jar /opt/users/hudsonbuild/workspace/mylyn-context-nightly/.repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.2.0.v20110502/org.eclipse.equinox.launcher-1.2.0.v20110502.jar -data /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/work/data -dev file:/opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/dev.properties -install /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/work -configuration /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/work/configuration -application org.eclipse.tycho.surefire.osgibooter.uitest -testproperties /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/surefire.properties -testApplication org.eclipse.ui.ide.workbench -product org.eclipse.sdk.ide -eclipse.keyring /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/.eclipse.keyring -eclipse.password /opt/users/hudsonbuild/workspace/mylyn-context-nightly/org.eclipse.mylyn.java.tests/target/work/configuration/config.ini
Xlib:  extension "RANDR" missing on display ":10.0".
[2011-07-25T5-55-51] Status WARNING: org.eclipse.mylyn.tasks.ui code=0 No search provider was registed. Tasks search is not available. null, 

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Comment 1 Steffen Pingel CLA 2011-08-14 07:48:28 EDT
Created attachment 201474 [details]
pom
Comment 2 Steffen Pingel CLA 2011-08-14 07:49:40 EDT
Moving to Tycho since I have not been able to figure out why this is not working. We use the same pattern for all test bundles. We have configure a test suite in the pom that runs all JUnit tests. This works for a dozen test bundles except for org.eclipse.mylyn.java.tests which runs but no tests are executed.

The error log is empty and running with -console shows that all required bundles resolve fine:

osgi> diag org.eclipse.mylyn.java.tests
initial@reference:file:../../ [64]
  No unresolved constraints.

Is there any way to debug execution of the tycho-surefire-plugin further?
Comment 3 Steffen Pingel CLA 2011-08-14 08:32:46 EDT
I was able to work around it by changing the configuration to this:

		<configuration>
          <includes>
            <include>**/AllJavaTests.class</include>
          </includes>
        </configuration>

Still, it's not clear to me why it doesn't work to configure the test suite explicitly for this bundle while it works for all other Mylyn test bundles.
Comment 4 Jan Sievers CLA 2011-08-15 03:39:44 EDT
please add 'mvn -X -e' debug log and link to source repository/CI build.
Comment 5 Steffen Pingel CLA 2011-08-15 08:44:05 EDT
How would that make a difference? The problem happens during execution of Eclipse and not in Maven.
Comment 6 Jan Sievers CLA 2011-08-15 11:05:56 EDT
(In reply to comment #5)
> How would that make a difference? The problem happens during execution of
> Eclipse and not in Maven.

as it says "no tests to run" it could be that the testrunner was misconfigured to include test(s) that don't exist.
Comment 7 Steffen Pingel CLA 2011-08-15 11:24:02 EDT
Created attachment 201503 [details]
log file
Comment 8 Steffen Pingel CLA 2011-08-15 11:24:20 EDT
Here are the steps:

# git clone ssh://git.eclipse.org/gitroot/mylyn/org.eclipse.mylyn.context.git
# cd org.eclipse.mylyn.context/
# mvn -Dmaven.test.skip=true install
# cd org.eclipse.mylyn.java.tests/
[edit pom.xml]
# mvn -X -e integration-test

I have attached the log output of the last command. The org.eclipse.mylyn.context/org.eclipse.mylyn.java.tests/target/surefire-reports/ directory is empty.
Comment 9 Jan Sievers CLA 2011-08-15 11:54:46 EDT
(In reply to comment #8)
the debug log says:

[DEBUG] Using test framework org.junit4

but your test suite class 

http://git.eclipse.org/c/mylyn/org.eclipse.mylyn.context.git/tree/org.eclipse.mylyn.java.tests/src/org/eclipse/mylyn/java/tests/AllJavaTests.java 

is not annotated with @RunWith(Suite.class)

=> no tests are found.

junit4 runner is used because you did not specify a version range to force version < 4 in the test bundle MANIFEST
http://git.eclipse.org/c/mylyn/org.eclipse.mylyn.context.git/tree/org.eclipse.mylyn.java.tests/META-INF/MANIFEST.MF

Require-Bundle: org.junit,

and tycho will resolve junit to whatever it can get (junit 4 in this case).

=> Either explicitly require junit < 4  or port tests to junit 4 with annotations (and explicitly require junit >= 4).

Let me know if this solves your issue.
Comment 10 Steffen Pingel CLA 2011-08-15 14:23:42 EDT
Thanks for the explanation. I am surprised that it works for the other Mylyn test bundles that don't have version ranges specified either. I tried adding this in the manifest but it did not make a difference:

 Require-Bundle: org.junit;bundle-version="[3.8.2,4.0.0)"

I tried adding another class with JUnit 4 annotations without any luck but I might have not used the annotations correctly:

 @RunWith(Suite.class)
 @SuiteClasses(AllJavaTests.class)

Anyways, feel free to mark this as workforme. The work around in comment#3 works fine.
Comment 11 Igor Fedorenko CLA 2011-08-15 23:48:31 EDT
By default, Tycho includes=**/Test*.class,**/*Test.class,**/*TestCase, which does not match AllJavaTests.class afaict.

Also, I have local branch that allows forcing use of junit v3 launcher for projects that depend on junit v4. I can merge it to master if anyone is interested.
Comment 12 Jan Sievers CLA 2011-08-16 12:03:46 EDT
Forcing the junit v3 launcher by specifying a version range in the test plugin works fine.

after some in-depth debugging, I found the problem:

it's actually a bug in surefire

http://jira.codehaus.org/browse/SUREFIRE-638

surefire can't handle "java" in includes :(

... and here we have org/eclipse/mylyn/java/tests/AllJavaTests.class

which surefire converts to 

org/eclipse/mylyn/class/tests/AllJavaTests.class
                  ^^^^^

(instead of only replacing ".java" at the end of the String only if found)

and this class of course can't be found.

=> we should update the surefire  version used by tycho to >= 2.7 where this bug is fixed.
Comment 13 Steffen Pingel CLA 2011-08-17 14:03:36 EDT
Wow, great find! That explains why the java tests bundle was the only broken one. Thanks for digging into this.
Comment 14 Jan Sievers CLA 2011-08-18 12:21:03 EDT
Created attachment 201728 [details]
patch to port tycho-surefire to surefire 2.9

patch which ports tycho-surefire to surefire 2.9

I attach it as patch and don't submit it because

1. we will need to file CQs for surefire 2.9 and I don't want to further delay initial check-in
2. 2 classes are still copied from surefire-junit3 instead of fixing a bug in surefire


The hard part was to find out why code was originally copied from surefire-junit.

Turns out the reason why the code was copied is a bug with suite classes (see patch) which it seems was never reported and thus still exists in latest surefire 2.9 :(

I will report it at http://jira.codehaus.org/browse/SUREFIRE 

The patch fixes the issue again by copying but I would prefer we fix it in surefire.
Comment 15 Jan Sievers CLA 2011-08-19 05:51:44 EDT
created http://jira.codehaus.org/browse/SUREFIRE-761
Comment 16 Jan Sievers CLA 2011-09-26 17:15:11 EDT
waiting for surefire 2.10 which will include my fix for

http://jira.codehaus.org/browse/SUREFIRE-761
Comment 17 Stanislav Ochotnicky CLA 2011-09-27 08:51:40 EDT
*** Bug 359044 has been marked as a duplicate of this bug. ***
Comment 18 Jan Sievers CLA 2011-10-13 07:07:07 EDT
(In reply to comment #16)
surefire 2.10 released

http://maven.40175.n5.nabble.com/Maven-Surefire-2-10-Released-td4858384.html
Comment 19 Jan Sievers CLA 2011-10-14 10:18:31 EDT
fixed with commit 
http://git.eclipse.org/c/tycho/org.eclipse.tycho.git/commit/?id=a4248738bbbb53f30f1a213b2829c5344c0988fb

I will open CQs for surefire 2.10 artifacts
Comment 20 Jan Sievers CLA 2011-10-14 10:48:47 EDT
(In reply to comment #19)
CQs 5739, 5741, 5743, 5740, 5742

opened for surefire 2.10
Comment 21 Tobias Oberlies CLA 2012-01-03 11:52:34 EST
(In reply to comment #20)
> CQs 5739, 5741, 5743, 5740, 5742
> 
> opened for surefire 2.10
All CQs have been approved.