use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_noopIfAllNoop_allChildNoops.
@Test
public void testSequence_noopIfAllNoop_allChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setNoop(true);
MockTransform t2 = new MockTransform("t2").setNoop(true);
MockTransform t3 = new MockTransform("t3").setNoop(true);
Transformation t = sequence(Sequence.NoopBehavior.NOOP_IF_ALL_NOOP, t1, t2, t3);
TransformationStatus status = t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(t3.wasRun).isTrue();
assertThat(status.isNoop()).isTrue();
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_nestedSequences_missOnSecondCache.
@Test
public void testSequence_nestedSequences_missOnSecondCache() throws Exception {
TransformWork work = cachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setUseTreeState(false);
MockTransform t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(false);
MockTransform t3 = new MockTransform("t3").setUseTreeState(true).setExpectCacheHit(true);
MockTransform t4 = new MockTransform("t4").setUseTreeState(true).setExpectCacheHit(true);
Transformation t = sequence(sequence(t1, t2), sequence(t3, t4));
t.transform(work);
assertThat(t1.wasRun).isTrue();
assertThat(t2.wasRun).isTrue();
assertThat(t3.wasRun).isTrue();
assertThat(t4.wasRun).isTrue();
}
use of com.google.copybara.TransformWork in project copybara by google.
the class TodoReplaceTest method run.
private TransformWork run(Transformation replace) throws Exception {
TransformWork work = TransformWorks.of(checkoutDir, "testmsg", console);
replace.transform(work);
return work;
}
use of com.google.copybara.TransformWork in project copybara by google.
the class MetadataModuleTest method testMapAuthor_noop_reversal.
@Test
public void testMapAuthor_noop_reversal() throws Exception {
Transformation m = skylark.eval("m", "m = " + "metadata.map_author({\n" + " 'a' : 'b <b@example.com>',\n" + "}," + "noop_reverse = True)");
TransformWork work = TransformWorks.of(workdir, "test", testingConsole);
work.setAuthor(new Author("a", "foo@foo"));
m.transform(work);
assertThat(work.getAuthor().getEmail()).isEqualTo("b@example.com");
m.reverse().transform(work);
assertThat(work.getAuthor().getEmail()).isEqualTo("b@example.com");
}
use of com.google.copybara.TransformWork in project copybara by google.
the class MetadataModuleTest method testLastMessageWithMerge.
@Test
public void testLastMessageWithMerge() throws Exception {
Changes changes = new Changes(ImmutableList.of(new Change<>(new DummyRevision("3"), ORIGINAL_AUTHOR, "merge", fakeDate(), ImmutableListMultimap.of(), /*changeFiles=*/
null, /*merge=*/
true, ImmutableList.of(new DummyRevision("10"), new DummyRevision("20"))), new Change<>(new DummyRevision("2"), ORIGINAL_AUTHOR, "change2", fakeDate(), ImmutableListMultimap.of()), new Change<>(new DummyRevision("1"), ORIGINAL_AUTHOR, "change1", fakeDate(), ImmutableListMultimap.of())), ImmutableList.of());
TransformWork work = TransformWorks.of(workdir, "the message", testingConsole).withChanges(changes);
// The default is to use merges, since git.origin does --first-parent by default
skylark.<UseLastChange>eval("s", "s = metadata.use_last_change()").transform(work);
assertThat(work.getMessage()).isEqualTo("merge");
work = TransformWorks.of(workdir, "the message", testingConsole).withChanges(changes);
skylark.<UseLastChange>eval("s", "s = metadata.use_last_change(use_merge = False)").transform(work);
assertThat(work.getMessage()).isEqualTo("change2");
}
Aggregations