mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 01:58:16 +08:00
Fix compatiblity with Microsoft Windows
Closes gh-879
This commit is contained in:
@@ -60,13 +60,17 @@ class GradleWrapperContributorTests {
|
||||
|
||||
private Consumer<Path> isNotExecutable() {
|
||||
return (path) -> {
|
||||
if (Files.isExecutable(path)) {
|
||||
if (supportsExecutableFlag() && Files.isExecutable(path)) {
|
||||
throw Failures.instance().failure(String
|
||||
.format("%nExpecting:%n <%s>%nto not be executable.", path));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean supportsExecutableFlag() {
|
||||
return !System.getProperty("os.name").startsWith("Windows");
|
||||
}
|
||||
|
||||
Path contribute(String gradleVersion) throws IOException {
|
||||
Path projectDir = Files.createTempDirectory(this.directory, "project-");
|
||||
new GradleWrapperContributor(gradleVersion).contribute(projectDir);
|
||||
|
@@ -52,13 +52,17 @@ class MavenWrapperContributorTests {
|
||||
|
||||
private Consumer<Path> isNotExecutable() {
|
||||
return (path) -> {
|
||||
if (Files.isExecutable(path)) {
|
||||
if (supportsExecutableFlag() && Files.isExecutable(path)) {
|
||||
throw Failures.instance().failure(String
|
||||
.format("%nExpecting:%n <%s>%nto not be executable.", path));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean supportsExecutableFlag() {
|
||||
return !System.getProperty("os.name").startsWith("Windows");
|
||||
}
|
||||
|
||||
Path contribute() throws IOException {
|
||||
Path projectDir = Files.createTempDirectory(this.directory, "project-");
|
||||
new MavenWrapperContributor().contribute(projectDir);
|
||||
|
@@ -42,8 +42,8 @@ public class SourceCodeAssert {
|
||||
}
|
||||
|
||||
public SourceCodeAssert equalsTo(Resource expected) {
|
||||
try (InputStream stream = expected.getInputStream()) {
|
||||
String expectedContent = StreamUtils.copyToString(stream,
|
||||
try (InputStream in = expected.getInputStream()) {
|
||||
String expectedContent = StreamUtils.copyToString(in,
|
||||
Charset.forName("UTF-8"));
|
||||
assertThat(this.content).describedAs("Content for %s", this.name)
|
||||
.isEqualTo(expectedContent.replaceAll("\r\n", "\n"));
|
||||
|
Reference in New Issue
Block a user