diff --git a/lib/src/main/java/com/diffplug/spotless/FileSignature.java b/lib/src/main/java/com/diffplug/spotless/FileSignature.java index 3d37ec2983..0d26d86ff8 100644 --- a/lib/src/main/java/com/diffplug/spotless/FileSignature.java +++ b/lib/src/main/java/com/diffplug/spotless/FileSignature.java @@ -126,7 +126,7 @@ public static Promised promise(Iterable files) { } public static Promised promise(File file) { - return new Promised(List.of(file), null); + return new Promised(MoreIterables.toNullHostileList(List.of(file)), null); } /** Returns all of the files in this signature, throwing an exception if there are more or less than 1 file. */ diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NativeCmdIntegrationTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NativeCmdIntegrationTest.java index a4f8d6205c..418bded954 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NativeCmdIntegrationTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NativeCmdIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 DiffPlug + * Copyright 2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,26 +20,40 @@ import java.io.File; import java.io.IOException; +import org.gradle.testkit.runner.GradleRunner; import org.junit.jupiter.api.Test; -class NativeCmdIntegrationTest extends GradleIntegrationHarness { +interface NativeCmdIntegrationTest { @Test - void nativeCmd() throws IOException { + default void nativeCmd() throws IOException { // This will only work if /usr/bin/sed is available assumeThat(new File("/usr/bin/sed")).exists(); - setFile("build.gradle").toLines( + GradleIntegrationHarness harness = (GradleIntegrationHarness) this; + harness.setFile("build.gradle").toLines( "plugins {", " id 'com.diffplug.spotless'", "}", "spotless {", + " lineEndings 'UNIX'", " format 'test', {", - " target '**/*.txt'", + " target '*.txt'", " nativeCmd('sed', '/usr/bin/sed', ['s/placeholder/replaced/g'])", " }", "}"); - setFile("test.txt").toResource("native_cmd/dirty.txt"); - gradleRunner().withArguments("spotlessApply").build(); - assertFile("test.txt").sameAsResource("native_cmd/clean.txt"); + harness.setFile("test.txt").toResource("native_cmd/dirty.txt"); + harness.gradleRunner().withArguments("spotlessApply", "--stacktrace").build(); + harness.assertFile("test.txt").sameAsResource("native_cmd/clean.txt"); + } + + class NativeCmdWithoutConfigCacheTest extends GradleIntegrationHarness implements NativeCmdIntegrationTest {} + + class NativeCmdWithConfigCacheTest extends GradleIntegrationHarness implements NativeCmdIntegrationTest { + @Override + public GradleRunner gradleRunner() throws IOException { + setFile("gradle.properties").toContent("org.gradle.unsafe.configuration-cache=true"); + setFile("gradle.properties").toContent("org.gradle.configuration-cache=true"); + return super.gradleRunner().withGradleVersion(GradleVersionSupport.CONFIGURATION_CACHE.version); + } } } diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest.java index 50ea620778..22fe466dbe 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmTestsWithoutNpmInstallationTest.java @@ -17,12 +17,10 @@ import org.assertj.core.api.Assertions; import org.gradle.testkit.runner.BuildResult; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import com.diffplug.common.base.Predicates; -@Disabled("https://status.npmjs.org/ shows npm services down on 12/8/2024, should undisable this later") class NpmTestsWithoutNpmInstallationTest extends GradleIntegrationHarness { @Test