Skip to content

Commit 0d89b36

Browse files
committed
[FIXUP] Implement sub-module execution based on -pl option
1 parent 92ae2c8 commit 0d89b36

File tree

5 files changed

+136
-158
lines changed

5 files changed

+136
-158
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 root, String test) throws IOException {
24-
return new File("target/test-classes", root).getAbsoluteFile();
23+
protected File getBasedir(String test) throws IOException {
24+
return new File("target/test-classes", test).getAbsoluteFile();
2525
}
2626

2727
}

tycho-its/projects/TYCHO253extraClassPathEntries/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<packaging>pom</packaging>
1010

1111
<modules>
12+
<module>org.eclipse.tycho.testExtraClasspathTest1</module>
1213
<module>org.eclipse.tycho.testExtraClasspathTest2</module>
1314
<module>org.eclipse.tycho.testExtraClasspathTest3</module>
1415
</modules>

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,32 @@
1212
*******************************************************************************/
1313
package org.eclipse.tycho.test.TYCHO253extraClassPathEntries;
1414

15-
import java.util.Arrays;
16-
import java.util.List;
17-
1815
import org.apache.maven.it.Verifier;
1916
import org.eclipse.tycho.test.AbstractTychoIntegrationTest;
2017
import org.junit.Test;
2118

2219
public class ExtraClassPathEntriesTest extends AbstractTychoIntegrationTest {
2320

24-
@Test
25-
public void testJarsExtraClasspath() throws Exception {
26-
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries", "org.eclipse.tycho.testExtraClasspathTest1");
27-
verifier.executeGoals(List.of("install"));
28-
verifier.verifyErrorFreeLog();
29-
}
21+
@Test
22+
public void testJarsExtraClasspath() throws Exception {
23+
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries");
24+
executeOnlyProject(verifier, "org.eclipse.tycho.testExtraClasspathTest1");
25+
verifier.executeGoal("verify");
26+
verifier.verifyErrorFreeLog();
27+
}
3028

31-
@Test
32-
public void testExtraClasspath() throws Exception {
33-
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries", "org.eclipse.tycho.testExtraClasspathTest2");
34-
verifier.executeGoals(List.of("install"));
35-
verifier.verifyErrorFreeLog();
36-
}
29+
@Test
30+
public void testExtraClasspath() throws Exception {
31+
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries");
32+
executeOnlyProject(verifier, "org.eclipse.tycho.testExtraClasspathTest2");
33+
verifier.executeGoal("verify");
34+
verifier.verifyErrorFreeLog();
35+
}
3736

38-
@Test
39-
public void testReferenceToInnerJar() throws Exception {
40-
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries");
41-
verifier.executeGoals(Arrays.asList("install"));
42-
verifier.verifyErrorFreeLog();
43-
}
37+
@Test
38+
public void testReferenceToInnerJar() throws Exception {
39+
Verifier verifier = getVerifier("/TYCHO253extraClassPathEntries");
40+
verifier.executeGoal("verify");
41+
verifier.verifyErrorFreeLog();
42+
}
4443
}

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

Lines changed: 101 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -31,113 +31,105 @@
3131
* @author Edoardo Luppi
3232
*/
3333
public class P2RepositoryFtpHandlerTest extends AbstractTychoIntegrationTest {
34-
private static final String TEST_BASEDIR = "/p2Repository.ftp";
35-
36-
private File repoDir;
37-
private String repositoryUrl;
38-
private FakeFtpServer ftpServer;
39-
40-
@Before
41-
public void setup() throws Exception {
42-
repoDir = new File(getBasedir(TEST_BASEDIR, null), "repository");
43-
startFtpServer();
44-
}
45-
46-
@Test
47-
public void testFtpRepository() throws Exception {
48-
final Verifier verifier = getVerifier(TEST_BASEDIR, false);
49-
verifier.getSystemProperties().setProperty("p2.ftp.repository", repositoryUrl);
50-
verifier.executeGoal("package");
51-
verifier.verifyErrorFreeLog();
52-
}
53-
54-
@After
55-
public void tearDown() {
56-
ftpServer.stop();
57-
}
58-
59-
private void startFtpServer() throws IOException {
60-
ftpServer = new FakeFtpServer();
61-
ftpServer.setFileSystem(getFileSystem());
62-
63-
final UserAccount userAccount = new UserAccount("anonymous", "", "/");
64-
userAccount.setPasswordRequiredForLogin(false);
65-
66-
ftpServer.addUserAccount(userAccount);
67-
68-
ftpServer.setCommandHandler("FEAT", new StaticReplyCommandHandler(STAT_SYSTEM_OK, getFeatResponse()));
69-
ftpServer.setCommandHandler("MDTM", new MdtmCommandHandler());
70-
ftpServer.setCommandHandler("SIZE", new SizeCommandHandler());
71-
72-
ftpServer.setServerControlPort(0);
73-
ftpServer.start();
74-
75-
// Address example: ftp://localhost:21/
76-
repositoryUrl = "ftp://localhost:" + ftpServer.getServerControlPort() + "/";
77-
}
78-
79-
private FileSystem getFileSystem() throws IOException {
80-
final FileSystem fileSystem = new UnixFakeFileSystem();
81-
fileSystem.add(new DirectoryEntry("/"));
82-
fileSystem.add(getFileEntry("/content.xml", new File(repoDir, "content.xml")));
83-
fileSystem.add(getFileEntry("/artifacts.xml", new File(repoDir, "artifacts.xml")));
84-
fileSystem.add(new DirectoryEntry("/plugins"));
85-
fileSystem.add(getFileEntry(
86-
"/plugins/tycho.ftp.bundle_1.0.0.202303021030.jar",
87-
new File(repoDir, "plugins/tycho.ftp.bundle_1.0.0.202303021030.jar")
88-
));
89-
90-
return fileSystem;
91-
}
92-
93-
private FileEntry getFileEntry(final String path, final File file) throws IOException {
94-
final FileEntry entry = new FileEntry(path);
95-
entry.setContents(FileUtils.readFileToByteArray(file));
96-
return entry;
97-
}
98-
99-
private String getFeatResponse() {
100-
return "Extensions supported:\r\n" +
101-
" MDTM\r\n" +
102-
" RETR\r\n" +
103-
" SIZE\r\n" +
104-
" UTF8\r\n" +
105-
" EPSV\r\n" +
106-
" EPRT\r\n" +
107-
"END";
108-
}
109-
110-
private static class MdtmCommandHandler extends AbstractFakeCommandHandler {
111-
@Override
112-
protected void handle(final Command command, final Session session) {
113-
verifyLoggedIn(session);
114-
115-
final String path = getRealPath(session, command.getRequiredParameter(0));
116-
final FileSystemEntry entry = getFileSystem().getEntry(path);
117-
118-
verifyFileSystemCondition(entry != null, path, "filesystem.doesNotExist");
119-
verifyFileSystemCondition(!Objects.requireNonNull(entry).isDirectory(), path, "filesystem.isNotAFile");
120-
121-
final FileEntry fileEntry = (FileEntry) entry;
122-
final DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
123-
final String lastModified = format.format(fileEntry.getLastModified());
124-
session.sendReply(STAT_FILE_OK, lastModified);
125-
}
126-
}
127-
128-
private static class SizeCommandHandler extends AbstractFakeCommandHandler {
129-
@Override
130-
protected void handle(final Command command, final Session session) {
131-
verifyLoggedIn(session);
132-
133-
final String path = getRealPath(session, command.getRequiredParameter(0));
134-
final FileSystemEntry entry = getFileSystem().getEntry(path);
135-
136-
verifyFileSystemCondition(entry != null, path, "filesystem.doesNotExist");
137-
verifyFileSystemCondition(!Objects.requireNonNull(entry).isDirectory(), path, "filesystem.isNotAFile");
138-
139-
final FileEntry fileEntry = (FileEntry) entry;
140-
session.sendReply(STAT_FILE_OK, String.valueOf(fileEntry.getSize()));
141-
}
142-
}
34+
private static final String TEST_BASEDIR = "/p2Repository.ftp";
35+
36+
private File repoDir;
37+
private String repositoryUrl;
38+
private FakeFtpServer ftpServer;
39+
40+
@Before
41+
public void setup() throws Exception {
42+
repoDir = new File(getBasedir(TEST_BASEDIR), "repository");
43+
startFtpServer();
44+
}
45+
46+
@Test
47+
public void testFtpRepository() throws Exception {
48+
final Verifier verifier = getVerifier(TEST_BASEDIR, false);
49+
verifier.getSystemProperties().setProperty("p2.ftp.repository", repositoryUrl);
50+
verifier.executeGoal("package");
51+
verifier.verifyErrorFreeLog();
52+
}
53+
54+
@After
55+
public void tearDown() {
56+
ftpServer.stop();
57+
}
58+
59+
private void startFtpServer() throws IOException {
60+
ftpServer = new FakeFtpServer();
61+
ftpServer.setFileSystem(getFileSystem());
62+
63+
final UserAccount userAccount = new UserAccount("anonymous", "", "/");
64+
userAccount.setPasswordRequiredForLogin(false);
65+
66+
ftpServer.addUserAccount(userAccount);
67+
68+
ftpServer.setCommandHandler("FEAT", new StaticReplyCommandHandler(STAT_SYSTEM_OK, getFeatResponse()));
69+
ftpServer.setCommandHandler("MDTM", new MdtmCommandHandler());
70+
ftpServer.setCommandHandler("SIZE", new SizeCommandHandler());
71+
72+
ftpServer.setServerControlPort(0);
73+
ftpServer.start();
74+
75+
// Address example: ftp://localhost:21/
76+
repositoryUrl = "ftp://localhost:" + ftpServer.getServerControlPort() + "/";
77+
}
78+
79+
private FileSystem getFileSystem() throws IOException {
80+
final FileSystem fileSystem = new UnixFakeFileSystem();
81+
fileSystem.add(new DirectoryEntry("/"));
82+
fileSystem.add(getFileEntry("/content.xml", new File(repoDir, "content.xml")));
83+
fileSystem.add(getFileEntry("/artifacts.xml", new File(repoDir, "artifacts.xml")));
84+
fileSystem.add(new DirectoryEntry("/plugins"));
85+
fileSystem.add(getFileEntry("/plugins/tycho.ftp.bundle_1.0.0.202303021030.jar",
86+
new File(repoDir, "plugins/tycho.ftp.bundle_1.0.0.202303021030.jar")));
87+
88+
return fileSystem;
89+
}
90+
91+
private FileEntry getFileEntry(final String path, final File file) throws IOException {
92+
final FileEntry entry = new FileEntry(path);
93+
entry.setContents(FileUtils.readFileToByteArray(file));
94+
return entry;
95+
}
96+
97+
private String getFeatResponse() {
98+
return "Extensions supported:\r\n" + " MDTM\r\n" + " RETR\r\n" + " SIZE\r\n" + " UTF8\r\n" + " EPSV\r\n"
99+
+ " EPRT\r\n" + "END";
100+
}
101+
102+
private static class MdtmCommandHandler extends AbstractFakeCommandHandler {
103+
@Override
104+
protected void handle(final Command command, final Session session) {
105+
verifyLoggedIn(session);
106+
107+
final String path = getRealPath(session, command.getRequiredParameter(0));
108+
final FileSystemEntry entry = getFileSystem().getEntry(path);
109+
110+
verifyFileSystemCondition(entry != null, path, "filesystem.doesNotExist");
111+
verifyFileSystemCondition(!Objects.requireNonNull(entry).isDirectory(), path, "filesystem.isNotAFile");
112+
113+
final FileEntry fileEntry = (FileEntry) entry;
114+
final DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
115+
final String lastModified = format.format(fileEntry.getLastModified());
116+
session.sendReply(STAT_FILE_OK, lastModified);
117+
}
118+
}
119+
120+
private static class SizeCommandHandler extends AbstractFakeCommandHandler {
121+
@Override
122+
protected void handle(final Command command, final Session session) {
123+
verifyLoggedIn(session);
124+
125+
final String path = getRealPath(session, command.getRequiredParameter(0));
126+
final FileSystemEntry entry = getFileSystem().getEntry(path);
127+
128+
verifyFileSystemCondition(entry != null, path, "filesystem.doesNotExist");
129+
verifyFileSystemCondition(!Objects.requireNonNull(entry).isDirectory(), path, "filesystem.isNotAFile");
130+
131+
final FileEntry fileEntry = (FileEntry) entry;
132+
session.sendReply(STAT_FILE_OK, String.valueOf(fileEntry.getSize()));
133+
}
134+
}
143135
}

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

Lines changed: 12 additions & 26 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 root, String test) throws IOException {
42-
File src = new File("projects", root).getAbsoluteFile();
41+
protected File getBasedir(String test) throws IOException {
42+
File src = new File("projects", test).getAbsoluteFile();
4343
File dst = new File("target/projects",
44-
getClass().getSimpleName() + "/" + name.getMethodName() + "/" + root.replace("../", "./"))
44+
getClass().getSimpleName() + "/" + name.getMethodName() + "/" + test.replace("../", "./"))
4545
.getAbsoluteFile();
4646

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

5555
FileUtils.copyDirectoryStructure(src, dst);
5656

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

6060
protected Verifier getVerifier(String test, boolean setTargetPlatform) throws Exception {
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());
61+
return getVerifier(test, setTargetPlatform, getSettings());
6662
}
6763

6864
protected Verifier getVerifier(String test, boolean setTargetPlatform, boolean ignoreLocalArtifacts)
6965
throws Exception {
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);
66+
return getVerifier(test, setTargetPlatform, getSettings(), ignoreLocalArtifacts);
7667
}
7768

7869
protected Verifier getVerifier(String test, boolean setTargetPlatform, File userSettings) throws Exception {
79-
return getVerifier(test, null, setTargetPlatform, userSettings);
80-
}
81-
82-
protected Verifier getVerifier(String root, String test, boolean setTargetPlatform, File userSettings)
83-
throws Exception {
84-
return getVerifier(root, test, setTargetPlatform, userSettings, true);
70+
return getVerifier(test, setTargetPlatform, userSettings, true);
8571
}
8672

87-
protected Verifier getVerifier(String root, String test, boolean setTargetPlatform, File userSettings,
73+
protected Verifier getVerifier(String test, boolean setTargetPlatform, File userSettings,
8874
boolean ignoreLocalArtifacts) throws Exception {
8975
//Test JVM can be started in debug mode by passing the following property to the maven run:
9076
//-Dtycho.mvnDebug -> will start with port 8000
@@ -94,7 +80,7 @@ protected Verifier getVerifier(String root, String test, boolean setTargetPlatfo
9480
// oddly enough, Verifier uses this system property to locate maven install
9581
System.setProperty("maven.home", getMavenHome());
9682

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

9985
Verifier verifier = new Verifier(testDir.getAbsolutePath());
10086
verifier.setForkJvm(isForked());
@@ -162,11 +148,11 @@ protected boolean isForked() {
162148
}
163149

164150
protected Verifier getVerifier(String test) throws Exception {
165-
return getVerifier(test, null);
151+
return getVerifier(test, true);
166152
}
167153

168-
protected Verifier getVerifier(String root, String test) throws Exception {
169-
return getVerifier(root, test, true);
154+
protected static void executeOnlyProject(Verifier verifier, String projectFolder) {
155+
verifier.addCliOption("-pl " + projectFolder);
170156
}
171157

172158
protected String getTargetPlatform() {

0 commit comments

Comments
 (0)