use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableMap in project buck by facebook.
the class HeaderMapStepTest method testHeaderMap.
@Test
public void testHeaderMap() throws IOException {
ProjectFilesystem projectFilesystem = new ProjectFilesystem(tmpDir.getRoot().toPath());
ExecutionContext context = TestExecutionContext.newInstance();
Path output = Paths.get("headers.hmap");
ImmutableMap<Path, Path> entries = ImmutableMap.of(Paths.get("file1.h"), Paths.get("/some/absolute/path.h"), Paths.get("file2.h"), Paths.get("/other/absolute/path.h"), Paths.get("prefix/file1.h"), Paths.get("/some/absolute/path.h"));
HeaderMapStep step = new HeaderMapStep(projectFilesystem, output, entries);
step.execute(context);
assertTrue(projectFilesystem.exists(output));
byte[] headerMapBytes = ByteStreams.toByteArray(projectFilesystem.newFileInputStream(output));
HeaderMap headerMap = HeaderMap.deserialize(headerMapBytes);
assertNotNull(headerMap);
assertThat(headerMap.getNumEntries(), equalTo(entries.size()));
for (Map.Entry<Path, Path> entry : entries.entrySet()) {
assertThat(headerMap.lookup(entry.getKey().toString()), equalTo(entry.getValue().toString()));
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableMap in project buck by facebook.
the class DistBuildStateTest method worksCrossCell.
@Test
public void worksCrossCell() throws IOException, InterruptedException {
ProjectFilesystem parentFs = createJavaOnlyFilesystem("/saving");
Path cell1Root = parentFs.resolve("cell1");
Path cell2Root = parentFs.resolve("cell2");
parentFs.mkdirs(cell1Root);
parentFs.mkdirs(cell2Root);
ProjectFilesystem cell1Filesystem = new ProjectFilesystem(cell1Root);
ProjectFilesystem cell2Filesystem = new ProjectFilesystem(cell2Root);
Config config = new Config(ConfigBuilder.rawFromLines("[cache]", "repository=somerepo", "[repositories]", "cell2 = " + cell2Root.toString()));
BuckConfig buckConfig = new BuckConfig(config, cell1Filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(cell1Root, config));
Cell rootCellWhenSaving = new TestCellBuilder().setFilesystem(cell1Filesystem).setBuckConfig(buckConfig).build();
BuildJobState dump = DistBuildState.dump(new DistBuildCellIndexer(rootCellWhenSaving), emptyActionGraph(), createDefaultCodec(rootCellWhenSaving, Optional.empty()), createCrossCellTargetGraph(cell1Filesystem, cell2Filesystem), ImmutableSet.of(BuildTargetFactory.newInstance(cell1Filesystem.getRootPath(), "//:dummy")));
Cell rootCellWhenLoading = new TestCellBuilder().setFilesystem(createJavaOnlyFilesystem("/loading")).build();
Config localConfig = new Config(ConfigBuilder.rawFromLines("[cache]", "slb_server_pool=http://someserver:8080"));
BuckConfig localBuckConfig = new BuckConfig(localConfig, cell1Filesystem, Architecture.detect(), Platform.detect(), ImmutableMap.<String, String>builder().putAll(System.getenv()).put("envKey", "envValue").build(), new DefaultCellPathResolver(cell1Root, localConfig));
DistBuildState distributedBuildState = DistBuildState.load(Optional.of(localBuckConfig), dump, rootCellWhenLoading, knownBuildRuleTypesFactory);
ImmutableMap<Integer, Cell> cells = distributedBuildState.getCells();
assertThat(cells, Matchers.aMapWithSize(2));
BuckConfig rootCellBuckConfig = cells.get(0).getBuckConfig();
Optional<ImmutableMap<String, String>> cacheSection = rootCellBuckConfig.getSection("cache");
assertTrue(cacheSection.isPresent());
assertTrue(cacheSection.get().containsKey("repository"));
assertThat(cacheSection.get().get("repository"), Matchers.equalTo("somerepo"));
assertThat(cacheSection.get().get("slb_server_pool"), Matchers.equalTo("http://someserver:8080"));
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableMap in project buck by facebook.
the class HalideLibraryDescriptionTest method testCreateBuildRule.
@Test
public void testCreateBuildRule() throws Exception {
// Set up a #halide-compiler rule, then set up a halide_library rule, and
// check that the library rule depends on the compiler rule.
BuildTarget compilerTarget = BuildTargetFactory.newInstance("//:rule").withFlavors(HalideLibraryDescription.HALIDE_COMPILER_FLAVOR);
BuildTarget libTarget = BuildTargetFactory.newInstance("//:rule");
ProjectFilesystem filesystem = new FakeProjectFilesystem();
HalideLibraryBuilder compilerBuilder = new HalideLibraryBuilder(compilerTarget);
compilerBuilder.setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("main.cpp"))));
HalideLibraryBuilder libBuilder = new HalideLibraryBuilder(libTarget);
TargetGraph targetGraph = TargetGraphFactory.newInstance(compilerBuilder.build(), libBuilder.build());
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
HalideLibrary lib = (HalideLibrary) libBuilder.build(resolver, filesystem, targetGraph);
// Check that the library rule has the correct preprocessor input.
CxxPlatform cxxPlatform = CxxLibraryBuilder.createDefaultPlatform();
String headerName = "rule.h";
BuildTarget flavoredLibTarget = libTarget.withFlavors(HalideLibraryDescription.HALIDE_COMPILE_FLAVOR, cxxPlatform.getFlavor());
Path headerPath = HalideCompile.headerOutputPath(flavoredLibTarget, lib.getProjectFilesystem(), Optional.empty());
CxxSymlinkTreeHeaders publicHeaders = (CxxSymlinkTreeHeaders) lib.getCxxPreprocessorInput(cxxPlatform, HeaderVisibility.PUBLIC).getIncludes().get(0);
assertThat(publicHeaders.getIncludeType(), Matchers.equalTo(CxxPreprocessables.IncludeType.SYSTEM));
assertThat(publicHeaders.getNameToPathMap(), Matchers.equalTo(ImmutableMap.<Path, SourcePath>of(Paths.get(headerName), new ExplicitBuildTargetSourcePath(flavoredLibTarget, headerPath))));
// Check that the library rule has the correct native linkable input.
NativeLinkableInput input = lib.getNativeLinkableInput(cxxPlatform, Linker.LinkableDepType.STATIC);
BuildRule buildRule = FluentIterable.from(input.getArgs()).transformAndConcat(arg -> arg.getDeps(new SourcePathRuleFinder(resolver))).get(0);
assertThat(buildRule, is(instanceOf(Archive.class)));
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableMap in project buck by facebook.
the class GroovyBuckConfigTest method byDefaultFindGroovycFromGroovyHome.
@Test
public void byDefaultFindGroovycFromGroovyHome() {
String systemGroovyHome = System.getenv("GROOVY_HOME");
assumeTrue(systemGroovyHome != null);
//noinspection ConstantConditions
ImmutableMap<String, String> environment = ImmutableMap.of("GROOVY_HOME", systemGroovyHome);
ImmutableMap<String, ImmutableMap<String, String>> rawConfig = ImmutableMap.of();
final GroovyBuckConfig groovyBuckConfig = createGroovyConfig(environment, rawConfig);
// it's enough that this doesn't throw.
groovyBuckConfig.getGroovyCompiler();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableMap in project buck by facebook.
the class ParserTest method buildTargetGraphAndGetHashCodes.
private ImmutableMap<BuildTarget, HashCode> buildTargetGraphAndGetHashCodes(Parser parser, BuildTarget... buildTargets) throws Exception {
// Build the target graph so we can access the hash code cache.
ImmutableList<BuildTarget> buildTargetsList = ImmutableList.copyOf(buildTargets);
TargetGraph targetGraph = parser.buildTargetGraph(eventBus, cell, false, executorService, buildTargetsList);
ImmutableMap.Builder<BuildTarget, HashCode> toReturn = ImmutableMap.builder();
for (TargetNode<?, ?> node : targetGraph.getNodes()) {
toReturn.put(node.getBuildTarget(), node.getRawInputsHashCode());
}
return toReturn.build();
}
Aggregations