Skip to content

Commit 45558bd

Browse files
committed
blah
1 parent 79e0d44 commit 45558bd

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

plugin/src/integrationTest/java/org/gauge/gradle/RunTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void testCanRunGaugeTestsWhenInParallelSet(TestGradleVersions gradle) throws IOE
118118
specsDir = 'specs multipleSpecs'
119119
inParallel = true
120120
nodes = 2
121-
additionalFlags = '--simple-console'
121+
additionalFlags = '--simple-console --verbose'
122122
}
123123
""");
124124
// Then I should be able to run the gauge task
@@ -148,7 +148,7 @@ void testCanRunGaugeTestsWhenTagsSet(TestGradleVersions gradle) throws IOExcepti
148148
gauge {
149149
specsDir='specs multipleSpecs'
150150
inParallel = true
151-
additionalFlags = '--simple-console'
151+
additionalFlags = '--simple-console --verbose'
152152
tags = 'example1'
153153
}
154154
""");
@@ -178,7 +178,7 @@ void testCanRunGaugeTestsWhenEnvSet(TestGradleVersions gradle) throws IOExceptio
178178
writeFile(buildFile, getApplyPluginsBlock() + """
179179
gauge {
180180
inParallel = true
181-
additionalFlags = '--simple-console'
181+
additionalFlags = '--simple-console --verbose'
182182
env = 'invalid'
183183
}
184184
""");
@@ -204,7 +204,7 @@ void testCanRunGaugeTestsWhenRepeatFlagSet(TestGradleVersions gradle) throws IOE
204204
writeFile(buildFile, getApplyPluginsBlock() + """
205205
gauge {
206206
inParallel = true
207-
additionalFlags = '--simple-console'
207+
additionalFlags = '--simple-console --verbose'
208208
nodes = 2
209209
env = 'dev'
210210
}
@@ -213,15 +213,15 @@ void testCanRunGaugeTestsWhenRepeatFlagSet(TestGradleVersions gradle) throws IOE
213213
BuildResult resultWithExtension = defaultGradleRunner().withGradleVersion(gradle.ver).withArguments(GAUGE_TASK, "--info").build();
214214
assertEquals(SUCCESS, resultWithExtension.task(GAUGE_TASK_PATH).getOutcome());
215215
// And I should see environment and parallel flags with specs in the command
216-
assertThat(resultWithExtension.getOutput(), containsString("--simple-console --parallel --n 2 --env dev specs"));
216+
assertThat(resultWithExtension.getOutput(), containsString("--simple-console --verbose --parallel --n 2 --env dev specs"));
217217
// When additionalFlags include the --repeat flag
218218
BuildResult resultWithProperty = defaultGradleRunner().withGradleVersion(gradle.ver)
219-
.withArguments(GAUGE_TASK, "-PadditionalFlags=--repeat --simple-console", "--info").build();
219+
.withArguments(GAUGE_TASK, "-PadditionalFlags=--repeat --simple-console --verbose", "--info").build();
220220
assertEquals(SUCCESS, resultWithProperty.task(GAUGE_TASK_PATH).getOutcome());
221221
// Then I should not see environment and parallel flags and specs include the command
222222
assertThat(resultWithProperty.getOutput(), not(containsString("--parallel --n 2 --env dev specs")));
223223
// And I should only see repeat and simple-console included
224-
assertThat(resultWithProperty.getOutput(), containsString("--repeat --simple-console"));
224+
assertThat(resultWithProperty.getOutput(), containsString("--repeat --simple-console --verbose"));
225225
// And I should see tests ran against the dev environment
226226
assertThat(resultWithProperty.getOutput(), containsString(getExpectedReportPath("dev")));
227227
}

plugin/src/main/java/org/gauge/gradle/GaugeCommand.java

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
import java.nio.file.Path;
66
import java.nio.file.Paths;
7-
import java.util.ArrayList;
8-
import java.util.Arrays;
9-
import java.util.Collections;
10-
import java.util.List;
11-
import java.util.Map;
7+
import java.util.*;
128

139
/**
1410
* Represents a Gauge command and provides methods to construct command-line arguments for Gauge execution.
@@ -37,16 +33,13 @@ public GaugeCommand(final GaugeExtension extension, final Project project) {
3733
* @return the path to the Gauge executable
3834
*/
3935
public String getExecutable() {
40-
final String binary = "gauge";
4136
return project.hasProperty(GaugeProperty.GAUGE_ROOT.getKey())
42-
? getExecutablePath(properties.get(GaugeProperty.GAUGE_ROOT.getKey()).toString()).toString()
43-
: extension.getGaugeRoot().isPresent()
44-
? getExecutablePath(extension.getGaugeRoot().get()).toString()
45-
: binary;
37+
? getExecutablePath(properties.get(GaugeProperty.GAUGE_ROOT.getKey()).toString())
38+
: extension.getGaugeRoot().map(this::getExecutablePath).getOrElse("gauge");
4639
}
4740

48-
private Path getExecutablePath(final String gaugeRoot) {
49-
return Paths.get(gaugeRoot, "bin", "gauge");
41+
private String getExecutablePath(final String gaugeRoot) {
42+
return Paths.get(gaugeRoot, "bin", "gauge").toString();
5043
}
5144

5245
/**
@@ -105,33 +98,33 @@ public List<Object> getFlags() {
10598
flags.add(GaugeProperty.IN_PARALLEL.getFlag());
10699
final int nodes = getNodes();
107100
if (nodes != 0) {
108-
flags.addAll(List.of(GaugeProperty.NODES.getFlag(), nodes));
101+
flags.add(GaugeProperty.NODES.getFlag());
102+
flags.add(nodes);
109103
}
110104
}
111105
return flags;
112106
}
113107

114108
private List<String> getAdditionalFlags() {
115-
return project.hasProperty(GaugeProperty.ADDITIONAL_FLAGS.getKey())
116-
? getListFromString(properties.get(GaugeProperty.ADDITIONAL_FLAGS.getKey()).toString())
117-
: extension.getAdditionalFlags().isPresent()
118-
? getListFromString(extension.getAdditionalFlags().get())
119-
: Collections.emptyList();
109+
return getListFromString(project.hasProperty(GaugeProperty.ADDITIONAL_FLAGS.getKey())
110+
? properties.get(GaugeProperty.ADDITIONAL_FLAGS.getKey()).toString()
111+
: extension.getAdditionalFlags().getOrElse("")
112+
);
120113
}
121114

122115
private List<String> getListFromString(final String value) {
123-
return Arrays.stream(value.split("\\s+")).map(String::trim).toList();
116+
return Arrays.stream(value.split("\\s+")).map(String::trim).filter(s -> !s.isEmpty()).toList();
124117
}
125118

126119
private int getNodes() {
127120
return project.hasProperty(GaugeProperty.NODES.getKey())
128121
? Integer.parseInt(properties.get(GaugeProperty.NODES.getKey()).toString())
129-
: extension.getNodes().isPresent() ? extension.getNodes().get() : 0;
122+
: extension.getNodes().getOrElse(0);
130123
}
131124

132125
private boolean isInParallel() {
133126
return project.hasProperty(GaugeProperty.IN_PARALLEL.getKey())
134-
? Boolean.parseBoolean(project.getProperties().get(GaugeProperty.IN_PARALLEL.getKey()).toString())
127+
? Boolean.parseBoolean(properties.get(GaugeProperty.IN_PARALLEL.getKey()).toString())
135128
: extension.getInParallel().get();
136129
}
137130

@@ -154,7 +147,7 @@ public List<String> getSpecsDir() {
154147
public List<String> getTags() {
155148
final String tags = project.hasProperty(GaugeProperty.TAGS.getKey())
156149
? properties.get(GaugeProperty.TAGS.getKey()).toString()
157-
: extension.getTags().isPresent() ? extension.getTags().get() : "";
150+
: extension.getTags().getOrElse("");
158151
return !tags.isEmpty() ? List.of(GaugeProperty.TAGS.getFlag(), tags) : Collections.emptyList();
159152
}
160153

0 commit comments

Comments
 (0)