comparison test/com/tmate/hgkit/TestStatus.java @ 62:25819103de17

Few more tests for status
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 18 Jan 2011 18:42:01 +0100
parents fac8e7fcc8b0
children
comparison
equal deleted inserted replaced
61:fac8e7fcc8b0 62:25819103de17
19 * @author artem 19 * @author artem
20 */ 20 */
21 public class TestStatus { 21 public class TestStatus {
22 22
23 public static void main(String[] args) throws Exception { 23 public static void main(String[] args) throws Exception {
24 HgRepository repo = new RepositoryLookup().detectFromWorkingDir();
25 final WorkingCopyStatusCollector wcc = new WorkingCopyStatusCollector(repo, new FileWalker(new File(System.getProperty("user.dir"))));
24 final StatusOutputParser statusParser = new StatusOutputParser(); 26 final StatusOutputParser statusParser = new StatusOutputParser();
25 ExecHelper eh = new ExecHelper(statusParser, null); 27 ExecHelper eh = new ExecHelper(statusParser, null);
28 //
26 eh.run("hg", "status", "-A"); 29 eh.run("hg", "status", "-A");
27 // run java equivalent
28 HgRepository repo = new RepositoryLookup().detectFromWorkingDir();
29 final WorkingCopyStatusCollector wcc = new WorkingCopyStatusCollector(repo, new FileWalker(new File(System.getProperty("user.dir"))));
30 StatusCollector.Record r = wcc.status(HgRepository.TIP); 30 StatusCollector.Record r = wcc.status(HgRepository.TIP);
31 // compare result 31 report("hg status -A", r, statusParser);
32 //
33 statusParser.reset();
34 int revision = 3;
35 eh.run("hg", "status", "-A", "--rev", String.valueOf(revision));
36 r = wcc.status(revision);
37 report("status -A --rev " + revision, r, statusParser);
38 //
39 statusParser.reset();
40 eh.run("hg", "status", "-A", "--change", String.valueOf(revision));
41 r = new StatusCollector.Record();
42 new StatusCollector(repo).change(revision, r);
43 report("status -A --change " + revision, r, statusParser);
44 }
45
46 private static void report(String what, StatusCollector.Record r, StatusOutputParser statusParser) {
47 System.out.println(">>>" + what);
32 reportNotEqual("MODIFIED", r.getModified(), statusParser.getModified()); 48 reportNotEqual("MODIFIED", r.getModified(), statusParser.getModified());
33 reportNotEqual("ADDED", r.getAdded(), statusParser.getAdded()); 49 reportNotEqual("ADDED", r.getAdded(), statusParser.getAdded());
34 reportNotEqual("REMOVED", r.getRemoved(), statusParser.getRemoved()); 50 reportNotEqual("REMOVED", r.getRemoved(), statusParser.getRemoved());
35 reportNotEqual("CLEAN", r.getClean(), statusParser.getClean()); 51 reportNotEqual("CLEAN", r.getClean(), statusParser.getClean());
36 reportNotEqual("IGNORED", r.getIgnored(), statusParser.getIgnored()); 52 reportNotEqual("IGNORED", r.getIgnored(), statusParser.getIgnored());
37 reportNotEqual("MISSING", r.getMissing(), statusParser.getMissing()); 53 reportNotEqual("MISSING", r.getMissing(), statusParser.getMissing());
38 reportNotEqual("UNKNOWN", r.getUnknown(), statusParser.getUnknown()); 54 reportNotEqual("UNKNOWN", r.getUnknown(), statusParser.getUnknown());
39 // TODO compare equals 55 // TODO compare equals
56 System.out.println("<<<\n");
40 } 57 }
41 58
42 private static <T> void reportNotEqual(String what, Collection<T> l1, Collection<T> l2) { 59 private static <T> void reportNotEqual(String what, Collection<T> l1, Collection<T> l2) {
43 List<T> diff = difference(l1, l2); 60 List<T> diff = difference(l1, l2);
44 System.out.print(what); 61 System.out.print(what);