Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- Write type annotations in all functions and most variables.
- Document code without being too verbose.
- In Java and Groovy, always import classes and use them without qualified names.
- In Java use multi-line strings where possible.
- In Java use the markdown style for comments.

## Testing individual components

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,38 @@ public Path getTestDir(String coordinates) {
Objects.requireNonNull(artifactId, "Artifact ID must be specified");
Objects.requireNonNull(version, "Version must be specified");

// First, let's try if we can find test directory from the new `tests/src/index.json` file.
List<Map<String, ?>> index = (List<Map<String, ?>>) readIndexFile(testRoot());
for (Map<String, ?> entry : index) {
boolean found = ((List<Map<String, ?>>) entry.get("libraries")).stream().anyMatch(
lib -> coordinatesMatch((String) lib.get("name"), groupId, artifactId) &&
((List<String>) lib.get("versions")).contains(version)
);
if (found) {
return testRoot().resolve((String) entry.get("test-project-path"));
// First, try to locate the test project via the aggregated tests/src/index.json (new layout).
try {
List<Map<String, ?>> index = (List<Map<String, ?>>) readIndexFile(testRoot());
for (Map<String, ?> entry : index) {
boolean found = ((List<Map<String, ?>>) entry.get("libraries")).stream().anyMatch(
lib -> coordinatesMatch((String) lib.get("name"), groupId, artifactId) &&
((List<String>) lib.get("versions")).contains(version)
);
if (found) {
return testRoot().resolve((String) entry.get("test-project-path"));
}
}
} catch (Exception ignored) {
// Fall through to conventional layout resolution below.
}
// Fallback: conventional layout tests/src/<group>/<artifact>/<version>
Path conventional = testRoot().resolve(groupId).resolve(artifactId).resolve(version);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So previously we only matched using tests/src/index.json, and failed otherwise? These fallbacks will be useful once we get rid of that index.json.

if (Files.isDirectory(conventional)) {
return conventional;
}
// Secondary fallback: derive test dir from metadata "metadata-version"
try {
Path mdDir = getMetadataDir(coordinates); // .../metadata/<group>/<artifact>/<metadata-version>
Path mdVersion = mdDir.getFileName();
if (mdVersion != null) {
Path testsForMetadataVersion = testRoot().resolve(groupId).resolve(artifactId).resolve(mdVersion.toString());
if (Files.isDirectory(testsForMetadataVersion)) {
return testsForMetadataVersion;
}
}
} catch (Exception ignored) {
// ignore and fall through to error
}
throw new RuntimeException("Missing test-directory for coordinates `" + coordinates + "`");
}
Expand Down

This file was deleted.

Loading
Loading