use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method checkLastRevStatus_change_request.
@Test
public void checkLastRevStatus_change_request() throws Exception {
ValidationException e = assertThrows(ValidationException.class, () -> checkLastRevStatus(WorkflowMode.CHANGE_REQUEST));
assertThat(e.getMessage()).isEqualTo("--check-last-rev-state is not compatible with CHANGE_REQUEST");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method testNullOrigin.
@Test
public void testNullOrigin() throws Exception {
ValidationException e = assertThrows(ValidationException.class, () -> loadConfig("" + "core.workflow(\n" + " name = 'foo',\n" + " authoring = " + authoring + "\n," + " destination = testing.destination(),\n" + ")\n"));
for (Message message : console().getMessages()) {
System.err.println(message);
}
console().assertThat().onceInLog(MessageType.ERROR, ".*missing 1 required named argument: origin.*");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class BuildozerBatchTest method testBatchFileNotFoundIsNotNoop.
@Test
public void testBatchFileNotFoundIsNotNoop() throws Exception {
options.workflowOptions.ignoreNoop = true;
BuildozerCreate create = 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" + " )");
ValidationException thrown = assertThrows(ValidationException.class, () -> transform(create.join(notFound)));
assertThat(thrown).hasMessageThat().contains("foo/bar:idontexist");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class BuildozerBatchTest method testBatchMixedExceptionsGetThrown.
@Test
public void testBatchMixedExceptionsGetThrown() throws Exception {
options.workflowOptions.ignoreNoop = true;
BuildozerCreate create = skylark.eval("c", "c = " + "buildozer.create(" + " target = 'copy/bar:baz'," + " rule_type = 'proto_library'" + ")");
BuildozerModify targetNotFoundButIgnored = skylark.eval("c", "c = " + " buildozer.modify(\n" + " target = ['foo/bar:idontexist'],\n" + " commands = [ buildozer.cmd('set config \"test\"')],\n" + " )");
BuildozerModify fileNotFound = skylark.eval("c", "c = " + " buildozer.modify(\n" + " target = ['nosuch:file'],\n" + " commands = [ buildozer.cmd('set config \"test\"')],\n" + " )");
Files.createDirectories(checkoutDir.resolve("foo/bar"));
Files.write(checkoutDir.resolve("foo/bar/BUILD"), "".getBytes(UTF_8));
// this is fine
transform(create.join(targetNotFoundButIgnored));
// this is not
ValidationException thrown = assertThrows(ValidationException.class, () -> transform(create.join(targetNotFoundButIgnored).join(fileNotFound)));
assertThat(thrown).hasMessageThat().contains("nosuch:file");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class SkylarkParserTest method testStrictStarlarkParsingCatchesError.
@Test
public void testStrictStarlarkParsingCatchesError() throws IOException, ValidationException {
// A parse error is always reported, even in LOOSE mode.
options.general.starlarkMode = StarlarkMode.LOOSE.name();
parser = new SkylarkTestExecutor(options);
ValidationException ex = assertThrows(ValidationException.class, () -> parser.loadConfig("foo = '\\j',"));
assertThat(ex).hasMessageThat().contains("Trailing comma");
// Strict mode detects string escapes, if/for at top level, and loads not at the top.
options.general.starlarkMode = StarlarkMode.STRICT.name();
parser = new SkylarkTestExecutor(options);
ex = assertThrows(ValidationException.class, () -> parser.loadConfig("foo = '\\j',"));
assertThat(ex).hasMessageThat().contains("Trailing comma");
assertThat(ex).hasMessageThat().contains("invalid escape sequence");
}
Aggregations