Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Follow symlinks when loading feature files #2043

Merged
merged 1 commit into from
Jul 7, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
Expand Down Expand Up @@ -43,7 +45,8 @@ void findResourcesForPath(Path path, Predicate<Path> filter, Function<Path, Cons
}

try {
walkFileTree(path, new ResourceFileVisitor(filter, consumer.apply(path)));
walkFileTree(path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
new ResourceFileVisitor(filter, consumer.apply(path)));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ void scanForResourcesPath() {
assertThat(resources, contains(file.toURI()));
}

@Test
void scanForResourcesPathSymlink() {
File file = new File("src/test/resource-symlink/test/resource.txt");
List<URI> resources = resourceScanner.scanForResourcesPath(file.toPath());
assertThat(resources, contains(file.toURI()));
}

@Test
void scanForResourcesDirectory() {
File file = new File("src/test/resources/io/cucumber/core/resource");
Expand All @@ -112,6 +119,16 @@ void scanForResourcesDirectory() {
new File("src/test/resources/io/cucumber/core/resource/test/spaces in name resource.txt").toURI()));
}

@Test
void scanForResourcesDirectorySymlink() {
File file = new File("src/test/resource-symlink");
List<URI> resources = resourceScanner.scanForResourcesPath(file.toPath());
assertThat(resources, containsInAnyOrder(
new File("src/test/resource-symlink/test/resource.txt").toURI(),
new File("src/test/resource-symlink/test/other-resource.txt").toURI(),
new File("src/test/resource-symlink/test/spaces in name resource.txt").toURI()));
}

@Test
void scanForResourcesFileUri() {
File file = new File("src/test/resources/io/cucumber/core/resource/test/resource.txt");
Expand Down
1 change: 1 addition & 0 deletions core/src/test/resource-symlink