use of com.google.copybara.transform.ExplicitReversal in project copybara by google.
the class CoreTransformTest method testOneLayerTransformWithNoop_usingNoopBehavior_noopIfAllNoop.
@Test
public void testOneLayerTransformWithNoop_usingNoopBehavior_noopIfAllNoop() throws Exception {
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" + "], noop_behavior = 'NOOP_IF_ALL_NOOP')");
Files.write(checkoutDir.resolve("file.txt"), "foo".getBytes(UTF_8));
t.transform(TransformWorks.of(checkoutDir, "msg", console));
console.assertThat().onceInLog(MessageType.WARNING, ".*NOOP.*");
assertThatPath(checkoutDir).containsFile("file.txt", "bar").containsNoMoreFiles();
}
use of com.google.copybara.transform.ExplicitReversal 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.transform.ExplicitReversal in project copybara by google.
the class CoreTransformTest method testOneLayerTransformWithNoop_usingNoopBehavior_ignoreNoop.
@Test
public void testOneLayerTransformWithNoop_usingNoopBehavior_ignoreNoop() throws Exception {
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" + "], noop_behavior = 'IGNORE_NOOP')");
Files.write(checkoutDir.resolve("file.txt"), "foo".getBytes(UTF_8));
t.transform(TransformWorks.of(checkoutDir, "msg", console));
console.assertThat().onceInLog(MessageType.WARNING, ".*NOOP.*");
assertThatPath(checkoutDir).containsFile("file.txt", "bar").containsNoMoreFiles();
}
use of com.google.copybara.transform.ExplicitReversal in project copybara by google.
the class CoreTransformTest method testSecondLayerTransformWithOuterNoop.
@Test
public void testSecondLayerTransformWithOuterNoop() throws Exception {
String secondLayerTransform = "core.transform([\n" + " core.replace(\n" + " before = 'not found',\n" + " after = 'not important',\n" + " ),\n" + "]),\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));
t.transform(TransformWorks.of(checkoutDir, "msg", console));
assertThatPath(checkoutDir).containsFile("file.txt", "baz").containsNoMoreFiles();
console.assertThat().onceInLog(MessageType.WARNING, ".*NOOP.*");
}
use of com.google.copybara.transform.ExplicitReversal in project copybara by google.
the class CoreTransformTest method testSecondLayerWithInnerNoop.
@Test
public void testSecondLayerWithInnerNoop() throws Exception {
String secondLayerTransform = "core.transform([\n" + " core.replace(\n" + " before = 'not found',\n" + " after = 'not important',\n" + " ),\n" + "]," + "ignore_noop=True),";
ExplicitReversal t = skylark.eval("x", "x=" + "core.transform([\n" + " core.replace(\n" + " before = 'foo',\n" + " after = 'bar',\n" + " ),\n" + secondLayerTransform + " core.replace(\n" + " before = 'bar',\n" + " after = 'baz',\n" + " )\n" + "], ignore_noop=False)");
Files.write(checkoutDir.resolve("file.txt"), "foo".getBytes(UTF_8));
t.transform(TransformWorks.of(checkoutDir, "msg", console));
assertThatPath(checkoutDir).containsFile("file.txt", "baz").containsNoMoreFiles();
console.assertThat().onceInLog(MessageType.WARNING, ".*NOOP.*");
}
Aggregations