diff test/org/tmatesoft/hg/test/TestIgnore.java @ 612:dca70c0b1f74

Test tags, branches and hgingore information get refreshed on external (and/or internal) change
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 10 May 2013 14:29:35 +0200
parents 0f5696623512
children
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestIgnore.java	Thu May 09 21:52:01 2013 +0200
+++ b/test/org/tmatesoft/hg/test/TestIgnore.java	Fri May 10 14:29:35 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 TMate Software Ltd
+ * Copyright (c) 2011-2013 TMate Software Ltd
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -28,6 +28,9 @@
 import org.tmatesoft.hg.internal.WinToNixPathRewrite;
 import org.tmatesoft.hg.repo.HgIgnore;
 import org.tmatesoft.hg.repo.HgInternals;
+import org.tmatesoft.hg.repo.HgLookup;
+import org.tmatesoft.hg.repo.HgRepository;
+import org.tmatesoft.hg.repo.HgRepositoryFiles;
 import org.tmatesoft.hg.util.Path;
 
 /**
@@ -189,6 +192,26 @@
 		doAssert(hgIgnore, toIgnore, toPass);
 	}
 	
+	@Test
+	public void testRefreshOnChange() throws Exception {
+		File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-refresh-hgignore", false);
+		File hgignoreFile = new File(repoLoc, HgRepositoryFiles.HgIgnore.getPath());
+		RepoUtils.createFile(hgignoreFile, "bin/");
+		HgRepository hgRepo = new HgLookup().detect(repoLoc);
+		final Path p1 = Path.create("bin/a/b/c");
+		final Path p2 = Path.create("src/a/b/c");
+		HgIgnore ignore = hgRepo.getIgnore();
+		errorCollector.assertTrue(ignore.isIgnored(p1));
+		errorCollector.assertFalse(ignore.isIgnored(p2));
+		Thread.sleep(1000); // Linux granularity for modification time is 1 second 
+		// file of the same length
+		RepoUtils.createFile(hgignoreFile, "src/");
+		ignore = hgRepo.getIgnore();
+		errorCollector.assertFalse(ignore.isIgnored(p1));
+		errorCollector.assertTrue(ignore.isIgnored(p2));
+		
+	}
+	
 	private void doAssert(HgIgnore hgIgnore, Path[] toIgnore, Path[] toPass) {
 		if (toIgnore == null && toPass == null) {
 			throw new IllegalArgumentException();