Skip to content

Commit 92ae2c8

Browse files
committed
Clean-up integration tests and improve re-use of pomless projects
If tycho-pomless is used in (integration) test-resources/projects the entire project structure, especially including the '.mvn' folder has to be copied into the clean test-environment, even if just a sub-project is executed. This extends AbstractTychoIntegrationTest.getVerifier() to add overloads that allow to specify the project-structure root and the specific sub-folder that is eventually executed.
1 parent e8902b8 commit 92ae2c8

File tree

12 files changed

+90
-171
lines changed

12 files changed

+90
-171
lines changed

tycho-extras/tycho-extras-its/src/test/java/org/eclipse/tycho/extras/its/AbstractTychoExtrasIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
public class AbstractTychoExtrasIntegrationTest extends AbstractTychoIntegrationTest {
2121

2222
@Override
23-
protected File getBasedir(String test) throws IOException {
24-
return new File("target/test-classes", test).getAbsoluteFile();
23+
protected File getBasedir(String root, String test) throws IOException {
24+
return new File("target/test-classes", root).getAbsoluteFile();
2525
}
2626

2727
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*/lib/*.jar
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<extensions>
3+
<extension>
4+
<groupId>org.eclipse.tycho</groupId>
5+
<artifactId>tycho-build</artifactId>
6+
<version>${tycho-version}</version>
7+
</extension>
8+
</extensions>

tycho-its/projects/TYCHO253extraClassPathEntries/org.eclipse.tycho.testExtraClasspathTest1/pom.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

tycho-its/projects/TYCHO253extraClassPathEntries/org.eclipse.tycho.testExtraClasspathTest2/pom.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

tycho-its/projects/TYCHO253extraClassPathEntries/org.eclipse.tycho.testExtraClasspathTest3/pom.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

tycho-its/projects/TYCHO253extraClassPathEntries/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,33 @@
1212
<module>org.eclipse.tycho.testExtraClasspathTest2</module>
1313
<module>org.eclipse.tycho.testExtraClasspathTest3</module>
1414
</modules>
15+
16+
<properties>
17+
<target-platform>http://download.eclipse.org/releases/latest</target-platform>
18+
<tycho.localArtifacts>ignore</tycho.localArtifacts>
19+
</properties>
20+
21+
<repositories>
22+
<repository>
23+
<id>p2</id>
24+
<layout>p2</layout>
25+
<url>${target-platform}</url>
26+
</repository>
27+
</repositories>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.eclipse.tycho</groupId>
33+
<artifactId>tycho-maven-plugin</artifactId>
34+
<version>${tycho-version}</version>
35+
<extensions>true</extensions>
36+
</plugin>
37+
<plugin>
38+
<groupId>org.eclipse.tycho</groupId>
39+
<artifactId>target-platform-configuration</artifactId>
40+
<version>${tycho-version}</version>
41+
</plugin>
42+
</plugins>
43+
</build>
1544
</project>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
-Dtycho-version=5.0.0-SNAPSHOT
2-
-Dtycho.localArtifacts=ignore

tycho-its/projects/tycho-ds-dependency/.mvn/maven.config

Lines changed: 0 additions & 1 deletion
This file was deleted.

tycho-its/src/test/java/org/eclipse/tycho/test/TYCHO253extraClassPathEntries/ExtraClassPathEntriesTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,32 @@
1313
package org.eclipse.tycho.test.TYCHO253extraClassPathEntries;
1414

1515
import java.util.Arrays;
16+
import java.util.List;
1617

1718
import org.apache.maven.it.Verifier;
1819
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
1920
import org.junit.Test;
2021

2122
public class ExtraClassPathEntriesTest extends AbstractTychoIntegrationTest {
23+
2224
@Test
2325
public void testJarsExtraClasspath() throws Exception {
24-
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries/org.eclipse.tycho.testExtraClasspathTest1");
25-
verifier.executeGoals(Arrays.asList("clean", "install"));
26+
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries", "org.eclipse.tycho.testExtraClasspathTest1");
27+
verifier.executeGoals(List.of("install"));
2628
verifier.verifyErrorFreeLog();
2729
}
2830

2931
@Test
3032
public void testExtraClasspath() throws Exception {
31-
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries/org.eclipse.tycho.testExtraClasspathTest2");
32-
verifier.executeGoals(Arrays.asList("clean", "install"));
33+
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries", "org.eclipse.tycho.testExtraClasspathTest2");
34+
verifier.executeGoals(List.of("install"));
3335
verifier.verifyErrorFreeLog();
3436
}
3537

3638
@Test
3739
public void testReferenceToInnerJar() throws Exception {
3840
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries");
39-
verifier.executeGoals(Arrays.asList("clean", "install"));
41+
verifier.executeGoals(Arrays.asList("install"));
4042
verifier.verifyErrorFreeLog();
4143
}
4244
}

tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryFtpHandlerTest.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package org.eclipse.tycho.test.p2Repository;
22

3+
import static org.mockftpserver.core.command.ReplyCodes.STAT_FILE_OK;
4+
import static org.mockftpserver.core.command.ReplyCodes.STAT_SYSTEM_OK;
5+
6+
import java.io.File;
7+
import java.io.IOException;
8+
import java.text.DateFormat;
9+
import java.text.SimpleDateFormat;
10+
import java.util.Objects;
11+
312
import org.apache.commons.io.FileUtils;
413
import org.apache.maven.it.Verifier;
514
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
@@ -12,16 +21,11 @@
1221
import org.mockftpserver.fake.FakeFtpServer;
1322
import org.mockftpserver.fake.UserAccount;
1423
import org.mockftpserver.fake.command.AbstractFakeCommandHandler;
15-
import org.mockftpserver.fake.filesystem.*;
16-
17-
import java.io.File;
18-
import java.io.IOException;
19-
import java.text.DateFormat;
20-
import java.text.SimpleDateFormat;
21-
import java.util.Objects;
22-
23-
import static org.mockftpserver.core.command.ReplyCodes.STAT_FILE_OK;
24-
import static org.mockftpserver.core.command.ReplyCodes.STAT_SYSTEM_OK;
24+
import org.mockftpserver.fake.filesystem.DirectoryEntry;
25+
import org.mockftpserver.fake.filesystem.FileEntry;
26+
import org.mockftpserver.fake.filesystem.FileSystem;
27+
import org.mockftpserver.fake.filesystem.FileSystemEntry;
28+
import org.mockftpserver.fake.filesystem.UnixFakeFileSystem;
2529

2630
/**
2731
* @author Edoardo Luppi
@@ -35,7 +39,7 @@ public class P2RepositoryFtpHandlerTest extends AbstractTychoIntegrationTest {
3539

3640
@Before
3741
public void setup() throws Exception {
38-
repoDir = new File(getBasedir(TEST_BASEDIR), "repository");
42+
repoDir = new File(getBasedir(TEST_BASEDIR, null), "repository");
3943
startFtpServer();
4044
}
4145

tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public abstract class AbstractTychoIntegrationTest {
3838
@Rule
3939
public TestName name = new TestName();
4040

41-
protected File getBasedir(String test) throws IOException {
42-
File src = new File("projects", test).getAbsoluteFile();
41+
protected File getBasedir(String root, String test) throws IOException {
42+
File src = new File("projects", root).getAbsoluteFile();
4343
File dst = new File("target/projects",
44-
getClass().getSimpleName() + "/" + name.getMethodName() + "/" + test.replace("../", "./"))
44+
getClass().getSimpleName() + "/" + name.getMethodName() + "/" + root.replace("../", "./"))
4545
.getAbsoluteFile();
4646

4747
if (dst.isDirectory()) {
@@ -54,23 +54,37 @@ protected File getBasedir(String test) throws IOException {
5454

5555
FileUtils.copyDirectoryStructure(src, dst);
5656

57-
return dst;
57+
return test != null ? new File(dst, test) : dst;
5858
}
5959

6060
protected Verifier getVerifier(String test, boolean setTargetPlatform) throws Exception {
61-
return getVerifier(test, setTargetPlatform, getSettings());
61+
return getVerifier(test, null, setTargetPlatform);
62+
}
63+
64+
protected Verifier getVerifier(String root, String test, boolean setTargetPlatform) throws Exception {
65+
return getVerifier(root, test, setTargetPlatform, getSettings());
6266
}
6367

6468
protected Verifier getVerifier(String test, boolean setTargetPlatform, boolean ignoreLocalArtifacts)
6569
throws Exception {
66-
return getVerifier(test, setTargetPlatform, getSettings(), ignoreLocalArtifacts);
70+
return getVerifier(test, null, setTargetPlatform, ignoreLocalArtifacts);
71+
}
72+
73+
protected Verifier getVerifier(String root, String test, boolean setTargetPlatform, boolean ignoreLocalArtifacts)
74+
throws Exception {
75+
return getVerifier(root, test, setTargetPlatform, getSettings(), ignoreLocalArtifacts);
6776
}
6877

6978
protected Verifier getVerifier(String test, boolean setTargetPlatform, File userSettings) throws Exception {
70-
return getVerifier(test, setTargetPlatform, userSettings, true);
79+
return getVerifier(test, null, setTargetPlatform, userSettings);
7180
}
7281

73-
protected Verifier getVerifier(String test, boolean setTargetPlatform, File userSettings,
82+
protected Verifier getVerifier(String root, String test, boolean setTargetPlatform, File userSettings)
83+
throws Exception {
84+
return getVerifier(root, test, setTargetPlatform, userSettings, true);
85+
}
86+
87+
protected Verifier getVerifier(String root, String test, boolean setTargetPlatform, File userSettings,
7488
boolean ignoreLocalArtifacts) throws Exception {
7589
//Test JVM can be started in debug mode by passing the following property to the maven run:
7690
//-Dtycho.mvnDebug -> will start with port 8000
@@ -80,7 +94,7 @@ protected Verifier getVerifier(String test, boolean setTargetPlatform, File user
8094
// oddly enough, Verifier uses this system property to locate maven install
8195
System.setProperty("maven.home", getMavenHome());
8296

83-
File testDir = getBasedir(test);
97+
File testDir = getBasedir(root, test);
8498

8599
Verifier verifier = new Verifier(testDir.getAbsolutePath());
86100
verifier.setForkJvm(isForked());
@@ -148,7 +162,11 @@ protected boolean isForked() {
148162
}
149163

150164
protected Verifier getVerifier(String test) throws Exception {
151-
return getVerifier(test, true);
165+
return getVerifier(test, null);
166+
}
167+
168+
protected Verifier getVerifier(String root, String test) throws Exception {
169+
return getVerifier(root, test, true);
152170
}
153171

154172
protected String getTargetPlatform() {

0 commit comments

Comments
 (0)