use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KotlinBuckConfigTest method testFindsKotlinCompilerInConfigWithRelativePath.
@Test
public void testFindsKotlinCompilerInConfigWithRelativePath() throws HumanReadableException, IOException {
// Get faux kotlinc binary location in project
Path kotlinCompiler = workspace.resolve("bin").resolve("kotlinc");
MoreFiles.makeExecutable(kotlinCompiler);
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.resolve("."));
BuckConfig buckConfig = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(ImmutableMap.of("kotlin", ImmutableMap.of("compiler", "bin/kotlinc"))).build();
KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
String command = kotlinBuckConfig.getKotlinCompiler().get().getCommandPrefix(null).get(0);
assertEquals(command, kotlinCompiler.toString());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KotlinBuckConfigTest method testFindsKotlinRuntimeInConfigWithAbsolutePath.
@Test
public void testFindsKotlinRuntimeInConfigWithAbsolutePath() throws HumanReadableException, IOException {
Path kotlinRuntime = workspace.resolve("lib").resolve("kotlin-runtime.jar");
BuckConfig buckConfig = FakeBuckConfig.builder().setSections(ImmutableMap.of("kotlin", ImmutableMap.of("runtime_jar", kotlinRuntime.toString()))).setEnvironment(ImmutableMap.of("KOTLIN_HOME", workspace.getPath(".").normalize().toString())).build();
KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
Path runtimeJar = kotlinBuckConfig.getPathToRuntimeJar().getRight();
assertEquals(runtimeJar.toString(), kotlinRuntime.toString());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class KotlinBuckConfigTest method testFindsKotlinCompilerInHome.
@Test
public void testFindsKotlinCompilerInHome() throws HumanReadableException, IOException {
// Get faux kotlinc binary location in project
Path kotlinCompiler = workspace.resolve("bin").resolve("kotlinc");
MoreFiles.makeExecutable(kotlinCompiler);
BuckConfig buckConfig = FakeBuckConfig.builder().setEnvironment(ImmutableMap.of("KOTLIN_HOME", workspace.getPath(".").normalize().toString())).build();
KotlinBuckConfig kotlinBuckConfig = new KotlinBuckConfig(buckConfig);
String command = kotlinBuckConfig.getKotlinCompiler().get().getCommandPrefix(null).get(0);
assertEquals(command, kotlinCompiler.toString());
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenEnvChangesThenCachedRulesAreInvalidated.
@Test
public void whenEnvChangesThenCachedRulesAreInvalidated() throws Exception {
Path buckFile = cellRoot.resolve("BUCK");
Files.write(buckFile, Joiner.on("").join(ImmutableList.of("import os\n", "os.getenv('FOO')\n", "genrule(name = 'cake', out = 'file.txt', cmd = 'touch $OUT')\n")).getBytes(UTF_8));
BuckConfig config = FakeBuckConfig.builder().setEnvironment(ImmutableMap.<String, String>builder().putAll(System.getenv()).put("FOO", "value").build()).setFilesystem(filesystem).build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
parser.getAllTargetNodes(eventBus, cell, false, executorService, buckFile);
// Call filterAllTargetsInProject to request cached rules.
config = FakeBuckConfig.builder().setFilesystem(filesystem).setEnvironment(ImmutableMap.<String, String>builder().putAll(System.getenv()).put("FOO", "other value").build()).build();
cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
parser.getAllTargetNodes(eventBus, cell, false, executorService, buckFile);
// Test that the second parseBuildFile call repopulated the cache.
assertEquals("Should have invalidated.", 2, counter.calls);
}
use of com.facebook.buck.cli.BuckConfig in project buck by facebook.
the class ParserTest method whenBuckConfigAddedThenCachedRulesAreInvalidated.
@Test
public void whenBuckConfigAddedThenCachedRulesAreInvalidated() throws Exception {
Path buckFile = cellRoot.resolve("BUCK");
Files.write(buckFile, Joiner.on("").join(ImmutableList.of("read_config('foo', 'bar')\n", "genrule(name = 'cake', out = 'file.txt', cmd = 'touch $OUT')\n")).getBytes(UTF_8));
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem).build();
Cell cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
parser.getAllTargetNodes(eventBus, cell, false, executorService, buckFile);
// Call filterAllTargetsInProject to request cached rules.
config = FakeBuckConfig.builder().setFilesystem(filesystem).setSections(ImmutableMap.of("foo", ImmutableMap.of("bar", "other value"))).build();
cell = new TestCellBuilder().setFilesystem(filesystem).setBuckConfig(config).build();
parser.getAllTargetNodes(eventBus, cell, false, executorService, buckFile);
// Test that the second parseBuildFile call repopulated the cache.
assertEquals("Should have invalidated.", 2, counter.calls);
}
Aggregations