use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class OCamlIntegrationTest method testConfigInteropIncludes.
@Test
public void testConfigInteropIncludes() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "config_interop_includes", tmp);
workspace.setUp();
Path ocamlc = new ExecutableFinder(Platform.detect()).getExecutable(Paths.get("ocamlc"), ImmutableMap.copyOf(System.getenv()));
ProcessExecutor.Result result = workspace.runCommand(ocamlc.toString(), "-where");
assertEquals(0, result.getExitCode());
String stdlibPath = result.getStdout().get();
BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//:test");
BuildTarget binary = createOcamlLinkTarget(target);
ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, binary);
// Points somewhere with no stdlib in it, so fails to find Pervasives
workspace.runBuckCommand("build", target.toString()).assertFailure();
BuckBuildLog buildLog = workspace.getBuildLog();
assertThat(buildLog.getAllTargets(), Matchers.hasItems(targets.toArray(new BuildTarget[0])));
buildLog.assertTargetCanceled(target.toString());
buildLog.assertTargetCanceled(binary.toString());
workspace.resetBuildLogFile();
// Point to the real stdlib (from `ocamlc -where`)
workspace.replaceFileContents(".buckconfig", "interop.includes=lib", "interop.includes=" + stdlibPath);
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
workspace.resetBuildLogFile();
// Remove the config, should default to a valid place
workspace.replaceFileContents(".buckconfig", "interop.includes=" + stdlibPath, "");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class ParserConfigTest method whenParserPythonIsNotSetFallbackIsUsed.
@Test
public void whenParserPythonIsNotSetFallbackIsUsed() throws IOException {
Path configPythonFile = temporaryFolder.newExecutableFile("python");
// This sets the python.interpreter section, not parser.python_interpreter
ParserConfig parserConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("interpreter", configPythonFile.toAbsolutePath().toString()))).build().getView(ParserConfig.class);
assertEquals("Should return path to temp file.", configPythonFile.toAbsolutePath().toString(), parserConfig.getPythonInterpreter(new ExecutableFinder()));
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class PythonBuckConfigTest method whenToolsPythonIsExecutableDirectoryThenItIsNotUsed.
@Test(expected = HumanReadableException.class)
public void whenToolsPythonIsExecutableDirectoryThenItIsNotUsed() throws IOException {
Path configPythonFile = temporaryFolder.newFolder("python");
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("interpreter", configPythonFile.toAbsolutePath().toString()))).build(), new ExecutableFinder());
config.getPythonInterpreter();
fail("Should throw exception as python config is invalid.");
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class PythonBuckConfigTest method whenToolsPythonIsNonExecutableFileThenItIsNotUsed.
@Test(expected = HumanReadableException.class)
public void whenToolsPythonIsNonExecutableFileThenItIsNotUsed() throws IOException {
assumeThat("On windows all files are executable.", Platform.detect(), is(not(Platform.WINDOWS)));
Path configPythonFile = temporaryFolder.newFile("python");
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("interpreter", configPythonFile.toAbsolutePath().toString()))).build(), new ExecutableFinder());
config.getPythonInterpreter();
fail("Should throw exception as python config is invalid.");
}
use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.
the class PythonBuckConfigTest method whenMultiplePythonExecutablesOnPathFirstIsUsed.
@Test
public void whenMultiplePythonExecutablesOnPathFirstIsUsed() throws IOException {
Path pythonA = temporaryFolder.newExecutableFile("python2");
temporaryFolder2.newExecutableFile("python2");
String path = temporaryFolder.getRoot().toAbsolutePath() + File.pathSeparator + temporaryFolder2.getRoot().toAbsolutePath();
PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setEnvironment(ImmutableMap.<String, String>builder().put("PATH", path).put("PATHEXT", "").build()).build(), new ExecutableFinder());
assertEquals("Should return the first path", config.getPythonInterpreter(), pythonA.toAbsolutePath().toString());
}
Aggregations