Skip to content

Commit

Permalink
Apply /etc/profile when running CLI tools before integration tests
Browse files Browse the repository at this point in the history
Some operating systems may have a shell without default PATH variable
compiled in, so we should take into account system PATH

Signed-off-by: Alexander Koval <[email protected]>
  • Loading branch information
anti-social committed May 16, 2024
1 parent f217270 commit 3f8e7d4
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -716,14 +716,24 @@ private void runOpenSearchBinScriptWithInput(String input, String tool, CharSequ
LoggedExec.exec(project, spec -> {
spec.setEnvironment(getOpenSearchEnvironment());
spec.workingDir(getDistroDir());
spec.executable(OS.conditionalString().onUnix(() -> "./bin/" + tool).onWindows(() -> "cmd").supply());
spec.executable(
OS.conditionalString()
.onUnix(() -> "/usr/bin/env")
.onWindows(() -> "cmd").supply()
);
spec.args(OS.<List<CharSequence>>conditional().onWindows(() -> {
ArrayList<CharSequence> result = new ArrayList<>();
result.add("/c");
result.add("bin\\" + tool + ".bat");
result.addAll(Arrays.asList(args));
return result;
}).onUnix(() -> Arrays.asList(args)).supply());
}).onUnix(() -> {
ArrayList<CharSequence> result = new ArrayList<>();
result.add("bash");
result.add("-c");
result.add("source /etc/profile; ./bin/" + tool + " " + String.join(" ", args));
return result;
}).supply());
spec.setStandardInput(byteArrayInputStream);

});
Expand Down

0 comments on commit 3f8e7d4

Please sign in to comment.