forked from loafle/openapi-generator-original
[codegen ignore] normalize path separator for Windows, add *.ext tests (#4476)
* [codegen ignore] Fix windows paths for ignore processing * [codegen ignore] Add missing glob rule tests
This commit is contained in:
@@ -107,6 +107,8 @@ public class CodegenIgnoreProcessorTest {
|
||||
return new Object[] {
|
||||
// Matching filenames
|
||||
new CodegenIgnoreProcessorTest("build.sh", "build.sh", "A file when matching should ignore.").ignored(),
|
||||
new CodegenIgnoreProcessorTest("build.sh", "*.sh", "A file when matching glob should ignore.").ignored(),
|
||||
new CodegenIgnoreProcessorTest("src/build.sh", "*.sh", "A nested file when matching non-nested simple glob should allow.").allowed(),
|
||||
new CodegenIgnoreProcessorTest("src/build.sh", "**/build.sh", "A file when matching nested files should ignore.").ignored(),
|
||||
new CodegenIgnoreProcessorTest("Build.sh", "build.sh", "A file when non-matching should allow.").allowed().skipOnCondition(SystemUtils.IS_OS_WINDOWS),
|
||||
new CodegenIgnoreProcessorTest("build.sh", "/build.sh", "A rooted file when matching should ignore.").ignored(),
|
||||
|
||||
@@ -67,4 +67,43 @@ public class FileRuleTest {
|
||||
assertFalse(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobbingRecursive() throws Exception {
|
||||
// Arrange
|
||||
final String definition = "*.txt";
|
||||
final String relativePath = "path/to/some/nested/location/xyzzy.txt";
|
||||
|
||||
// Act
|
||||
final List<Part> syntax = Arrays.asList(
|
||||
new Part(IgnoreLineParser.Token.MATCH_ALL),
|
||||
new Part(IgnoreLineParser.Token.DIRECTORY_MARKER),
|
||||
new Part(IgnoreLineParser.Token.MATCH_ANY),
|
||||
new Part(IgnoreLineParser.Token.TEXT, ".txt")
|
||||
);
|
||||
|
||||
Rule rule = new FileRule(syntax, definition);
|
||||
Boolean actual = rule.matches(relativePath);
|
||||
|
||||
// Assert
|
||||
assertTrue(actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobbingNotRecursive() throws Exception {
|
||||
// Arrange
|
||||
final String definition = "*.txt";
|
||||
final String relativePath = "path/to/some/nested/location/xyzzy.txt";
|
||||
|
||||
// Act
|
||||
final List<Part> syntax = Arrays.asList(
|
||||
new Part(IgnoreLineParser.Token.MATCH_ANY),
|
||||
new Part(IgnoreLineParser.Token.TEXT, ".txt")
|
||||
);
|
||||
|
||||
Rule rule = new FileRule(syntax, definition);
|
||||
Boolean actual = rule.matches(relativePath);
|
||||
|
||||
// Assert
|
||||
assertFalse(actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user