Search in sources :

Example 96 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class KotlinBuckConfigTest method testFindsKotlinRuntimeLibraryInPath.

@Test
public void testFindsKotlinRuntimeLibraryInPath() throws IOException {
    // Get faux kotlinc binary location in project
    Path kotlinPath = workspace.resolve("bin");
    Path kotlinCompiler = kotlinPath.resolve("kotlinc");
    MoreFiles.makeExecutable(kotlinCompiler);
    BuckConfig buckConfig = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("PATH", kotlinPath.toString() + pathSeparator + System.getenv("PATH"))).build();
    KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
    Path runtimeJar = kotlinBuckConfig.getPathToRuntimeJar().getRight();
    Assert.assertThat(runtimeJar.toString(), Matchers.containsString(workspace.getPath(".").normalize().toString()));
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Example 97 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class KotlinBuckConfigTest method testFindsKotlinCompilerInConfigWithAbsolutePath.

@Test
public void testFindsKotlinCompilerInConfigWithAbsolutePath() throws HumanReadableException, IOException {
    // Get faux kotlinc binary location in project
    Path kotlinCompiler = workspace.resolve("bin").resolve("kotlinc");
    MoreFiles.makeExecutable(kotlinCompiler);
    BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("kotlin", ImmutableMap.of("compiler", kotlinCompiler.toString()))).build();
    KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
    String command = kotlinBuckConfig.getKotlinCompiler().get().getCommandPrefix(null).get(0);
    assertEquals(command, kotlinCompiler.toString());
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) Test(org.junit.Test)

Example 98 with BuckConfig

use of com.facebook.buck.cli.BuckConfig in project buck by facebook.

the class KotlinBuckConfigTest method testFindsKotlinRuntimeInConfigWithRelativePath.

@Test
public void testFindsKotlinRuntimeInConfigWithRelativePath() throws HumanReadableException, IOException {
    ProjectFilesystem filesystem = new ProjectFilesystem(workspace.resolve("."));
    BuckConfig buckConfig = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(ImmutableMap.of("kotlin", ImmutableMap.of("runtime_jar", "lib/kotlin-runtime.jar"))).setEnvironment(ImmutableMap.of("KOTLIN_HOME", workspace.getPath(".").normalize().toString())).build();
    KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
    PathSourcePath runtimeJar = (PathSourcePath) kotlinBuckConfig.getPathToRuntimeJar().getLeft();
    assertEquals(runtimeJar.getRelativePath().toString(), "lib/kotlin-runtime.jar");
}
Also used : FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) PathSourcePath(com.facebook.buck.rules.PathSourcePath) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Aggregations

BuckConfig (com.facebook.buck.cli.BuckConfig)98 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)89 Test (org.junit.Test)74 Path (java.nio.file.Path)46 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)37 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)29 PathSourcePath (com.facebook.buck.rules.PathSourcePath)27 Cell (com.facebook.buck.rules.Cell)22 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 Config (com.facebook.buck.config.Config)15 DefaultCellPathResolver (com.facebook.buck.rules.DefaultCellPathResolver)14 BuildTarget (com.facebook.buck.model.BuildTarget)12 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)9 ParserConfig (com.facebook.buck.parser.ParserConfig)8 ConstructorArgMarshaller (com.facebook.buck.rules.ConstructorArgMarshaller)7 DefaultTypeCoercerFactory (com.facebook.buck.rules.coercer.DefaultTypeCoercerFactory)7 TestConsole (com.facebook.buck.testutil.TestConsole)7 Optional (java.util.Optional)7 BuildJobState (com.facebook.buck.distributed.thrift.BuildJobState)6