Search in sources :

Example 6 with TransformationStatus

use of com.google.copybara.TransformationStatus in project copybara by google.

the class CopyOrMoveTest method testDoesntExistMover.

@Test
public void testDoesntExistMover() throws Exception {
    CopyOrMove mover = skylark.eval("m", "" + "m = core.move(before = 'blablabla', after = 'other')\n");
    TransformationStatus status = transform(mover);
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).contains("Error moving 'blablabla'. It doesn't exist");
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Test(org.junit.Test)

Example 7 with TransformationStatus

use of com.google.copybara.TransformationStatus in project copybara by google.

the class CopyOrMoveTest method testDoesntExistAsWarning.

@Test
public void testDoesntExistAsWarning() throws Exception {
    options.workflowOptions.ignoreNoop = true;
    CopyOrMove mover = skylark.eval("m", "" + "m = core.move(before = 'blablabla', after = 'other')\n");
    TransformationStatus status = transform(mover);
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).matches(".*blablabla.*doesn't exist.*");
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Test(org.junit.Test)

Example 8 with TransformationStatus

use of com.google.copybara.TransformationStatus in project copybara by google.

the class SequenceTest method testSequence_noopIfAllNoop_someChildNoops.

@Test
public void testSequence_noopIfAllNoop_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_ALL_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();
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 9 with TransformationStatus

use of com.google.copybara.TransformationStatus 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();
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Example 10 with TransformationStatus

use of com.google.copybara.TransformationStatus 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();
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Transformation(com.google.copybara.Transformation) TransformWork(com.google.copybara.TransformWork) Test(org.junit.Test)

Aggregations

TransformationStatus (com.google.copybara.TransformationStatus)27 Test (org.junit.Test)23 Transformation (com.google.copybara.Transformation)12 TransformWork (com.google.copybara.TransformWork)9 NonReversibleValidationException (com.google.copybara.exception.NonReversibleValidationException)2 ValidationException (com.google.copybara.exception.ValidationException)2 EmptyChangeException (com.google.copybara.exception.EmptyChangeException)1 RepoException (com.google.copybara.exception.RepoException)1 Transformations.toTransformation (com.google.copybara.transform.Transformations.toTransformation)1 Console (com.google.copybara.util.console.Console)1 Pattern (com.google.re2j.Pattern)1 PathMatcher (java.nio.file.PathMatcher)1 EvalException (net.starlark.java.eval.EvalException)1 Mutability (net.starlark.java.eval.Mutability)1 StarlarkThread (net.starlark.java.eval.StarlarkThread)1