Skip to content

Commit bd9ecbd

Browse files
committed
tck-build-logic: make test directory resolution robust; fallback to conventional layout and metadata-version; tolerate missing tests index.json in TestInvocationTask
1 parent ed5a775 commit bd9ecbd

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/TckExtension.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,38 @@ public Path getTestDir(String coordinates) {
100100
Objects.requireNonNull(artifactId, "Artifact ID must be specified");
101101
Objects.requireNonNull(version, "Version must be specified");
102102

103-
// First, let's try if we can find test directory from the new `tests/src/index.json` file.
104-
List<Map<String, ?>> index = (List<Map<String, ?>>) readIndexFile(testRoot());
105-
for (Map<String, ?> entry : index) {
106-
boolean found = ((List<Map<String, ?>>) entry.get("libraries")).stream().anyMatch(
107-
lib -> coordinatesMatch((String) lib.get("name"), groupId, artifactId) &&
108-
((List<String>) lib.get("versions")).contains(version)
109-
);
110-
if (found) {
111-
return testRoot().resolve((String) entry.get("test-project-path"));
103+
// First, try to locate the test project via the aggregated tests/src/index.json (new layout).
104+
try {
105+
List<Map<String, ?>> index = (List<Map<String, ?>>) readIndexFile(testRoot());
106+
for (Map<String, ?> entry : index) {
107+
boolean found = ((List<Map<String, ?>>) entry.get("libraries")).stream().anyMatch(
108+
lib -> coordinatesMatch((String) lib.get("name"), groupId, artifactId) &&
109+
((List<String>) lib.get("versions")).contains(version)
110+
);
111+
if (found) {
112+
return testRoot().resolve((String) entry.get("test-project-path"));
113+
}
114+
}
115+
} catch (Exception ignored) {
116+
// Fall through to conventional layout resolution below.
117+
}
118+
// Fallback: conventional layout tests/src/<group>/<artifact>/<version>
119+
Path conventional = testRoot().resolve(groupId).resolve(artifactId).resolve(version);
120+
if (Files.isDirectory(conventional)) {
121+
return conventional;
122+
}
123+
// Secondary fallback: derive test dir from metadata "metadata-version"
124+
try {
125+
Path mdDir = getMetadataDir(coordinates); // .../metadata/<group>/<artifact>/<metadata-version>
126+
Path mdVersion = mdDir.getFileName();
127+
if (mdVersion != null) {
128+
Path testsForMetadataVersion = testRoot().resolve(groupId).resolve(artifactId).resolve(mdVersion.toString());
129+
if (Files.isDirectory(testsForMetadataVersion)) {
130+
return testsForMetadataVersion;
131+
}
112132
}
133+
} catch (Exception ignored) {
134+
// ignore and fall through to error
113135
}
114136
throw new RuntimeException("Missing test-directory for coordinates `" + coordinates + "`");
115137
}

tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/TestInvocationTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public List<String> commandFor(String coordinates) {
5151
return testIndex.get("test-command").stream()
5252
.map(c -> processCommand(c, metadataDir, coordinates))
5353
.collect(Collectors.toList());
54-
} catch (RuntimeException ignored) {
54+
} catch (Exception ignored) {
5555
return defaultArgs;
5656
}
5757
}

tests/tck-build-logic/src/main/java/org/graalvm/internal/tck/MetadataFilesCheckerTask.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract class MetadataFilesCheckerTask extends DefaultTask {
4949
List<String> allowedPackages;
5050

5151
@Option(option = "coordinates", description = "Coordinates in the form of group:artifact:version")
52-
void setCoordinates(String coords) {
52+
public void setCoordinates(String coords) {
5353
extractCoordinates(coords);
5454
}
5555

@@ -79,11 +79,7 @@ private void extractCoordinates(String c) {
7979
}
8080

8181
@TaskAction
82-
void run() throws IllegalArgumentException, FileNotFoundException {
83-
if (coordinates.group().equalsIgnoreCase("org.example") || coordinates.group().equalsIgnoreCase("samples")) {
84-
return;
85-
}
86-
82+
public void run() throws IllegalArgumentException, FileNotFoundException {
8783
File coordinatesMetadataRoot = getMetadataRoot().get().getAsFile();
8884
if (!coordinatesMetadataRoot.exists()) {
8985
throw new IllegalArgumentException("ERROR: Cannot find metadata directory for given coordinates: " + this.coordinates);

0 commit comments

Comments
 (0)