@Test public void testGlobsUpToDate() throws Exception { assertTrue(cache.globsUpToDate()); // Initialize the cache cache.getGlob("*.txt"); assertTrue(cache.globsUpToDate()); cache.getGlob("*.js"); assertTrue(cache.globsUpToDate()); // Change the filesystem scratch.file("isolated/third.txt", "# this is third.txt"); assertFalse(cache.globsUpToDate()); // Fool the cache to observe the method's behavior. cache.setGlobPaths( "*.txt", false, Futures.<List<Path>>immediateFuture( Lists.newArrayList( scratch.resolve("isolated/first.txt"), scratch.resolve("isolated/second.txt"), scratch.resolve("isolated/third.txt")))); assertTrue(cache.globsUpToDate()); }
@Test public void testSetGlobPaths() throws Exception { // This pattern matches no files. String pattern = "fake*.java"; assertThat(cache.getKeySet()).doesNotContain(pattern); List<String> results = cache.getGlob(pattern, false); assertThat(cache.getKeySet()).contains(Pair.of(pattern, false)); assertThat(results).isEmpty(); cache.setGlobPaths( pattern, false, Futures.<List<Path>>immediateFuture( Lists.newArrayList( scratch.resolve("isolated/fake.txt"), scratch.resolve("isolated/fake.py")))); assertThat(cache.getGlob(pattern, false)).containsExactly("fake.py", "fake.txt"); }