@Test public void ndkCxxPlatforms() throws IOException { AssumeAndroidPlatform.assumeNdkIsAvailable(); ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "simple", tmp); workspace.setUp(); workspace.runBuckCommand("build", "//foo:simple#android-arm").assertSuccess(); workspace.runBuckCommand("build", "//foo:simple#android-armv7").assertSuccess(); workspace.runBuckCommand("build", "//foo:simple#android-x86").assertSuccess(); }
@Test public void whenActivityBuckFileRemovedThenRebuildFails() throws IOException, InterruptedException { AssumeAndroidPlatform.assumeSdkIsAvailable(); final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp); workspace.setUp(); workspace.runBuckdCommand("build", "//java/com/example/activity:activity").assertSuccess(); String fileName = "java/com/example/activity/BUCK"; Files.delete(workspace.getPath(fileName)); workspace.runBuckdCommand("build", "//java/com/example/activity:activity").assertFailure(); }
@Test public void whenAppBuckFileRemovedThenRebuildFails() throws IOException, InterruptedException { AssumeAndroidPlatform.assumeSdkIsAvailable(); final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp); workspace.setUp(); ProcessResult result = workspace.runBuckdCommand("build", "app"); result.assertSuccess(); String fileName = "apps/myapp/BUCK"; Files.delete(workspace.getPath(fileName)); workspace.runBuckdCommand("build", "app").assertFailure(); }
@Test public void whenSourceInputInvalidatedThenRebuildFails() throws IOException, InterruptedException { AssumeAndroidPlatform.assumeSdkIsAvailable(); final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp); workspace.setUp(); workspace.runBuckdCommand("build", "//java/com/example/activity:activity").assertSuccess(); String fileName = "java/com/example/activity/MyFirstActivity.java"; Files.delete(workspace.getPath(fileName)); thrown.expect(HumanReadableException.class); thrown.expectMessage(containsString("MyFirstActivity.java")); workspace.runBuckdCommand("build", "//java/com/example/activity:activity"); }
@Test public void whenAppBuckFileInvalidatedThenRebuildFails() throws IOException, InterruptedException { AssumeAndroidPlatform.assumeSdkIsAvailable(); final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp); workspace.setUp(); workspace.runBuckdCommand("build", "app").assertSuccess(); String fileName = "apps/myapp/BUCK"; Files.write(workspace.getPath(fileName), "Some Illegal Python".getBytes(Charsets.US_ASCII)); ProcessResult result = workspace.runBuckdCommand("build", "app"); assertThat( "Failure should be due to syntax error.", result.getStderr(), containsString("SyntaxError: invalid syntax")); result.assertFailure(); }
@Test public void whenBuckBuiltTwiceLogIsPresent() throws IOException, InterruptedException { AssumeAndroidPlatform.assumeSdkIsAvailable(); final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp); workspace.setUp(); workspace.runBuckdCommand("build", "//java/com/example/activity:activity").assertSuccess(); Path buildLogFile = workspace.getPath("buck-out/bin/build.log"); assertTrue(Files.isRegularFile(buildLogFile)); Files.delete(buildLogFile); ProcessResult rebuild = workspace.runBuckdCommand("build", "//java/com/example/activity:activity"); rebuild.assertSuccess(); buildLogFile = workspace.getPath("buck-out/bin/build.log"); assertTrue(Files.isRegularFile(buildLogFile)); }
@Test public void whenSourceInputRemovedThenRebuildFails() throws IOException, InterruptedException { AssumeAndroidPlatform.assumeNdkIsAvailable(); final ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "file_watching", tmp); workspace.setUp(); workspace.runBuckdCommand("build", "//java/com/example/activity:activity").assertSuccess(); String fileName = "java/com/example/activity/MyFirstActivity.java"; Files.delete(workspace.getPath(fileName)); try { workspace.runBuckdCommand("build", "//java/com/example/activity:activity"); fail("Should have thrown HumanReadableException."); } catch (java.lang.RuntimeException e) { assertThat( "Failure should have been due to file removal.", e.getMessage(), containsString("MyFirstActivity.java")); } }