Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jerboaa committed Dec 11, 2024
1 parent d6bbc2a commit c15438c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
22 changes: 10 additions & 12 deletions test/jdk/tools/jlink/bindservices/BindServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,20 @@ public class BindServices {
private static String[] modules = new String[] {"m1", "m2", "m3"};


private static boolean isApplicable() {
if (!JMODS_EXIST) {
if (!LINKABLE_RUNTIME) {
System.err.println("Test skipped. Not a linkable runtime and no JMODs");
return false;
}
private static boolean isExplodedJDKImage() {
if (!JMODS_EXIST && !LINKABLE_RUNTIME) {
System.err.println("Test skipped. Not a linkable runtime and no JMODs");
return true;
}
return true;
return false;
}

/*
* Compiles all modules used by the test
*/
@BeforeTest
public void compileAll() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

for (String mn : modules) {
Path msrc = SRC_DIR.resolve(mn);
Expand All @@ -95,7 +93,7 @@ public void compileAll() throws Throwable {

@Test
public void noServiceBinding() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

Path dir = Paths.get("noServiceBinding");

Expand All @@ -109,7 +107,7 @@ public void noServiceBinding() throws Throwable {

@Test
public void fullServiceBinding() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

Path dir = Paths.get("fullServiceBinding");

Expand All @@ -128,7 +126,7 @@ public void fullServiceBinding() throws Throwable {

@Test
public void testVerbose() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

Path dir = Paths.get("verbose");

Expand Down Expand Up @@ -159,7 +157,7 @@ public void testVerbose() throws Throwable {

@Test
public void testVerboseAndNoBindServices() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

Path dir = Paths.get("verboseNoBind");

Expand Down
32 changes: 15 additions & 17 deletions test/jdk/tools/jlink/bindservices/SuggestProviders.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,20 @@ public class SuggestProviders {
private static String[] modules = new String[] {"m1", "m2", "m3"};


private static boolean isApplicable() {
if (!JMODS_EXIST) {
if (!LINKABLE_RUNTIME) {
System.err.println("Test skipped. Not a linkable runtime and no JMODs");
return false;
}
private static boolean isExplodedJDKImage() {
if (!JMODS_EXIST && !LINKABLE_RUNTIME) {
System.err.println("Test skipped. Not a linkable runtime and no JMODs");
return true;
}
return true;
return false;
}

/*
* Compiles all modules used by the test
*/
@BeforeTest
public void compileAll() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

for (String mn : modules) {
Path msrc = SRC_DIR.resolve(mn);
Expand Down Expand Up @@ -134,7 +132,7 @@ public void compileAll() throws Throwable {

@Test
public void suggestProviders() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output = JLink.run("--module-path", MODULE_PATH,
"--suggest-providers").output();
Expand All @@ -154,7 +152,7 @@ public void suggestProviders() throws Throwable {
*/
@Test
public void observableModules() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output = JLink.run("--module-path", MODULE_PATH,
"--add-modules", "m1",
Expand All @@ -174,7 +172,7 @@ public void observableModules() throws Throwable {
*/
@Test
public void limitModules() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output = JLink.run("--module-path", MODULE_PATH,
"--limit-modules", "m1",
Expand All @@ -193,7 +191,7 @@ public void limitModules() throws Throwable {

@Test
public void providersForServices() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output =
JLink.run("--module-path", MODULE_PATH,
Expand All @@ -212,7 +210,7 @@ public void providersForServices() throws Throwable {

@Test
public void unusedService() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output =
JLink.run("--module-path", MODULE_PATH,
Expand All @@ -230,7 +228,7 @@ public void unusedService() throws Throwable {

@Test
public void nonExistentService() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output =
JLink.run("--module-path", MODULE_PATH,
Expand All @@ -245,7 +243,7 @@ public void nonExistentService() throws Throwable {

@Test
public void noSuggestProviders() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output =
JLink.run("--module-path", MODULE_PATH,
Expand All @@ -259,7 +257,7 @@ public void noSuggestProviders() throws Throwable {

@Test
public void suggestTypeNotRealProvider() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output =
JLink.run("--module-path", MODULE_PATH,
Expand All @@ -277,7 +275,7 @@ public void suggestTypeNotRealProvider() throws Throwable {

@Test
public void addNonObservableModule() throws Throwable {
if (!isApplicable()) return;
if (isExplodedJDKImage()) return;

List<String> output =
JLink.run("--module-path", MODULE_PATH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ protected Path jlinkUsingImage(JlinkSpec spec, OutputAnalyzerHandler handler, Pr
// if the exit checker failed, we expected the other outcome
// i.e. fail for success and success for fail.
boolean successExit = analyzer.getExitValue() == 0;
String msg = String.format("Expected jlink to %s given a run-time image " +
"link capable image. Exit code was: %d",
String msg = String.format("Expected jlink to %s given a linkable run-time image. " +
"Exit code was: %d",
(successExit ? "fail" : "pass"), analyzer.getExitValue());
throw new AssertionError(msg);
}
Expand Down

0 comments on commit c15438c

Please sign in to comment.