use of com.google.copybara.config.MapConfigFile in project copybara by google.
the class PatchTransformationTest method setup.
@Before
public void setup() throws IOException {
checkoutDir = Files.createTempDirectory("workdir");
Files.createDirectories(checkoutDir);
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console);
general = options.build().get(GeneralOptions.class);
skylark = new SkylarkTestExecutor(options, PatchModule.class);
ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("diff.patch", (DIFF).getBytes(UTF_8), "series", ("diff.patch\n").getBytes(UTF_8));
patchFile = new MapConfigFile(configFiles, "diff.patch");
seriesFile = new MapConfigFile(configFiles, "series");
options.setEnvironment(GitTestUtil.getGitEnv());
}
use of com.google.copybara.config.MapConfigFile in project copybara by google.
the class WorkflowTest method testDynamicTransformThrowingRepoException.
@Test
public void testDynamicTransformThrowingRepoException() throws Exception {
SkylarkTestExecutor exec = skylark.withStaticModules(ImmutableSet.of(ThrowingCallable.class));
origin.singleFileChange(0, "one commit", "foo.txt", "1");
Workflow<?, ?> wf = ((Workflow<?, ?>) exec.loadConfig(new MapConfigFile(ImmutableMap.of("copy.bara.sky", ("" + "def dynamic_foo(ctx):\n" + " dynamic_test.throw_repo()\n" + "" + "core.workflow(\n" + " name = 'default',\n" + " authoring = " + authoring + "\n," + " origin = testing.origin(),\n" + " destination = testing.destination(),\n" + " transformations = [dynamic_foo],\n" + ")\n" + "").getBytes(UTF_8)), "copy.bara.sky")).getMigration("default"));
RepoException expected = assertThrows(RepoException.class, () -> wf.run(workdir, ImmutableList.of("HEAD")));
assertThat(expected).hasMessageThat().contains("Oh noes");
}
use of com.google.copybara.config.MapConfigFile in project copybara by google.
the class PatchTransformationTest method setup.
@Before
public void setup() throws IOException {
checkoutDir = Files.createTempDirectory("workdir");
Files.createDirectories(checkoutDir);
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console);
patchingOptions = options.build().get(PatchingOptions.class);
skylark = new SkylarkTestExecutor(options);
ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("diff.patch", (DIFF).getBytes(UTF_8), "series", ("diff.patch\n").getBytes(UTF_8));
patchFile = new MapConfigFile(configFiles, "diff.patch");
seriesFile = new MapConfigFile(configFiles, "series");
options.setEnvironment(GitTestUtil.getGitEnv().getEnvironment());
// In preparation to switch to the new default. PatchingOptionsTest has more coverage on this.
options.patch.useGitApply = false;
options.patch.skipVersionCheck = false;
}
use of com.google.copybara.config.MapConfigFile in project copybara by google.
the class WorkflowTest method customIdentity_customPathIncluded.
@Test
public void customIdentity_customPathIncluded() throws Exception {
options.workflowOptions.initHistory = true;
byte[] cfgContent = ("" + "core.workflow(\n" + " name = 'default',\n" + " authoring = " + authoring + "\n," + " origin = testing.origin(),\n" + " destination = testing.destination(),\n" + " change_identity = '${copybara_config_path}foo${label:some_label}',\n" + " mode = 'ITERATIVE',\n" + ")\n\n" + "").getBytes(UTF_8);
Config config1 = skylark.loadConfig(new MapConfigFile(ImmutableMap.of("foo/copy.bara.sky", cfgContent), "foo/copy.bara.sky"));
Config config2 = skylark.loadConfig(new MapConfigFile(ImmutableMap.of("bar/copy.bara.sky", cfgContent), "bar/copy.bara.sky"));
origin.addSimpleChange(1, "change\n\nsome_label=a");
config1.getMigration("default").run(workdir, ImmutableList.of());
ImmutableList<String> oneResult = destination.processed.stream().map(ProcessedChange::getChangeIdentity).collect(ImmutableList.toImmutableList());
destination.processed.clear();
config2.getMigration("default").run(workdir, ImmutableList.of());
ImmutableList<String> twoResult = destination.processed.stream().map(ProcessedChange::getChangeIdentity).collect(ImmutableList.toImmutableList());
assertThat(oneResult).isNotEqualTo(twoResult);
}
use of com.google.copybara.config.MapConfigFile in project copybara by google.
the class QuiltTransformationTest method setUp.
@Before
public void setUp() throws IOException {
checkoutDir = Files.createTempDirectory("workdir");
Files.createDirectories(checkoutDir);
console = new TestingConsole();
// QuiltTransformation needs to write and read from to real temp directory.
options = new OptionsBuilder().setWorkdirToRealTempDir();
// GeneralOptions.getDirFactory() requires $HOME to be set. We set --output-root instead.
options.setOutputRootToTmpDir();
patchingOptions = options.build().get(PatchingOptions.class);
patchingOptions.quiltBin = setUpQuiltBin(patchingOptions.getGeneralOptions());
skylark = new SkylarkTestExecutor(options);
ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("patches/diff.patch", OLDDIFF.getBytes(UTF_8), "patches/series", SERIES.getBytes(UTF_8));
patchFile = new MapConfigFile(configFiles, "patches/diff.patch");
seriesFile = new MapConfigFile(configFiles, "patches/series");
}
Aggregations