|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2024 DiffPlug |
| 2 | + * Copyright 2016-2025 DiffPlug |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 |
|
18 | 18 | import java.io.IOException;
|
19 | 19 |
|
| 20 | +import org.gradle.testkit.runner.GradleRunner; |
20 | 21 | import org.junit.jupiter.api.Test;
|
21 | 22 |
|
22 |
| -class BumpThisNumberIfACustomStepChangesTest extends GradleIntegrationHarness { |
| 23 | +abstract class BumpThisNumberIfACustomStepChangesTest extends GradleIntegrationHarness { |
| 24 | + private boolean useConfigCache; |
| 25 | + |
| 26 | + BumpThisNumberIfACustomStepChangesTest(boolean useConfigCache) { |
| 27 | + this.useConfigCache = useConfigCache; |
| 28 | + } |
| 29 | + |
| 30 | + static class WithConfigCache extends BumpThisNumberIfACustomStepChangesTest { |
| 31 | + WithConfigCache() { |
| 32 | + super(true); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + static class WithoutConfigCache extends BumpThisNumberIfACustomStepChangesTest { |
| 37 | + WithoutConfigCache() { |
| 38 | + super(false); |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public GradleRunner gradleRunner() throws IOException { |
| 44 | + if (useConfigCache) { |
| 45 | + setFile("gradle.properties").toLines("org.gradle.unsafe.configuration-cache=true", |
| 46 | + "org.gradle.configuration-cache=true"); |
| 47 | + return super.gradleRunner().withGradleVersion(GradleVersionSupport.CONFIGURATION_CACHE.version); |
| 48 | + } else { |
| 49 | + return super.gradleRunner(); |
| 50 | + } |
| 51 | + } |
| 52 | + |
23 | 53 | private void writeBuildFile(String toInsert) throws IOException {
|
24 | 54 | setFile("build.gradle").toLines(
|
25 | 55 | "plugins {",
|
@@ -50,7 +80,12 @@ void customRuleNeverUpToDate() throws IOException {
|
50 | 80 | writeContentWithBadFormatting();
|
51 | 81 | applyIsUpToDate(false);
|
52 | 82 | checkIsUpToDate(false);
|
53 |
| - checkIsUpToDate(false); |
| 83 | + if (useConfigCache) { |
| 84 | + // if the config cache is in-effect, then it's okay for custom rules to become "up-to-date" |
| 85 | + checkIsUpToDate(true); |
| 86 | + } else { |
| 87 | + checkIsUpToDate(false); |
| 88 | + } |
54 | 89 | }
|
55 | 90 |
|
56 | 91 | @Test
|
|
0 commit comments