Skip to content

Commit 4cdecc9

Browse files
committed
---
yaml --- r: 6131 b: refs/heads/tswast-patch-1 c: f753b44 h: refs/heads/master i: 6129: afa77ea 6127: 8ec499c
1 parent 3cd7b44 commit 4cdecc9

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: e792c2c67795572501a2bd2cc04cb7a183a41a3f
60+
refs/heads/tswast-patch-1: f753b44d9a2f2b787b4e9fc1f51b67f47a19ba68
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/LocalGcdHelper.java

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,8 @@ private static Path installedGcdPath() {
134134
}
135135

136136
private static String installedGcdVersion() throws IOException, InterruptedException {
137-
CommandWrapper gcloudCommand;
138-
if (isWindows()) {
139-
gcloudCommand = CommandWrapper.cmd();
140-
} else {
141-
gcloudCommand = CommandWrapper.bash();
142-
}
143-
Process process = gcloudCommand.command("gcloud", "version").redirectErrorStream().start();
137+
Process process =
138+
CommandWrapper.create().command("gcloud", "version").redirectErrorStream().start();
144139
process.waitFor();
145140
try (BufferedReader reader =
146141
new BufferedReader(new InputStreamReader(process.getInputStream()))) {
@@ -225,6 +220,14 @@ private static class CommandWrapper {
225220

226221
private CommandWrapper() {
227222
this.prefix = new ArrayList<>();
223+
if (isWindows()) {
224+
this.prefix.add("cmd");
225+
this.prefix.add("/C");
226+
this.nullFilename = "NUL:";
227+
} else {
228+
this.prefix.add("bash");
229+
this.nullFilename = "/dev/null";
230+
}
228231
}
229232

230233
public CommandWrapper command(String... command) {
@@ -275,19 +278,8 @@ public Process start() throws IOException {
275278
return builder().start();
276279
}
277280

278-
public static CommandWrapper cmd() {
279-
CommandWrapper wrapper = new CommandWrapper();
280-
wrapper.prefix.add("cmd");
281-
wrapper.prefix.add("/C");
282-
wrapper.nullFilename = "NUL:";
283-
return wrapper;
284-
}
285-
286-
public static CommandWrapper bash() {
287-
CommandWrapper wrapper = new CommandWrapper();
288-
wrapper.prefix.add("bash");
289-
wrapper.nullFilename = "/dev/null";
290-
return wrapper;
281+
public static CommandWrapper create() {
282+
return new CommandWrapper();
291283
}
292284
}
293285

@@ -362,17 +354,11 @@ private void startGcd(Path executablePath) throws IOException, InterruptedExcept
362354
File datasetFolder = new File(gcdPath.toFile(), projectId);
363355
deleteRecurse(datasetFolder.toPath());
364356

365-
// create command wrappers
366-
CommandWrapper gcdCreateCommand;
367-
CommandWrapper gcdStartCommand;
357+
// Get path to cmd executable
368358
Path gcdAbsolutePath;
369359
if (isWindows()) {
370-
gcdCreateCommand = CommandWrapper.cmd();
371-
gcdStartCommand = CommandWrapper.cmd();
372360
gcdAbsolutePath = executablePath.toAbsolutePath().resolve("gcd.cmd");
373361
} else {
374-
gcdCreateCommand = CommandWrapper.bash();
375-
gcdStartCommand = CommandWrapper.bash();
376362
gcdAbsolutePath = executablePath.toAbsolutePath().resolve("gcd.sh");
377363
}
378364

@@ -381,7 +367,8 @@ private void startGcd(Path executablePath) throws IOException, InterruptedExcept
381367
log.log(Level.FINE, "Creating datastore for the project: {0}", projectId);
382368
}
383369
Process createProcess =
384-
gcdCreateCommand.command(gcdAbsolutePath.toString(), "create", "-p", projectId, projectId)
370+
CommandWrapper.create()
371+
.command(gcdAbsolutePath.toString(), "create", "-p", projectId, projectId)
385372
.redirectErrorInherit()
386373
.directory(gcdPath)
387374
.redirectOutputToNull()
@@ -393,7 +380,7 @@ private void startGcd(Path executablePath) throws IOException, InterruptedExcept
393380
log.log(Level.FINE, "Starting datastore emulator for the project: {0}", projectId);
394381
}
395382
Process startProcess =
396-
gcdStartCommand
383+
CommandWrapper.create()
397384
.command(gcdAbsolutePath.toString(), "start", "--testing", "--allow_remote_shutdown",
398385
projectId)
399386
.directory(gcdPath)

0 commit comments

Comments
 (0)