use of java.util.Optional in project buck by facebook.
the class ProvisioningProfileCopyStepTest method shouldSetProvisioningProfileFutureWhenStepIsRun.
@Test
public void shouldSetProvisioningProfileFutureWhenStepIsRun() throws Exception {
assumeTrue(Platform.detect() == Platform.MACOS);
ProvisioningProfileCopyStep step = new ProvisioningProfileCopyStep(projectFilesystem, testdataDir.resolve("Info.plist"), ApplePlatform.IPHONEOS, Optional.empty(), Optional.empty(), ProvisioningProfileStore.fromSearchPath(new DefaultProcessExecutor(new TestConsole()), ProvisioningProfileStore.DEFAULT_READ_COMMAND, testdataDir), outputFile, xcentFile, codeSignIdentityStore, Optional.empty());
Future<Optional<ProvisioningProfileMetadata>> profileFuture = step.getSelectedProvisioningProfileFuture();
step.execute(executionContext);
assertTrue(profileFuture.isDone());
assertNotNull(profileFuture.get());
}
use of java.util.Optional in project buck by facebook.
the class ProjectGeneratorTest method assertHasSingletonSourcesPhaseWithSourcesAndFlags.
private void assertHasSingletonSourcesPhaseWithSourcesAndFlags(PBXTarget target, ImmutableMap<String, Optional<String>> sourcesAndFlags) {
PBXSourcesBuildPhase sourcesBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXSourcesBuildPhase.class);
assertEquals("Sources build phase should have correct number of sources", sourcesAndFlags.size(), sourcesBuildPhase.getFiles().size());
// map keys to absolute paths
ImmutableMap.Builder<String, Optional<String>> absolutePathFlagMapBuilder = ImmutableMap.builder();
for (Map.Entry<String, Optional<String>> name : sourcesAndFlags.entrySet()) {
absolutePathFlagMapBuilder.put(projectFilesystem.getRootPath().resolve(name.getKey()).toAbsolutePath().normalize().toString(), name.getValue());
}
ImmutableMap<String, Optional<String>> absolutePathFlagMap = absolutePathFlagMapBuilder.build();
for (PBXBuildFile file : sourcesBuildPhase.getFiles()) {
String filePath = assertFileRefIsRelativeAndResolvePath(file.getFileRef());
Optional<String> flags = absolutePathFlagMap.get(filePath);
assertNotNull(String.format("Unexpected file ref '%s' found", filePath), flags);
if (flags.isPresent()) {
assertTrue("Build file should have settings dictionary", file.getSettings().isPresent());
NSDictionary buildFileSettings = file.getSettings().get();
NSString compilerFlags = (NSString) buildFileSettings.get("COMPILER_FLAGS");
assertNotNull("Build file settings should have COMPILER_FLAGS entry", compilerFlags);
assertEquals("Build file settings should be expected value", flags.get(), compilerFlags.getContent());
} else {
assertFalse("Build file should not have settings dictionary", file.getSettings().isPresent());
}
}
}
use of java.util.Optional in project buck by facebook.
the class BuildCommandTest method setUp.
@Before
public void setUp() {
BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
resolver = new SourcePathResolver(new SourcePathRuleFinder(ruleResolver));
LinkedHashMap<BuildRule, Optional<BuildResult>> ruleToResult = new LinkedHashMap<>();
FakeBuildRule rule1 = new FakeBuildRule(BuildTargetFactory.newInstance("//fake:rule1"), resolver);
rule1.setOutputFile("buck-out/gen/fake/rule1.txt");
ruleResolver.addToIndex(rule1);
ruleToResult.put(rule1, Optional.of(BuildResult.success(rule1, BUILT_LOCALLY, CacheResult.miss())));
BuildRule rule2 = new FakeBuildRule(BuildTargetFactory.newInstance("//fake:rule2"), resolver);
BuildResult rule2Failure = BuildResult.failure(rule2, new RuntimeException("some"));
ruleToResult.put(rule2, Optional.of(rule2Failure));
ruleResolver.addToIndex(rule2);
BuildRule rule3 = new FakeBuildRule(BuildTargetFactory.newInstance("//fake:rule3"), resolver);
ruleToResult.put(rule3, Optional.of(BuildResult.success(rule3, FETCHED_FROM_CACHE, CacheResult.hit("dir"))));
ruleResolver.addToIndex(rule3);
BuildRule rule4 = new FakeBuildRule(BuildTargetFactory.newInstance("//fake:rule4"), resolver);
ruleToResult.put(rule4, Optional.empty());
ruleResolver.addToIndex(rule4);
buildExecutionResult = BuildExecutionResult.builder().setResults(ruleToResult).setFailures(ImmutableSet.of(rule2Failure)).build();
}
use of java.util.Optional in project buck by facebook.
the class DefaultJavaLibraryTest method createDefaultJavaLibraryRuleWithAbiKey.
private BuildRule createDefaultJavaLibraryRuleWithAbiKey(BuildTarget buildTarget, ImmutableSet<String> srcs, ImmutableSortedSet<BuildRule> deps, ImmutableSortedSet<BuildRule> exportedDeps, Optional<AbstractJavacOptions.SpoolMode> spoolMode, ImmutableList<String> postprocessClassesCommands) {
ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
ImmutableSortedSet<? extends SourcePath> srcsAsPaths = FluentIterable.from(srcs).transform(Paths::get).transform(p -> new PathSourcePath(projectFilesystem, p)).toSortedSet(Ordering.natural());
BuildRuleParams buildRuleParams = new FakeBuildRuleParamsBuilder(buildTarget).setDeclaredDeps(ImmutableSortedSet.copyOf(deps)).build();
JavacOptions javacOptions = spoolMode.isPresent() ? JavacOptions.builder(DEFAULT_JAVAC_OPTIONS).setSpoolMode(spoolMode.get()).build() : DEFAULT_JAVAC_OPTIONS;
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
DefaultJavaLibrary defaultJavaLibrary = new DefaultJavaLibrary(buildRuleParams, new SourcePathResolver(ruleFinder), ruleFinder, srcsAsPaths, /* resources */
ImmutableSet.of(), javacOptions.getGeneratedSourceFolderName(), /* proguardConfig */
Optional.empty(), postprocessClassesCommands, exportedDeps, /* providedDeps */
ImmutableSortedSet.of(), ImmutableSortedSet.of(), javacOptions.trackClassUsage(), /* additionalClasspathEntries */
ImmutableSet.of(), new JavacToJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY), /* resourcesRoot */
Optional.empty(), /* manifest file */
Optional.empty(), /* mavenCoords */
Optional.empty(), /* tests */
ImmutableSortedSet.of(), /* classesToRemoveFromJar */
ImmutableSet.of()) {
};
ruleResolver.addToIndex(defaultJavaLibrary);
return defaultJavaLibrary;
}
use of java.util.Optional in project buck by facebook.
the class StringifyAlterRuleKeyTest method findAbsolutePathsInListOfOptionals.
@Test
public void findAbsolutePathsInListOfOptionals() {
Path path1 = MorePathsForTests.rootRelativePath("some/thing");
Path path2 = Paths.get("some/thing");
List<Optional<Path>> input = ImmutableList.of(Optional.empty(), Optional.of(path2), Optional.empty(), Optional.of(path1));
Assert.assertEquals(ImmutableSet.of(path1), ImmutableSet.copyOf(StringifyAlterRuleKey.findAbsolutePaths(input)));
}
Aggregations