Search in sources :

Example 41 with BuckBuildLog

use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.

the class OCamlIntegrationTest method testPrebuiltLibraryBytecodeOnly.

@Test
@Ignore("Redesign test so it does not depend on compiler/platform-specific binary artifacts.")
public void testPrebuiltLibraryBytecodeOnly() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//ocaml_ext_bc:ocaml_ext");
    BuildTarget binary = createOcamlLinkTarget(target);
    BuildTarget bytecode = OcamlBuildRulesGenerator.addBytecodeFlavor(binary);
    BuildTarget libplus = BuildTargetFactory.newInstance(workspace.getDestPath(), "//ocaml_ext_bc:plus");
    ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, bytecode, libplus);
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    assertTrue(buildLog.getAllTargets().containsAll(targets));
    assertFalse(buildLog.getAllTargets().contains(binary));
    buildLog.assertTargetBuiltLocally(target.toString());
    buildLog.assertTargetBuiltLocally(bytecode.toString());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) OcamlRuleBuilder.createStaticLibraryBuildTarget(com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 42 with BuckBuildLog

use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.

the class OCamlIntegrationTest method testConfigWarningsFlags.

@Test
public void testConfigWarningsFlags() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "config_warnings_flags", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//:unused_var");
    BuildTarget binary = createOcamlLinkTarget(target);
    ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, binary);
    workspace.runBuckCommand("build", target.toString()).assertFailure();
    BuckBuildLog buildLog = workspace.getBuildLog();
    assertTrue(buildLog.getAllTargets().containsAll(targets));
    buildLog.assertTargetCanceled(target.toString());
    buildLog.assertTargetCanceled(binary.toString());
    workspace.resetBuildLogFile();
    workspace.replaceFileContents(".buckconfig", "warnings_flags=+a", "");
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(target.toString());
    buildLog.assertTargetBuiltLocally(binary.toString());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) OcamlRuleBuilder.createStaticLibraryBuildTarget(com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Example 43 with BuckBuildLog

use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.

the class OCamlIntegrationTest method testConfigInteropIncludes.

@Test
public void testConfigInteropIncludes() throws IOException, InterruptedException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "config_interop_includes", tmp);
    workspace.setUp();
    Path ocamlc = new ExecutableFinder(Platform.detect()).getExecutable(Paths.get("ocamlc"), ImmutableMap.copyOf(System.getenv()));
    ProcessExecutor.Result result = workspace.runCommand(ocamlc.toString(), "-where");
    assertEquals(0, result.getExitCode());
    String stdlibPath = result.getStdout().get();
    BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//:test");
    BuildTarget binary = createOcamlLinkTarget(target);
    ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, binary);
    // Points somewhere with no stdlib in it, so fails to find Pervasives
    workspace.runBuckCommand("build", target.toString()).assertFailure();
    BuckBuildLog buildLog = workspace.getBuildLog();
    assertThat(buildLog.getAllTargets(), Matchers.hasItems(targets.toArray(new BuildTarget[0])));
    buildLog.assertTargetCanceled(target.toString());
    buildLog.assertTargetCanceled(binary.toString());
    workspace.resetBuildLogFile();
    // Point to the real stdlib (from `ocamlc -where`)
    workspace.replaceFileContents(".buckconfig", "interop.includes=lib", "interop.includes=" + stdlibPath);
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(target.toString());
    buildLog.assertTargetBuiltLocally(binary.toString());
    workspace.resetBuildLogFile();
    // Remove the config, should default to a valid place
    workspace.replaceFileContents(".buckconfig", "interop.includes=" + stdlibPath, "");
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(target.toString());
    buildLog.assertTargetBuiltLocally(binary.toString());
}
Also used : Path(java.nio.file.Path) ExecutableFinder(com.facebook.buck.io.ExecutableFinder) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) OcamlRuleBuilder.createStaticLibraryBuildTarget(com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Test(org.junit.Test)

Example 44 with BuckBuildLog

use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.

the class OCamlIntegrationTest method testCppLibraryDependency.

@Test
public void testCppLibraryDependency() throws IOException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
    workspace.setUp();
    BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//clib:clib");
    BuildTarget binary = createOcamlLinkTarget(target);
    BuildTarget libplus = BuildTargetFactory.newInstance(workspace.getDestPath(), "//clib:plus");
    BuildTarget libplusStatic = createStaticLibraryBuildTarget(libplus);
    BuildTarget cclib = BuildTargetFactory.newInstance(workspace.getDestPath(), "//clib:cc");
    CxxPlatform cxxPlatform = CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().build()));
    CxxSourceRuleFactory cxxSourceRuleFactory = CxxSourceRuleFactoryHelper.of(workspace.getDestPath(), cclib, cxxPlatform);
    BuildTarget cclibbin = CxxDescriptionEnhancer.createStaticLibraryBuildTarget(cclib, cxxPlatform.getFlavor(), CxxSourceRuleFactory.PicType.PDC);
    String sourceName = "cc/cc.cpp";
    BuildTarget ccObj = cxxSourceRuleFactory.createCompileBuildTarget(sourceName);
    BuildTarget headerSymlinkTreeTarget = CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(cclib, HeaderVisibility.PRIVATE, cxxPlatform.getFlavor());
    BuildTarget exportedHeaderSymlinkTreeTarget = CxxDescriptionEnhancer.createHeaderSymlinkTreeTarget(cclib, HeaderVisibility.PUBLIC, CxxPlatformUtils.getHeaderModeForDefaultPlatform(tmp.getRoot()).getFlavor());
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(binary.toString());
    buildLog.assertTargetBuiltLocally(libplusStatic.toString());
    buildLog.assertTargetBuiltLocally(cclibbin.toString());
    buildLog.assertTargetBuiltLocally(ccObj.toString());
    buildLog.assertTargetBuiltLocally(headerSymlinkTreeTarget.toString());
    buildLog.assertTargetBuiltLocally(exportedHeaderSymlinkTreeTarget.toString());
    workspace.resetBuildLogFile();
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetHadMatchingRuleKey(binary.toString());
    buildLog.assertTargetHadMatchingRuleKey(target.toString());
    workspace.resetBuildLogFile();
    workspace.replaceFileContents("clib/cc/cc.cpp", "Hi there", "hi there");
    workspace.runBuckCommand("build", target.toString()).assertSuccess();
    buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally(binary.toString());
    buildLog.assertTargetBuiltLocally(libplusStatic.toString());
    buildLog.assertTargetBuiltLocally(cclibbin.toString());
    buildLog.assertTargetBuiltLocally(ccObj.toString());
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) CxxPlatform(com.facebook.buck.cxx.CxxPlatform) CxxSourceRuleFactory(com.facebook.buck.cxx.CxxSourceRuleFactory) OcamlRuleBuilder.createStaticLibraryBuildTarget(com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget) BuildTarget(com.facebook.buck.model.BuildTarget) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) CxxBuckConfig(com.facebook.buck.cxx.CxxBuckConfig) Test(org.junit.Test)

Example 45 with BuckBuildLog

use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.

the class RustBinaryIntegrationTest method simpleBinaryWarnings.

@Test
public void simpleBinaryWarnings() throws IOException, InterruptedException {
    ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple_binary", tmp);
    workspace.setUp();
    assertThat(workspace.runBuckBuild("//:xyzzy").assertSuccess().getStderr(), Matchers.allOf(Matchers.containsString("warning: constant item is never used: `foo`, #[warn(dead_code)] on by default"), Matchers.containsString("warning: constant `foo` should have an upper case name such as `FOO`,")));
    BuckBuildLog buildLog = workspace.getBuildLog();
    buildLog.assertTargetBuiltLocally("//:xyzzy");
    workspace.resetBuildLogFile();
}
Also used : ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) BuckBuildLog(com.facebook.buck.testutil.integration.BuckBuildLog) Test(org.junit.Test)

Aggregations

BuckBuildLog (com.facebook.buck.testutil.integration.BuckBuildLog)88 Test (org.junit.Test)88 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)53 BuildTarget (com.facebook.buck.model.BuildTarget)32 OcamlRuleBuilder.createStaticLibraryBuildTarget (com.facebook.buck.ocaml.OcamlRuleBuilder.createStaticLibraryBuildTarget)10 ProcessExecutor (com.facebook.buck.util.ProcessExecutor)9 Path (java.nio.file.Path)8 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)7 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)2 Sha1HashCode (com.facebook.buck.util.sha1.Sha1HashCode)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)2 NSString (com.dd.plist.NSString)1 AssumeAndroidPlatform (com.facebook.buck.android.AssumeAndroidPlatform)1 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 CxxBuckConfig (com.facebook.buck.cxx.CxxBuckConfig)1 CxxFlavorSanitizer.sanitize (com.facebook.buck.cxx.CxxFlavorSanitizer.sanitize)1 CxxPlatform (com.facebook.buck.cxx.CxxPlatform)1