Search in sources :

Example 26 with TransformationStatus

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

the class ReplaceTest method noopReplaceAsWarning.

@Test
public void noopReplaceAsWarning() throws Exception {
    writeFile(checkoutDir.resolve("foo"), "");
    TransformationStatus status = transform(eval("core.replace(\n" + "  before = \"BEFORE this string doesn't appear anywhere in source\",\n" + "  after = 'lulz',\n" + ")"));
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).matches(".*BEFORE.*lulz.*was a no-op because it didn't change any of the matching files");
    status = transform(eval("core.replace(\n" + "  before = \"BEFORE this string doesn't appear anywhere in source\",\n" + "  after = 'lulz',\n" + "  paths = glob(['bad_path/**'])\n" + ")"));
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).matches(".*BEFORE.*lulz.*was a no-op because it didn't match any file");
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Test(org.junit.Test)

Example 27 with TransformationStatus

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

the class ReplaceTest method nopReplaceShouldThrowException.

@Test
public void nopReplaceShouldThrowException() throws Exception {
    Replace replace = eval("core.replace(\n" + "  before = \"this string doesn't appear anywhere in source\",\n" + "  after = 'lulz',\n" + ")");
    TransformationStatus status = transform(replace);
    assertThat(status.isNoop()).isTrue();
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) 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