Search in sources :

Example 41 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class PythonBuckConfigTest method whenPythonOnPathNotFoundThenThrow.

@Test(expected = HumanReadableException.class)
public void whenPythonOnPathNotFoundThenThrow() throws IOException {
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("interpreter", "does-not-exist"))).setEnvironment(ImmutableMap.<String, String>builder().put("PATH", temporaryFolder.getRoot().toAbsolutePath().toString()).put("PATHEXT", "").build()).build(), new ExecutableFinder());
    config.getPythonInterpreter();
    fail("Should throw an exception when Python isn't found.");
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 42 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class PythonBuckConfigTest method whenToolsPythonIsExecutableFileThenItIsUsed.

@Test
public void whenToolsPythonIsExecutableFileThenItIsUsed() throws IOException {
    Path configPythonFile = temporaryFolder.newExecutableFile("python");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("interpreter", configPythonFile.toAbsolutePath().toString()))).build(), new ExecutableFinder());
    assertEquals("Should return path to temp file.", configPythonFile.toAbsolutePath().toString(), config.getPythonInterpreter());
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Example 43 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class PythonTestIntegrationTest method getPythonBuckConfig.

private PythonBuckConfig getPythonBuckConfig() throws IOException {
    Config rawConfig = Configs.createDefaultConfig(tmp.getRoot());
    BuckConfig buckConfig = new BuckConfig(rawConfig, new ProjectFilesystem(tmp.getRoot()), Architecture.detect(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new DefaultCellPathResolver(tmp.getRoot(), rawConfig));
    return new PythonBuckConfig(buckConfig, new ExecutableFinder());
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 44 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class PythonBinaryIntegrationTest method getPythonBuckConfig.

private PythonBuckConfig getPythonBuckConfig() throws IOException {
    Config rawConfig = Configs.createDefaultConfig(tmp.getRoot());
    BuckConfig buckConfig = new BuckConfig(rawConfig, new ProjectFilesystem(tmp.getRoot()), Architecture.detect(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new DefaultCellPathResolver(tmp.getRoot(), rawConfig));
    return new PythonBuckConfig(buckConfig, new ExecutableFinder());
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) DefaultCellPathResolver(com.facebook.buck.rules.DefaultCellPathResolver) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Config(com.facebook.buck.config.Config) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 45 with ExecutableFinder

use of com.facebook.buck.io.ExecutableFinder in project buck by facebook.

the class PythonBuckConfigTest method whenPythonPlusExtensionOnPathIsExecutableFileThenItIsUsed.

@Test
public void whenPythonPlusExtensionOnPathIsExecutableFileThenItIsUsed() throws IOException {
    temporaryFolder.newExecutableFile("my-py.exe");
    PythonBuckConfig config = new PythonBuckConfig(FakeBuckConfig.builder().setSections(ImmutableMap.of("python", ImmutableMap.of("interpreter", "my-py"))).setEnvironment(ImmutableMap.<String, String>builder().put("PATH", temporaryFolder.getRoot().toAbsolutePath().toString()).put("PATHEXT", ".exe").build()).build(), new ExecutableFinder(Platform.WINDOWS));
    config.getPythonInterpreter();
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) AlwaysFoundExecutableFinder(com.facebook.buck.io.AlwaysFoundExecutableFinder) Test(org.junit.Test)

Aggregations

ExecutableFinder (com.facebook.buck.io.ExecutableFinder)47 Path (java.nio.file.Path)28 Test (org.junit.Test)20 AlwaysFoundExecutableFinder (com.facebook.buck.io.AlwaysFoundExecutableFinder)13 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)9 PythonBuckConfig (com.facebook.buck.python.PythonBuckConfig)6 HumanReadableException (com.facebook.buck.util.HumanReadableException)6 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)5 BuildTarget (com.facebook.buck.model.BuildTarget)5 ParserConfig (com.facebook.buck.parser.ParserConfig)5 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)5 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)5 BuckConfig (com.facebook.buck.cli.BuckConfig)4 DefaultProjectBuildFileParserFactory (com.facebook.buck.json.DefaultProjectBuildFileParserFactory)4 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)4 TestConsole (com.facebook.buck.testutil.TestConsole)4 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)4 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)3 Config (com.facebook.buck.config.Config)3 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)3