use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class OCamlIntegrationTest method testHelloOcamlBuild.
@Test
public void testHelloOcamlBuild() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
workspace.setUp();
BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//hello_ocaml:hello_ocaml");
BuildTarget binary = createOcamlLinkTarget(target);
BuildTarget lib = BuildTargetFactory.newInstance(workspace.getDestPath(), "//hello_ocaml:ocamllib");
BuildTarget staticLib = createStaticLibraryBuildTarget(lib);
ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, binary, lib, staticLib);
workspace.runBuckCommand("build", target.toString()).assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(staticLib.toString());
workspace.resetBuildLogFile();
// Check that running a build again results in no builds since everything is up to
// date.
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.of(binary, target), buildLog.getAllTargets());
buildLog.assertTargetHadMatchingRuleKey(binary.toString());
buildLog.assertTargetHadMatchingRuleKey(target.toString());
workspace.resetBuildLogFile();
// Update the source file.
workspace.replaceFileContents("hello_ocaml/amodule.ml", "v2", "v3");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetHadMatchingRuleKey(staticLib.toString());
workspace.resetBuildLogFile();
// Update the source file.
workspace.replaceFileContents("hello_ocaml/ocamllib/m1.ml", "print me", "print Me");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(staticLib.toString());
workspace.resetBuildLogFile();
// Update the source file.
workspace.replaceFileContents("hello_ocaml/BUCK", "#INSERT_POINT", "'ocamllib/dummy.ml',");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(staticLib.toString());
workspace.resetBuildLogFile();
BuildTarget lib1 = BuildTargetFactory.newInstance(workspace.getDestPath(), "//hello_ocaml:ocamllib1");
BuildTarget staticLib1 = createStaticLibraryBuildTarget(lib1);
ImmutableSet<BuildTarget> targets1 = ImmutableSet.of(target, binary, lib1, staticLib1);
// We rebuild if lib name changes
workspace.replaceFileContents("hello_ocaml/BUCK", "name = 'ocamllib'", "name = 'ocamllib1'");
workspace.replaceFileContents("hello_ocaml/BUCK", ":ocamllib", ":ocamllib1");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets1));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(staticLib1.toString());
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class OCamlIntegrationTest method testCInteropBuild.
@Test
public void testCInteropBuild() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
workspace.setUp();
BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//ctest:ctest");
BuildTarget binary = createOcamlLinkTarget(target);
ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, binary);
workspace.runBuckCommand("build", target.toString()).assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
workspace.resetBuildLogFile();
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.of(binary, target), buildLog.getAllTargets());
buildLog.assertTargetHadMatchingRuleKey(binary.toString());
buildLog.assertTargetHadMatchingRuleKey(target.toString());
workspace.resetBuildLogFile();
workspace.replaceFileContents("ctest/ctest.c", "NATIVE PLUS", "Native Plus");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
workspace.resetBuildLogFile();
workspace.replaceFileContents("ctest/BUCK", "#INSERTION_POINT", "compiler_flags=['-noassert']");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
workspace.resetBuildLogFile();
workspace.replaceFileContents("ctest/BUCK", "compiler_flags=['-noassert']", "compiler_flags=[]");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
workspace.resetBuildLogFile();
workspace.replaceFileContents("ctest/BUCK", "compiler_flags=[]", "compiler_flags=[]");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertEquals(ImmutableSet.of(binary, target), buildLog.getAllTargets());
buildLog.assertTargetHadMatchingRuleKey(binary.toString());
buildLog.assertTargetHadMatchingRuleKey(target.toString());
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class OCamlIntegrationTest method testGenruleDependency.
@Test
public void testGenruleDependency() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
workspace.setUp();
BuildTarget binary = BuildTargetFactory.newInstance(workspace.getDestPath(), "//generated:binary");
BuildTarget generated = BuildTargetFactory.newInstance(workspace.getDestPath(), "//generated:generated");
ImmutableSet<BuildTarget> targets = ImmutableSet.of(binary, generated);
// Build the binary.
workspace.runBuckCommand("build", binary.toString()).assertSuccess();
// Make sure the generated target is built as well.
BuckBuildLog buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(binary.toString());
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class OCamlIntegrationTest method testPrebuiltLibraryMac.
@Test
@Ignore("Redesign test so it does not depend on compiler/platform-specific binary artifacts.")
public void testPrebuiltLibraryMac() throws IOException {
if (Platform.detect() == Platform.MACOS) {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "ocaml", tmp);
workspace.setUp();
BuildTarget target = BuildTargetFactory.newInstance(workspace.getDestPath(), "//ocaml_ext_mac:ocaml_ext");
BuildTarget binary = createOcamlLinkTarget(target);
BuildTarget bytecode = OcamlBuildRulesGenerator.addBytecodeFlavor(binary);
BuildTarget libplus = BuildTargetFactory.newInstance(workspace.getDestPath(), "//ocaml_ext_mac:plus");
ImmutableSet<BuildTarget> targets = ImmutableSet.of(target, binary, bytecode, libplus);
workspace.runBuckCommand("build", target.toString()).assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
for (BuildTarget t : targets) {
assertTrue(String.format("Expected %s to be built", t.toString()), buildLog.getAllTargets().contains(t));
}
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
workspace.resetBuildLogFile();
workspace.runBuckCommand("build", target.toString()).assertSuccess();
for (BuildTarget t : targets) {
assertTrue(String.format("Expected %s to be built", t.toString()), buildLog.getAllTargets().contains(t));
}
buildLog.assertTargetHadMatchingRuleKey(target.toString());
buildLog.assertTargetHadMatchingRuleKey(binary.toString());
workspace.resetBuildLogFile();
workspace.replaceFileContents("ocaml_ext_mac/BUCK", "libplus_lib", "libplus_lib1");
workspace.runBuckCommand("build", target.toString()).assertSuccess();
buildLog = workspace.getBuildLog();
assertTrue(buildLog.getAllTargets().containsAll(targets));
buildLog.assertTargetBuiltLocally(target.toString());
buildLog.assertTargetBuiltLocally(binary.toString());
}
}
use of com.facebook.buck.testutil.integration.BuckBuildLog in project buck by facebook.
the class AndroidXmlFileIntegrationTest method testEditingStringOnlyBuildsResourceRule.
@Test
public void testEditingStringOnlyBuildsResourceRule() throws IOException {
workspace.replaceFileContents(PATH_TO_STRINGS_XML, "Hello", "Bye");
workspace.resetBuildLogFile();
ProjectWorkspace.ProcessResult result = workspace.runBuckBuild(MAIN_BUILD_TARGET);
result.assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
buildLog.assertTargetBuiltLocally("//res/com/sample/base:base");
buildLog.assertTargetHadMatchingInputRuleKey("//res/com/sample/top:top");
buildLog.assertTargetHadMatchingInputRuleKey("//java/com/sample/lib:lib#dummy_r_dot_java");
buildLog.assertTargetHadMatchingInputRuleKey(MAIN_BUILD_TARGET);
}
Aggregations