Search in sources :

Example 16 with ExplicitReversal

use of com.google.copybara.transform.ExplicitReversal in project copybara by google.

the class BuildozerModifyTest method testKeepGoing.

/**
 * Here we test that if we join buildozer transformations, we use buildozer -k, so that it
 * keeps going if one of them fails to find a target. Otherwise the effect of bundling many
 * buildozer transformations will be visible to our users when using --ignore-noop
 */
@Test
public void testKeepGoing() throws Exception {
    // Explicit just in case default changes
    options.workflowOptions.noTransformationJoin = false;
    options.workflowOptions.ignoreNoop = true;
    ExplicitReversal modify = skylark.eval("m", "m = " + "core.transform([\n" + "     buildozer.modify(\n" + "       target = ['foo/bar:idontexist'],\n" + "       commands = [ buildozer.cmd('set config \"test\"')],\n" + "     ),\n" + "     buildozer.modify(\n" + "       target = ['foo/bar:*'],\n" + "       commands = [ buildozer.cmd('set other \"test\"')],\n" + "     ),\n" + "  ], reversal = [])");
    Files.createDirectories(checkoutDir.resolve("foo/bar"));
    String original = "proto_library(name = 'baz')\n";
    Files.write(checkoutDir.resolve("foo/bar/BUILD"), original.getBytes(UTF_8));
    transform(modify);
    assertThatPath(checkoutDir).containsFile("foo/bar/BUILD", "" + "proto_library(\n" + "    name = \"baz\",\n" + "    other = \"test\",\n" + ")\n");
}
Also used : ExplicitReversal(com.google.copybara.transform.ExplicitReversal) Test(org.junit.Test)

Aggregations

ExplicitReversal (com.google.copybara.transform.ExplicitReversal)16 Test (org.junit.Test)14 VoidOperationException (com.google.copybara.exception.VoidOperationException)2 DocDefault (com.google.copybara.doc.annotations.DocDefault)1 NonReversibleValidationException (com.google.copybara.exception.NonReversibleValidationException)1 Sequence (com.google.copybara.transform.Sequence)1 SkylarkTransformation (com.google.copybara.transform.SkylarkTransformation)1 Transformations.toTransformation (com.google.copybara.transform.Transformations.toTransformation)1 TestingConsole (com.google.copybara.util.console.testing.TestingConsole)1 StarlarkMethod (net.starlark.java.annot.StarlarkMethod)1