use of com.google.copybara.TransformationStatus in project copybara by google.
the class SkylarkTransformationTest method testStarlarkTransform_noReturnValue_isTreatedAsSuccess.
@Test
public void testStarlarkTransform_noReturnValue_isTreatedAsSuccess() throws Exception {
Transformation t = skylark.eval("t", "" + "def foo(ctx):\n" + " # Do nothing \n" + " pass\n" + "\n" + "t = core.dynamic_transform(foo)");
TransformationStatus status = t.transform(transformWork);
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class SkylarkTransformationTest method testStarlarkTransform_returnsSuccess.
@Test
public void testStarlarkTransform_returnsSuccess() throws Exception {
Transformation t = skylark.eval("t", "" + "def foo(ctx):\n" + " return ctx.success()\n" + "\n" + "t = core.dynamic_transform(foo)");
TransformationStatus status = t.transform(transformWork);
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class SkylarkTransformationTest method testStarlarkTransform_returnsNoop.
@Test
public void testStarlarkTransform_returnsNoop() throws Exception {
Transformation t = skylark.eval("t", "" + "def foo(ctx):\n" + " return ctx.noop('Reason for noop.')\n" + "\n" + "t = core.dynamic_transform(foo)");
TransformationStatus status = t.transform(transformWork);
assertThat(status.isNoop()).isTrue();
assertThat(status.getMessage()).isEqualTo("Reason for noop.");
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class ReplaceTest method testNoBacktracking.
@Test
public void testNoBacktracking() throws Exception {
Replace transformation = eval("core.replace(\n" + " before = 'foo/${a}${a}',\n" + " after = '${a}',\n" + " regex_groups = {\n" + " 'a' : '[a-z]+',\n" + " },\n" + " repeated_groups = True,\n" + ")");
writeFile(checkoutDir.resolve("before_and_after"), "foo/barbar\n");
// Because we don't use backtracking this repeated group is expected to fail.
TransformationStatus status = transform(transformation);
assertThat(status.isNoop()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class ReplaceTest method replaceErrorEscapesNewLine.
@Test
public void replaceErrorEscapesNewLine() throws Exception {
Replace replace = eval("core.replace(\n" + " before = \"hello\\n\\r\\tbye!\",\n" + " after = 'lulz',\n" + ")");
TransformationStatus status = transform(replace);
assertThat(status.isNoop()).isTrue();
assertThat(status.getMessage()).contains("hello\\n\\r\\tbye!");
}
Aggregations