Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Nov 26, 2024
1 parent b8fc2f5 commit e35de2e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ class HierarchicalOutputDirectoryProvider implements OutputDirectoryProvider {
@Override
public Path createOutputDirectory(TestDescriptor testDescriptor) throws IOException {
List<Segment> segments = testDescriptor.getUniqueId().getSegments();
Segment firstSegment = segments.get(0);
Path relativePath = segments.stream() //
.skip(1) //
.map(Segment::getValue) //
.map(HierarchicalOutputDirectoryProvider::sanitizeName).map(Paths::get) //
.reduce(Paths.get(sanitizeName(firstSegment.getValue())), Path::resolve);
.map(HierarchicalOutputDirectoryProvider::toSanitizedPath) //
.reduce(toSanitizedPath(segments.get(0)), Path::resolve);
return Files.createDirectories(getRootDirectory().resolve(relativePath));
}

Expand All @@ -59,6 +57,10 @@ public synchronized Path getRootDirectory() {
return rootDir;
}

private static Path toSanitizedPath(Segment segment) {
return Paths.get(sanitizeName(segment.getValue()));
}

private static String sanitizeName(String value) {
StringBuilder result = new StringBuilder(value.length());
for (int i = 0; i < value.length(); i++) {
Expand Down

0 comments on commit e35de2e

Please sign in to comment.