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;
}
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");
}
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.*");
}
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");
}
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");
}
Aggregations