elharo commented on code in PR #297:
URL: https://github.com/apache/maven-enforcer/pull/297#discussion_r1908631102
##########
enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/files/RequireFilesExist.java:
##########
@@ -31,35 +30,11 @@ public final class RequireFilesExist extends
AbstractRequireFiles {
@Override
boolean checkFile(File file) {
// if we get here and the handle is null, treat it as a success
- return file == null ? true : file.exists() &&
osIndependentNameMatch(file, true);
+ return file == null ? true : file.exists();
Review Comment:
IMHO
return file == null || file.exists()
is clearer, but up to you
##########
enforcer-rules/src/site/apt/requireFilesExist.apt.vm:
##########
@@ -26,7 +26,10 @@
Require Files Exist
This rule checks that the specified list of files exist.
-
+
+ The mounted filesystem(s) will dictate the case-sensitive rules when
checking files. If you require checks that your
Review Comment:
case-sensitivity
##########
enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/files/TestRequireFilesDontExist.java:
##########
@@ -107,15 +106,58 @@ void testEmptyFileListAllowNull() {
@Test
void testFileDoesNotExist() throws EnforcerRuleException, IOException {
File f = File.createTempFile("junit", null, temporaryFolder);
+ rule.setFilesList(Collections.singletonList(f));
+
+ EnforcerRuleException e = assertThrows(EnforcerRuleException.class,
rule::execute);
+ assertNotNull(e.getMessage());
+
f.delete();
assertFalse(f.exists());
- rule.setFilesList(Collections.singletonList(f));
-
rule.execute();
}
+ @Test
+ void testSymbolicLinkDoesNotExist() throws Exception {
+ File canonicalFile = File.createTempFile("canonical_", null,
temporaryFolder);
+ File linkFile = Files.createSymbolicLink(
+ Paths.get(temporaryFolder.getAbsolutePath(),
"symbolic.link"),
+ Paths.get(canonicalFile.getAbsolutePath()))
+ .toFile();
+
+ try {
+ rule.setFilesList(Collections.singletonList(linkFile));
+ EnforcerRuleException e =
assertThrows(EnforcerRuleException.class, rule::execute);
+ assertNotNull(e.getMessage());
+
+ linkFile.delete();
+ rule.execute();
+ } finally {
Review Comment:
I think the temporary folder rule should take care of that
##########
enforcer-rules/src/site/apt/requireFilesSize.apt.vm:
##########
@@ -26,7 +26,10 @@
Require File Size
This rule checks that the specified list of files exist and are within the
specified size range.
-
+
+ The mounted filesystem(s) will dictate the case-sensitive rules when
checking files. If you require checks that your
Review Comment:
case-sensitivity
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]