Skip to content
Prev Previous commit
Next Next commit
Add case for Windows path variable "Path"
  • Loading branch information
hpryce committed Mar 8, 2017
commit 19791dd6a73d94d7deb892f38a80ace0661ab68f
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.palantir.docker.compose.execution;

import static com.google.common.base.MoreObjects.firstNonNull;
import static java.util.stream.Collectors.toList;

import com.google.common.collect.ImmutableList;
Expand All @@ -36,7 +35,10 @@ private DockerCommandLocations() {
}

public static List<Path> pathLocations() {
String path = firstNonNull(System.getenv("PATH"), firstNonNull(System.getenv("path"), File.pathSeparator));
String path = Stream.of(System.getenv("PATH"), System.getenv("path"), System.getenv("Path"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what about CrazyOS that uses "pATh"? /s

.filter(s -> s != null)
.findFirst()
.orElse(File.pathSeparator);
Stream<String> pathLocations = Arrays.stream(path.split(File.pathSeparator));
return Stream.concat(pathLocations, MAC_SEARCH_LOCATIONS.stream())
.map(p -> Paths.get(p))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public class DockerCommandLocationsShould {
assertThat(DockerCommandLocations.pathLocations(), hasItem(Paths.get("/lowercase")));
}

@Test public void
contain_the_contents_of_the_path_with_a_windows_environment_variable() {
environmentVariables.set("PATH", null);
environmentVariables.set("Path", "/windows");

assertThat(DockerCommandLocations.pathLocations(), hasItem(Paths.get("/windows")));
}

@Test public void
return_just_the_mac_locations_if_no_path_variable_is_present() {
environmentVariables.set("PATH", null);
Expand Down