comparison test/org/tmatesoft/hg/test/TestCheckout.java @ 623:fedc54356091

Update tests for Windows; TestCommit: use copy of a repo (not clone) to preserve old timestamps
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 20 May 2013 18:35:13 +0200
parents e1b29756f901
children
comparison
equal deleted inserted replaced
622:4e6179bde4fc 623:fedc54356091
26 26
27 import org.junit.Rule; 27 import org.junit.Rule;
28 import org.junit.Test; 28 import org.junit.Test;
29 import org.tmatesoft.hg.core.HgCheckoutCommand; 29 import org.tmatesoft.hg.core.HgCheckoutCommand;
30 import org.tmatesoft.hg.core.Nodeid; 30 import org.tmatesoft.hg.core.Nodeid;
31 import org.tmatesoft.hg.internal.Internals;
32 import org.tmatesoft.hg.internal.RelativePathRewrite;
31 import org.tmatesoft.hg.repo.HgLookup; 33 import org.tmatesoft.hg.repo.HgLookup;
32 import org.tmatesoft.hg.repo.HgRepository; 34 import org.tmatesoft.hg.repo.HgRepository;
33 import org.tmatesoft.hg.util.FileInfo; 35 import org.tmatesoft.hg.util.FileInfo;
34 import org.tmatesoft.hg.util.FileWalker; 36 import org.tmatesoft.hg.util.FileWalker;
35 import org.tmatesoft.hg.util.Pair; 37 import org.tmatesoft.hg.util.Pair;
36 import org.tmatesoft.hg.util.Path; 38 import org.tmatesoft.hg.util.Path;
39 import org.tmatesoft.hg.util.PathRewrite;
37 40
38 /** 41 /**
39 * 42 *
40 * @author Artem Tikhomirov 43 * @author Artem Tikhomirov
41 * @author TMate Software Ltd. 44 * @author TMate Software Ltd.
121 @Test 124 @Test
122 public void testCheckoutLinkAndExec() throws Exception { 125 public void testCheckoutLinkAndExec() throws Exception {
123 File testRepoLoc = cloneRepoToTempLocation("test-flags", "test-checkout-flags", true); 126 File testRepoLoc = cloneRepoToTempLocation("test-flags", "test-checkout-flags", true);
124 repo = new HgLookup().detect(testRepoLoc); 127 repo = new HgLookup().detect(testRepoLoc);
125 new HgCheckoutCommand(repo).clean(true).changeset(0).execute(); 128 new HgCheckoutCommand(repo).clean(true).changeset(0).execute();
126 129
127 FileWalker fw = new FileWalker(repo, testRepoLoc, new Path.SimpleSource(), null); 130 Path.Source pathSrc = new Path.SimpleSource(new PathRewrite.Composite(new RelativePathRewrite(testRepoLoc), repo.getToRepoPathHelper()));
131 FileWalker fw = new FileWalker(repo, testRepoLoc, pathSrc, null);
128 int execFound, linkFound, regularFound; 132 int execFound, linkFound, regularFound;
129 execFound = linkFound = regularFound = 0; 133 execFound = linkFound = regularFound = 0;
130 while(fw.hasNext()) { 134 while(fw.hasNext()) {
131 fw.next(); 135 fw.next();
132 FileInfo fi = fw.file(); 136 FileInfo fi = fw.file();
140 } 144 }
141 if (!executable && !symlink) { 145 if (!executable && !symlink) {
142 regularFound++; 146 regularFound++;
143 } 147 }
144 } 148 }
145 // TODO alter expected values to pass on Windows 149 final int expectedExec, expectedLink, expectedRegular;
146 errorCollector.assertEquals("Executable files", 1, execFound); 150 if (Internals.runningOnWindows()) {
147 errorCollector.assertEquals("Symlink files", 1, linkFound); 151 expectedExec = expectedLink = 0;
148 errorCollector.assertEquals("Regular files", 1, regularFound); 152 expectedRegular = 2;
153 } else {
154 expectedExec = expectedLink = expectedRegular = 1;
155 }
156 errorCollector.assertEquals("Executable files", expectedExec, execFound);
157 errorCollector.assertEquals("Symlink files", expectedLink, linkFound);
158 errorCollector.assertEquals("Regular files", expectedRegular, regularFound);
149 } 159 }
150 160
151 private static final class FilesOnlyFilter implements FileFilter { 161 private static final class FilesOnlyFilter implements FileFilter {
152 public boolean accept(File f) { 162 public boolean accept(File f) {
153 return f.isFile(); 163 return f.isFile();