Skip to content

Commit b69098f

Browse files
Saurabh AgarwalSaurabh Agarwal
authored andcommitted
Introduced a helper method for absolute path construction
1 parent 95f9f9d commit b69098f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

galvan-support/src/main/java/org/terracotta/testing/config/DefaultStartupCommandBuilder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.InputStream;
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
25+
import java.nio.file.Paths;
2526

2627
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
2728
import static org.terracotta.testing.demos.TestHelpers.isWindows;
@@ -84,13 +85,22 @@ protected void installServer() throws IOException {
8485
}
8586
}
8687

88+
/**
89+
* Returns a normalized absolute path to the shell/bat script, and quotes the windows path to avoid issues with special path chars.
90+
* @param scriptPath path to the script from the base kit
91+
* @return string representation of processed path
92+
*/
93+
protected String getAbsolutePath(Path scriptPath) {
94+
Path basePath = getServerWorkingDir().resolve(getKitDir()).resolve(scriptPath).toAbsolutePath().normalize();
95+
return isWindows() ? "\"" + basePath + ".bat\"" : basePath + ".sh";
96+
}
97+
8798
@Override
8899
public String[] build() {
89100
if (builtCommand == null) {
90101
try {
91102
installServer();
92-
Path basePath = serverWorkingDir.resolve(kitDir).resolve("server").resolve("bin").resolve("start-tc-server").toAbsolutePath().normalize();
93-
String startScript = isWindows() ? "\"" + basePath + ".bat\"" : basePath + ".sh";
103+
String startScript = getAbsolutePath(Paths.get("server","bin", "start-tc-server"));
94104
if (consistentStartup) {
95105
builtCommand = new String[]{startScript, "-c", "-f", tcConfig.toString(), "-n", serverName};
96106
} else {

0 commit comments

Comments
 (0)