use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_nestedSequences_missOnFourthCache.
@Test
public void testSequence_nestedSequences_missOnFourthCache() throws Exception {
TransformWork work = cachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(true);
MockTransform t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(true);
MockTransform t3 = new MockTransform("t3").setUseTreeState(false);
MockTransform t4 = new MockTransform("t4").setUseTreeState(true).setExpectCacheHit(false);
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 SequenceTest method testSequence_noopIfAllNoop_someChildNoops.
@Test
public void testSequence_noopIfAllNoop_someChildNoops() throws Exception {
TransformWork work = uncachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1");
MockTransform t2 = new MockTransform("t2").setNoop(true);
MockTransform t3 = new MockTransform("t3");
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.isSuccess()).isTrue();
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method cachedTreeStateTransformWork.
private TransformWork cachedTreeStateTransformWork() throws IOException {
TransformWork work = TransformWorks.of(checkoutDir, "foo", console);
// Force a cached tree-state
work.getTreeState().find(Glob.ALL_FILES.relativeTo(checkoutDir));
assertThat(work.getTreeState().isCached()).isTrue();
return work;
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_treeStateCacheInvalidation.
@Test
public void testSequence_treeStateCacheInvalidation() throws Exception {
TransformWork work = cachedTreeStateTransformWork();
// The first transform does not use/notify the TreeState...
Transformation t1 = new MockTransform("t1").setUseTreeState(false);
// ...so the second transform should not have a cache available
Transformation t2 = new MockTransform("t2").setUseTreeState(true).setExpectCacheHit(false);
Transformation t = sequence(t1, t2);
t.transform(work);
}
use of com.google.copybara.TransformWork in project copybara by google.
the class SequenceTest method testSequence_nestedSequences_missOnThirdCache.
@Test
public void testSequence_nestedSequences_missOnThirdCache() throws Exception {
TransformWork work = cachedTreeStateTransformWork();
MockTransform t1 = new MockTransform("t1").setUseTreeState(true).setExpectCacheHit(true);
MockTransform t2 = new MockTransform("t2").setUseTreeState(false);
MockTransform t3 = new MockTransform("t3").setUseTreeState(true).setExpectCacheHit(false);
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();
}
Aggregations