Search in sources :

Example 36 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class CopyNativeLibrariesTest method createAndroidBinaryRuleAndTestCopyNativeLibraryCommand.

private void createAndroidBinaryRuleAndTestCopyNativeLibraryCommand(ImmutableSet<TargetCpuType> cpuFilters, Path sourceDir, Path destinationDir, ImmutableList<String> expectedCommandDescriptions) {
    // Invoke copyNativeLibrary to populate the steps.
    ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
    CopyNativeLibraries.copyNativeLibrary(new FakeProjectFilesystem(), sourceDir, destinationDir, cpuFilters, stepsBuilder);
    ImmutableList<Step> steps = stepsBuilder.build();
    assertEquals(steps.size(), expectedCommandDescriptions.size());
    ExecutionContext context = TestExecutionContext.newInstance();
    for (int i = 0; i < steps.size(); ++i) {
        String description = steps.get(i).getDescription(context);
        assertEquals(expectedCommandDescriptions.get(i), description);
    }
}
Also used : ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) ImmutableList(com.google.common.collect.ImmutableList) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Step(com.facebook.buck.step.Step)

Example 37 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class ProGuardObfuscateStepTest method testAdditionalLibraryJarsParameterFormatting.

@Test
public void testAdditionalLibraryJarsParameterFormatting() {
    Path cwd = Paths.get("root");
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    ProGuardObfuscateStep.create(JavaCompilationConstants.DEFAULT_JAVA_OPTIONS.getJavaRuntimeLauncher(), new FakeProjectFilesystem(), /* proguardJarOverride */
    Optional.empty(), "1024M", Optional.empty(), Paths.get("generated/proguard.txt"), /* customProguardConfigs */
    ImmutableSet.of(), ProGuardObfuscateStep.SdkProguardType.DEFAULT, /* optimizationPasses */
    Optional.empty(), /* proguardJvmArgs */
    Optional.empty(), /* inputAndOutputEntries */
    ImmutableMap.of(), /* additionalLibraryJarsForProguard */
    ImmutableSet.of(Paths.get("myfavorite.jar"), Paths.get("another.jar")), Paths.get("proguard-directory"), new FakeBuildableContext(), false, steps);
    ProGuardObfuscateStep.CommandLineHelperStep commandLineHelperStep = (ProGuardObfuscateStep.CommandLineHelperStep) steps.build().get(1);
    ImmutableList<String> parameters = commandLineHelperStep.getParameters(executionContext, cwd);
    int libraryJarsArgIndex = parameters.indexOf("-libraryjars");
    int libraryJarsValueIndex = parameters.indexOf("myfavorite.jar" + File.pathSeparatorChar + "another.jar");
    assertNotEquals(-1, libraryJarsArgIndex);
    assertEquals(libraryJarsValueIndex, libraryJarsArgIndex + 1);
}
Also used : Path(java.nio.file.Path) FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) ImmutableList(com.google.common.collect.ImmutableList) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Step(com.facebook.buck.step.Step) Test(org.junit.Test)

Example 38 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class ProGuardObfuscateStepTest method testProguardJvmArgs.

@Test
public void testProguardJvmArgs() {
    List<String> proguardJvmArgs = Arrays.asList("-Dparam1=value1", "-Dparam2=value2");
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    ProGuardObfuscateStep.create(JavaCompilationConstants.DEFAULT_JAVA_OPTIONS.getJavaRuntimeLauncher(), new FakeProjectFilesystem(), /* proguardJarOverride */
    Optional.empty(), "1024M", Optional.empty(), Paths.get("generated/proguard.txt"), /* customProguardConfigs */
    ImmutableSet.of(), ProGuardObfuscateStep.SdkProguardType.DEFAULT, /* optimizationPasses */
    Optional.empty(), Optional.of(proguardJvmArgs), /* inputAndOutputEntries */
    ImmutableMap.of(), /* additionalLibraryJarsForProguard */
    ImmutableSet.of(Paths.get("myfavorite.jar"), Paths.get("another.jar")), Paths.get("proguard-directory"), new FakeBuildableContext(), false, steps);
    ProGuardObfuscateStep proguardStep = (ProGuardObfuscateStep) steps.build().get(2);
    ImmutableList<String> parameters = proguardStep.getShellCommandInternal(executionContext);
    for (String s : proguardJvmArgs) {
        assertNotEquals(-1, parameters.indexOf(s));
    }
}
Also used : FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) ImmutableList(com.google.common.collect.ImmutableList) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Step(com.facebook.buck.step.Step) Test(org.junit.Test)

Example 39 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class ProjectGeneratorTest method testCxxLibraryExportedPlatformFlags.

@Test
public void testCxxLibraryExportedPlatformFlags() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> node = new CxxLibraryBuilder(buildTarget).setExportedPlatformPreprocessorFlags(PatternMatchedCollection.<ImmutableList<String>>builder().add(Pattern.compile("iphone.*"), ImmutableList.of("-fbar-iphone")).build()).setExportedPlatformLinkerFlags(PatternMatchedCollection.<ImmutableList<StringWithMacros>>builder().add(Pattern.compile("macosx.*"), ImmutableList.of(StringWithMacrosUtils.format("-lbaz-macosx"))).build()).build();
    BuildTarget dependentBuildTarget = BuildTarget.builder(rootPath, "//foo", "bin").build();
    TargetNode<?, ?> dependentNode = AppleBinaryBuilder.createBuilder(dependentBuildTarget).setPlatformCompilerFlags(PatternMatchedCollection.<ImmutableList<String>>builder().add(Pattern.compile("iphone.*"), ImmutableList.of("-ffoo-iphone")).build()).setDeps(ImmutableSortedSet.of(buildTarget)).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node, dependentNode), ImmutableSet.of());
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
    assertHasConfigurations(target, "Debug", "Release", "Profile");
    ImmutableMap<String, String> settings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, buildTarget, target, "Debug");
    assertEquals("-Wno-deprecated -Wno-conversion -fbar-iphone -Wno-deprecated -Wno-conversion -fbar-iphone", settings.get("OTHER_CFLAGS[sdk=*iphone*]"));
    assertEquals("-Wundeclared-selector -Wno-objc-designated-initializers -fbar-iphone " + "-Wundeclared-selector -Wno-objc-designated-initializers -fbar-iphone", settings.get("OTHER_CPLUSPLUSFLAGS[sdk=*iphone*]"));
    assertEquals(null, settings.get("OTHER_LDFLAGS[sdk=*iphone*]"));
    PBXTarget dependentTarget = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:bin");
    assertHasConfigurations(target, "Debug", "Release", "Profile");
    ImmutableMap<String, String> dependentSettings = ProjectGeneratorTestUtils.getBuildSettings(projectFilesystem, dependentBuildTarget, dependentTarget, "Debug");
    assertEquals("-Wno-deprecated -Wno-conversion -ffoo-iphone -fbar-iphone " + "-Wno-deprecated -Wno-conversion -ffoo-iphone -fbar-iphone", dependentSettings.get("OTHER_CFLAGS[sdk=*iphone*]"));
    assertEquals("-Wundeclared-selector -Wno-objc-designated-initializers -ffoo-iphone -fbar-iphone " + "-Wundeclared-selector -Wno-objc-designated-initializers -ffoo-iphone -fbar-iphone", dependentSettings.get("OTHER_CPLUSPLUSFLAGS[sdk=*iphone*]"));
    assertEquals(null, dependentSettings.get("OTHER_LDFLAGS[sdk=*iphone*]"));
}
Also used : PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) CxxLibraryBuilder(com.facebook.buck.cxx.CxxLibraryBuilder) ImmutableList(com.google.common.collect.ImmutableList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) Test(org.junit.Test)

Example 40 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project druid by druid-io.

the class SpecificSegmentQueryRunnerTest method testRetry.

@Test
public void testRetry() throws Exception {
    final ObjectMapper mapper = new DefaultObjectMapper();
    SegmentDescriptor descriptor = new SegmentDescriptor(new Interval("2012-01-01T00:00:00Z/P1D"), "version", 0);
    final SpecificSegmentQueryRunner queryRunner = new SpecificSegmentQueryRunner(new QueryRunner() {

        @Override
        public Sequence run(Query query, Map responseContext) {
            return new Sequence() {

                @Override
                public Object accumulate(Object initValue, Accumulator accumulator) {
                    throw new SegmentMissingException("FAILSAUCE");
                }

                @Override
                public Yielder<Object> toYielder(Object initValue, YieldingAccumulator accumulator) {
                    throw new SegmentMissingException("FAILSAUCE");
                }
            };
        }
    }, new SpecificSegmentSpec(descriptor));
    // from accumulate
    Map<String, Object> responseContext = Maps.newHashMap();
    TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("foo").granularity(Granularities.ALL).intervals(ImmutableList.of(new Interval("2012-01-01T00:00:00Z/P1D"))).aggregators(ImmutableList.<AggregatorFactory>of(new CountAggregatorFactory("rows"))).build();
    Sequence results = queryRunner.run(query, responseContext);
    Sequences.toList(results, Lists.newArrayList());
    validate(mapper, descriptor, responseContext);
    // from toYielder
    responseContext = Maps.newHashMap();
    results = queryRunner.run(query, responseContext);
    results.toYielder(null, new YieldingAccumulator() {

        final List lists = Lists.newArrayList();

        @Override
        public Object accumulate(Object accumulated, Object in) {
            lists.add(in);
            return in;
        }
    });
    validate(mapper, descriptor, responseContext);
}
Also used : Accumulator(io.druid.java.util.common.guava.Accumulator) YieldingAccumulator(io.druid.java.util.common.guava.YieldingAccumulator) Yielder(io.druid.java.util.common.guava.Yielder) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) Query(io.druid.query.Query) TimeseriesQuery(io.druid.query.timeseries.TimeseriesQuery) SegmentMissingException(io.druid.segment.SegmentMissingException) Sequence(io.druid.java.util.common.guava.Sequence) YieldingAccumulator(io.druid.java.util.common.guava.YieldingAccumulator) AggregatorFactory(io.druid.query.aggregation.AggregatorFactory) CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) QueryRunner(io.druid.query.QueryRunner) CountAggregatorFactory(io.druid.query.aggregation.CountAggregatorFactory) SegmentDescriptor(io.druid.query.SegmentDescriptor) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Map(java.util.Map) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1079 List (java.util.List)293 ArrayList (java.util.ArrayList)169 Test (org.junit.Test)161 Map (java.util.Map)152 Path (java.nio.file.Path)149 ImmutableMap (com.google.common.collect.ImmutableMap)127 IOException (java.io.IOException)112 Set (java.util.Set)99 ImmutableSet (com.google.common.collect.ImmutableSet)98 SourcePath (com.facebook.buck.rules.SourcePath)91 Optional (java.util.Optional)89 HashMap (java.util.HashMap)85 Step (com.facebook.buck.step.Step)76 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)71 Collectors (java.util.stream.Collectors)62 File (java.io.File)58 HashSet (java.util.HashSet)58 Nullable (javax.annotation.Nullable)54 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)52