Search in sources :

Example 1 with VoidOperationException

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.*");
}
Also used : VoidOperationException(com.google.copybara.exception.VoidOperationException) ExplicitReversal(com.google.copybara.transform.ExplicitReversal) Test(org.junit.Test)

Example 2 with VoidOperationException

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();
}
Also used : VoidOperationException(com.google.copybara.exception.VoidOperationException) ExplicitReversal(com.google.copybara.transform.ExplicitReversal) Test(org.junit.Test)

Example 3 with VoidOperationException

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();
}
Also used : VoidOperationException(com.google.copybara.exception.VoidOperationException) Test(org.junit.Test)

Aggregations

VoidOperationException (com.google.copybara.exception.VoidOperationException)3 Test (org.junit.Test)3 ExplicitReversal (com.google.copybara.transform.ExplicitReversal)2