Skip to content

Commit 671b6ee

Browse files
authored
Run the NativeCmd integration test with and without the configuration cache (#2358 fixes #2347)
2 parents 339d2c9 + 4938c84 commit 671b6ee

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

lib/src/main/java/com/diffplug/spotless/FileSignature.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static Promised promise(Iterable<File> files) {
126126
}
127127

128128
public static Promised promise(File file) {
129-
return new Promised(List.of(file), null);
129+
return new Promised(MoreIterables.toNullHostileList(List.of(file)), null);
130130
}
131131

132132
/** Returns all of the files in this signature, throwing an exception if there are more or less than 1 file. */

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

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2024 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.
@@ -20,26 +20,40 @@
2020
import java.io.File;
2121
import java.io.IOException;
2222

23+
import org.gradle.testkit.runner.GradleRunner;
2324
import org.junit.jupiter.api.Test;
2425

25-
class NativeCmdIntegrationTest extends GradleIntegrationHarness {
26+
interface NativeCmdIntegrationTest {
2627
@Test
27-
void nativeCmd() throws IOException {
28+
default void nativeCmd() throws IOException {
2829
// This will only work if /usr/bin/sed is available
2930
assumeThat(new File("/usr/bin/sed")).exists();
3031

31-
setFile("build.gradle").toLines(
32+
GradleIntegrationHarness harness = (GradleIntegrationHarness) this;
33+
harness.setFile("build.gradle").toLines(
3234
"plugins {",
3335
" id 'com.diffplug.spotless'",
3436
"}",
3537
"spotless {",
38+
" lineEndings 'UNIX'",
3639
" format 'test', {",
37-
" target '**/*.txt'",
40+
" target '*.txt'",
3841
" nativeCmd('sed', '/usr/bin/sed', ['s/placeholder/replaced/g'])",
3942
" }",
4043
"}");
41-
setFile("test.txt").toResource("native_cmd/dirty.txt");
42-
gradleRunner().withArguments("spotlessApply").build();
43-
assertFile("test.txt").sameAsResource("native_cmd/clean.txt");
44+
harness.setFile("test.txt").toResource("native_cmd/dirty.txt");
45+
harness.gradleRunner().withArguments("spotlessApply", "--stacktrace").build();
46+
harness.assertFile("test.txt").sameAsResource("native_cmd/clean.txt");
47+
}
48+
49+
class NativeCmdWithoutConfigCacheTest extends GradleIntegrationHarness implements NativeCmdIntegrationTest {}
50+
51+
class NativeCmdWithConfigCacheTest extends GradleIntegrationHarness implements NativeCmdIntegrationTest {
52+
@Override
53+
public GradleRunner gradleRunner() throws IOException {
54+
setFile("gradle.properties").toContent("org.gradle.unsafe.configuration-cache=true");
55+
setFile("gradle.properties").toContent("org.gradle.configuration-cache=true");
56+
return super.gradleRunner().withGradleVersion(GradleVersionSupport.CONFIGURATION_CACHE.version);
57+
}
4458
}
4559
}

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

-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717

1818
import org.assertj.core.api.Assertions;
1919
import org.gradle.testkit.runner.BuildResult;
20-
import org.junit.jupiter.api.Disabled;
2120
import org.junit.jupiter.api.Test;
2221

2322
import com.diffplug.common.base.Predicates;
2423

25-
@Disabled("https://status.npmjs.org/ shows npm services down on 12/8/2024, should undisable this later")
2624
class NpmTestsWithoutNpmInstallationTest extends GradleIntegrationHarness {
2725

2826
@Test

0 commit comments

Comments
 (0)