Skip to content

Commit e513e57

Browse files
committed
Align samples test setup with the setup in other repositories
1 parent 93324c6 commit e513e57

File tree

9 files changed

+47
-63
lines changed

9 files changed

+47
-63
lines changed
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help "
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help"
9-
}]
1+
executable: gradlew
2+
args: help
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help"
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help"
9-
}]
1+
executable: gradlew
2+
args: help
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help -PmyGroup.myString=hello -PmyGroup.myInt=1"
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help -PmyGroup.myString=hello -PmyGroup.myInt=1"
9-
}]
1+
executable: gradlew
2+
args: "help -PmyGroup.myString=hello -PmyGroup.myInt=1"
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help "
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help"
9-
}]
1+
executable: gradlew
2+
args: help
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help -Pdeployment.username=jane-doe -Pdeployment.password=super-secret"
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help -Pdeployment.username=jane-doe -Pdeployment.password=super-secret"
9-
}]
1+
executable: gradlew
2+
args: "help -Pdeployment.username=jane-doe -Pdeployment.password=super-secret"
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help "
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help"
9-
}]
1+
executable: gradlew
2+
args: help
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
commands: [{
2-
execution-subdirectory: kotlin
3-
executable: gradle
4-
args: "help"
5-
},{
6-
execution-subdirectory: groovy
7-
executable: gradle
8-
args: "help"
9-
}]
1+
executable: gradlew
2+
args: help
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// SPDX-License-Identifier: Apache-2.0
22
package org.gradlex.buildparameters;
33

4+
import org.gradle.exemplar.test.runner.SampleModifiers;
45
import org.gradle.exemplar.test.runner.SamplesRoot;
56
import org.gradle.exemplar.test.runner.SamplesRunner;
67
import org.junit.runner.RunWith;
78

89
@RunWith(SamplesRunner.class)
910
@SamplesRoot("src/docs/snippets")
11+
@SampleModifiers(SamplesIntegrationTestModifier.class)
1012
public class SamplesIntegrationTest {}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package org.gradlex.buildparameters;
3+
4+
import java.io.File;
5+
import org.gradle.exemplar.model.Command;
6+
import org.gradle.exemplar.model.Sample;
7+
import org.gradle.exemplar.test.runner.SampleModifier;
8+
9+
public class SamplesIntegrationTestModifier implements SampleModifier {
10+
@Override
11+
public Sample modify(Sample sampleIn) {
12+
Command cmd = sampleIn.getCommands().remove(0);
13+
sampleIn.getCommands().add(copyCommand(cmd, "groovy"));
14+
sampleIn.getCommands().add(copyCommand(cmd, "kotlin"));
15+
return sampleIn;
16+
}
17+
18+
private Command copyCommand(Command cmd, String executionSubdirectory) {
19+
File pluginProjectDir = new File(".");
20+
return new Command(
21+
new File(pluginProjectDir, "gradlew").getAbsolutePath(),
22+
executionSubdirectory,
23+
cmd.getArgs(),
24+
cmd.getFlags(),
25+
cmd.getExpectedOutput(),
26+
cmd.isExpectFailure(),
27+
cmd.isAllowAdditionalOutput(),
28+
cmd.isAllowDisorderedOutput(),
29+
cmd.getUserInputs());
30+
}
31+
}

0 commit comments

Comments
 (0)