use of com.google.copybara.Transformation in project copybara by google.
the class SequenceTest method testSequence_ignoreNoop_someChildNoops.
@Test
public void testSequence_ignoreNoop_someChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1");
MockTransform t2 = new MockTransform("t2").setNoop(true);
MockTransform t3 = new MockTransform("t3");
Transformation t = sequence(Sequence.NoopBehavior.IGNORE_NOOP, t1, t2, t3);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(t3.wasRun).isTrue();
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.Transformation in project copybara by google.
the class SequenceTest method testSequence_ignoreNoop_insideFailIfAnyNoop.
@Test
public void testSequence_ignoreNoop_insideFailIfAnyNoop() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setNoop(true);
Transformation t = sequence(Sequence.NoopBehavior.FAIL_IF_ANY_NOOP, sequence(Sequence.NoopBehavior.IGNORE_NOOP, t1));
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.Transformation 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.Transformation 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.Transformation 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.");
}
Aggregations