Skip to content

Commit d537dd4

Browse files
committed
Fix for issue 654 ... adding unit test
1 parent 0019984 commit d537dd4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PaddedCellTaskTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public void paddedCellApplyCheck() throws Exception {
157157
assertFile(converge.file).hasContent(""); // converge -> converges
158158
assertFile(diverge.file).hasContent("CCC"); // diverge -> no change
159159

160+
assertFileAttributesEqual(wellbehaved.file, wellbehaved.outputFile);
161+
160162
// After apply, check should pass
161163
wellbehaved.check();
162164
cycle.check();

testlib/src/main/java/com/diffplug/spotless/ResourceHarness.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 DiffPlug
2+
* Copyright 2016-2020 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@
2222
import java.nio.charset.StandardCharsets;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25+
import java.nio.file.attribute.AclEntry;
26+
import java.nio.file.attribute.AclFileAttributeView;
2527
import java.util.ArrayList;
2628
import java.util.Arrays;
2729
import java.util.List;
@@ -166,6 +168,13 @@ protected void assertOnResources(FormatterFunc step, String unformattedPath, Str
166168
Assert.assertEquals(expected, formatted);
167169
}
168170

171+
/** Reads file attributes from the output file and compares it to the attributes from the input file. */
172+
protected void assertFileAttributesEqual(File input, File output) throws IOException {
173+
List<AclEntry> inputAttributes = Files.getFileAttributeView(input.toPath(), AclFileAttributeView.class).getAcl();
174+
List<AclEntry> outputAttributes = Files.getFileAttributeView(output.toPath(), AclFileAttributeView.class).getAcl();
175+
Assertions.assertThat(outputAttributes).isEqualTo(inputAttributes);
176+
}
177+
169178
@CheckReturnValue
170179
protected ReadAsserter assertFile(String path) throws IOException {
171180
return new ReadAsserter(newFile(path));

0 commit comments

Comments
 (0)