Search in sources :

Example 16 with TransformationStatus

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

the class ExplicitReversal method transform.

@Override
public TransformationStatus transform(TransformWork work) throws IOException, ValidationException, RepoException {
    TransformWork newWork;
    newWork = work.insideExplicitTransform();
    TransformationStatus status = forward.transform(newWork);
    work.updateFrom(newWork);
    return status;
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) TransformWork(com.google.copybara.TransformWork)

Example 17 with TransformationStatus

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

the class BuildozerBatchTest method testBatchTargetNotFoundIsError.

@Test
public void testBatchTargetNotFoundIsError() throws Exception {
    BuildozerCreate create1 = skylark.eval("c", "c = " + "buildozer.create(" + "    target = 'copy/bar:baz'," + "    rule_type = 'proto_library'" + ")");
    BuildozerModify notFound = skylark.eval("c", "c = " + "     buildozer.modify(\n" + "       target = ['foo/bar:idontexist'],\n" + "       commands = [ buildozer.cmd('set config \"test\"')],\n" + "     )");
    Files.createDirectories(checkoutDir.resolve("foo/bar"));
    Files.write(checkoutDir.resolve("foo/bar/BUILD"), "".getBytes(UTF_8));
    TransformationStatus status = transform(create1.join(notFound));
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).contains("foo/bar:idontexist");
    assertThatPath(checkoutDir).containsFiles("copy/bar/BUILD");
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Test(org.junit.Test)

Example 18 with TransformationStatus

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

the class BuildozerModifyTest method testNoopIsWarningTargetWildcard.

@Test
public void testNoopIsWarningTargetWildcard() throws Exception {
    BuildozerModify modify = skylark.eval("m", "m = " + "buildozer.modify(\n" + "    target = 'foo:%proto_library',\n" + "    commands = [buildozer.cmd('remove deps')],\n" + ")");
    options.workflowOptions.ignoreNoop = true;
    Files.createDirectories(checkoutDir.resolve("foo"));
    Files.write(checkoutDir.resolve("foo/BUILD"), "".getBytes(UTF_8));
    TransformationStatus status = transform(modify);
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).matches(".*Buildozer could not find a target for:\n  remove deps\\|foo:%proto_library.*");
}
Also used : TransformationStatus(com.google.copybara.TransformationStatus) Test(org.junit.Test)

Example 19 with TransformationStatus

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

the class CopyOrMoveTest method testDoesntExistCopier.

@Test
public void testDoesntExistCopier() throws Exception {
    CopyOrMove copier = skylark.eval("m", "" + "m = core.copy(before = 'blablabla', after = 'other')\n");
    TransformationStatus status = transform(copier);
    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 20 with TransformationStatus

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

the class CopyOrMoveTest method copyWithRegex_noop.

@Test
public void copyWithRegex_noop() throws Exception {
    CopyOrMove copier = skylark.eval("m", "m = core.copy(before = '${x}.java', after = '${x}.java.copy', regex_groups = {" + " 'x': '.*'})");
    touch("folder/foo/file.py");
    TransformationStatus status = transform(copier);
    assertThatPath(checkoutDir).containsFiles("folder/foo/file.py").containsNoMoreFiles();
    assertThat(status.isNoop()).isTrue();
    assertThat(status.getMessage()).contains("was a no-op because it didn't match any file");
}
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