use of com.google.copybara.exception.VoidOperationException in project copybara by google.
the class CoreTransformTest method testSecondLayerTransformWithInnerAndOuterNoop.
@Test
public void testSecondLayerTransformWithInnerAndOuterNoop() throws ValidationException, IOException {
String secondLayerTransform = "core.transform([\n" + " core.replace(\n" + " before = 'not found',\n" + " after = 'not important',\n" + " ),\n" + "], ignore_noop=False),\n";
ExplicitReversal t = skylark.eval("x", "x=" + "core.transform([\n" + " core.replace(\n" + " before = 'foo',\n" + " after = 'bar',\n" + " )," + secondLayerTransform + " core.replace(\n" + " before = 'bar',\n" + " after = 'baz',\n" + " )\n" + "], ignore_noop=True)");
Files.write(checkoutDir.resolve("file.txt"), "foo".getBytes(UTF_8));
VoidOperationException e = assertThrows(VoidOperationException.class, () -> t.transform(TransformWorks.of(checkoutDir, "msg", console)));
assertThat(e).hasMessageThat().containsMatch(".*was a no-op because it didn't " + "change any of the matching files.*");
}
use of com.google.copybara.exception.VoidOperationException in project copybara by google.
the class CoreTransformTest method testOneLayerTransformWithNoNoop.
@Test
public void testOneLayerTransformWithNoNoop() throws ValidationException, IOException {
ExplicitReversal t = skylark.eval("x", "x=" + "core.transform([\n" + " core.replace(\n" + " before = 'not found',\n" + " after = 'not important',\n" + " ),\n" + " core.replace(\n" + " before = 'foo',\n" + " after = 'bar',\n" + " ),\n" + "], ignore_noop = False)");
Files.write(checkoutDir.resolve("file.txt"), "foo".getBytes(UTF_8));
VoidOperationException e = assertThrows(VoidOperationException.class, () -> t.transform(TransformWorks.of(checkoutDir, "msg", console)));
assertThat(e).hasMessageThat().containsMatch(".*was a no-op because it didn't " + "change any of the matching files.*");
assertThatPath(checkoutDir).containsFile("file.txt", "foo").containsNoMoreFiles();
}
use of com.google.copybara.exception.VoidOperationException in project copybara by google.
the class WorkflowTest method testNoopGroupDefault.
@Test
public void testNoopGroupDefault() throws Exception {
options.workflowOptions.ignoreNoop = false;
transformations = ImmutableList.of("" + " core.transform(" + " transformations = [" + " core.replace(" + " before = 'foo'," + " after = 'bar'," + " )" + " ]," + " )");
VoidOperationException e = assertThrows(VoidOperationException.class, () -> workflow().run(workdir, ImmutableList.of(HEAD)));
assertThat(e.getMessage().contains("Use --ignore-noop if you want to ignore this error")).isTrue();
}
Aggregations