use of com.google.copybara.TransformationStatus in project copybara by google.
the class SequenceTest method testSequence_noopIfAnyNoop_insideIgnoreNoop.
@Test
public void testSequence_noopIfAnyNoop_insideIgnoreNoop() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setNoop(true);
Transformation t = sequence(Sequence.NoopBehavior.IGNORE_NOOP, sequence(Sequence.NoopBehavior.NOOP_IF_ANY_NOOP, t1));
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class SequenceTest method testSequence_noopIfAnyNoop_noChildNoops.
@Test
public void testSequence_noopIfAnyNoop_noChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1");
MockTransform t2 = new MockTransform("t2");
Transformation t = sequence(Sequence.NoopBehavior.NOOP_IF_ANY_NOOP, t1, t2);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(status.isSuccess()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class SequenceTest method testSequence_noopIfAnyNoop_someChildNoops.
@Test
public void testSequence_noopIfAnyNoop_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.NOOP_IF_ANY_NOOP, t1, t2, t3);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(t3.wasRun).isFalse();
assertThat(status.isNoop()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class SequenceTest method testSequence_noopIfAllNoop_allChildNoops.
@Test
public void testSequence_noopIfAllNoop_allChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setNoop(true);
MockTransform t2 = new MockTransform("t2").setNoop(true);
MockTransform t3 = new MockTransform("t3").setNoop(true);
Transformation t = sequence(Sequence.NoopBehavior.NOOP_IF_ALL_NOOP, t1, t2, t3);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(t3.wasRun).isTrue();
assertThat(status.isNoop()).isTrue();
}
use of com.google.copybara.TransformationStatus in project copybara by google.
the class SkylarkTransformationTest method testStarlarkTransform_returnValueCanBeCasedOn.
@Test
public void testStarlarkTransform_returnValueCanBeCasedOn() throws Exception {
Transformation t = skylark.eval("t", "" + "def foo(ctx):\n" + " return ctx.success()\n" + "\n" + "s = core.dynamic_transform(foo)" + "\n" + "def bar(ctx):\n" + " status = ctx.run(s)\n" + " if not status.is_success:\n" + " core.fail_with_noop()\n" + " if status.is_noop:\n" + " core.fail_with_noop()\n" + " return status" + "\n" + "t = core.dynamic_transform(foo)");
TransformationStatus status = t.transform(transformWork);
assertThat(status.isSuccess()).isTrue();
}
Aggregations