Skip to content

Commit

Permalink
Make cache invalidation test more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
mukel committed Aug 25, 2020
1 parent be7b637 commit fdb00e8
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ public void testCacheInvalidation() {
encodedGraphCacheContains(truffleCompiler, testMethod));

// Retry again, the encoded graph is re-parsed without the (invalidated) assumption.
// Compilation succeeds.
callTarget = compileAST(rootTestNode);

assertTrue("Re-parsed graph is in the cache",
encodedGraphCacheContains(truffleCompiler, testMethod));
boolean[] graphWasCached = {false};
for (int attempts = 0; attempts < 10 && !graphWasCached[0]; attempts++) {
// Compilation succeeds.
callTarget = compileAST(rootTestNode);
// But the cache can be purged anytime, retry if the graph is not cached.
graphWasCached[0] = encodedGraphCacheContains(truffleCompiler, testMethod);
}

Assert.assertTrue("Re-parsed graph was cached", graphWasCached[0]);
Assert.assertEquals(42, (int) callTarget.call());
}

Expand Down

0 comments on commit fdb00e8

Please sign in to comment.