annotate test/org/tmatesoft/hg/test/TestStatus.java @ 68:0e499fed9b3d

StatusCommand with tests. Extra constants to indicate common revision cases
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 22 Jan 2011 22:11:24 +0100
parents 52dc3f4cfc76
children 6f1b88693d48
rev   line source
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
2 * Copyright (c) 2011 TMate Software Ltd
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
3 *
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
4 * This program is free software; you can redistribute it and/or modify
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
5 * it under the terms of the GNU General Public License as published by
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
6 * the Free Software Foundation; version 2 of the License.
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
7 *
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
8 * This program is distributed in the hope that it will be useful,
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
11 * GNU General Public License for more details.
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
12 *
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
13 * For information on how to redistribute this software under
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
14 * the terms of a license other than GNU General Public License
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
15 * contact TMate Software at support@svnkit.com
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
17 package org.tmatesoft.hg.test;
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
68
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
19 import static com.tmate.hgkit.ll.HgRepository.TIP;
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
20
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 import java.io.File;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 import java.util.Collection;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import java.util.LinkedList;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import java.util.List;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25
68
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
26 import org.tmatesoft.hg.core.StatusCommand;
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
27
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import com.tmate.hgkit.fs.FileWalker;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import com.tmate.hgkit.fs.RepositoryLookup;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import com.tmate.hgkit.ll.HgRepository;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import com.tmate.hgkit.ll.StatusCollector;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 import com.tmate.hgkit.ll.WorkingCopyStatusCollector;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 /**
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 *
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
36 * @author Artem Tikhomirov
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
37 * @author TMate Software Ltd.
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 */
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 public class TestStatus {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40
68
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
41 private final HgRepository repo;
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
42 private StatusOutputParser statusParser;
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
43 private ExecHelper eh;
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
44
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 public static void main(String[] args) throws Exception {
62
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
46 HgRepository repo = new RepositoryLookup().detectFromWorkingDir();
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
47 TestStatus test = new TestStatus(repo);
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
48 test.testLowLevel();
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
49 test.testStatusCommand();
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
50 }
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
51
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
52 public TestStatus(HgRepository hgRepo) {
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
53 repo = hgRepo;
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
54 statusParser = new StatusOutputParser();
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
55 eh = new ExecHelper(statusParser, null);
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
56 }
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
57
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
58 public void testLowLevel() throws Exception {
62
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
59 final WorkingCopyStatusCollector wcc = new WorkingCopyStatusCollector(repo, new FileWalker(new File(System.getProperty("user.dir"))));
68
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
60 statusParser.reset();
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 eh.run("hg", "status", "-A");
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 StatusCollector.Record r = wcc.status(HgRepository.TIP);
62
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
63 report("hg status -A", r, statusParser);
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
64 //
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
65 statusParser.reset();
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
66 int revision = 3;
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
67 eh.run("hg", "status", "-A", "--rev", String.valueOf(revision));
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
68 r = wcc.status(revision);
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
69 report("status -A --rev " + revision, r, statusParser);
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
70 //
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
71 statusParser.reset();
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
72 eh.run("hg", "status", "-A", "--change", String.valueOf(revision));
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
73 r = new StatusCollector.Record();
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
74 new StatusCollector(repo).change(revision, r);
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
75 report("status -A --change " + revision, r, statusParser);
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
76 }
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
77
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
78 public void testStatusCommand() throws Exception {
68
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
79 final StatusCommand sc = new StatusCommand(repo).all();
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
80 StatusCollector.Record r;
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
81 statusParser.reset();
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
82 eh.run("hg", "status", "-A");
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
83 sc.execute(r = new StatusCollector.Record());
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
84 report("hg status -A", r, statusParser);
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
85 //
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
86 statusParser.reset();
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
87 int revision = 3;
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
88 eh.run("hg", "status", "-A", "--rev", String.valueOf(revision));
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
89 sc.base(revision).execute(r = new StatusCollector.Record());
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
90 report("status -A --rev " + revision, r, statusParser);
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
91 //
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
92 statusParser.reset();
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
93 eh.run("hg", "status", "-A", "--change", String.valueOf(revision));
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
94 sc.base(TIP).revision(revision).execute(r = new StatusCollector.Record());
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
95 report("status -A --change " + revision, r, statusParser);
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
96
0e499fed9b3d StatusCommand with tests. Extra constants to indicate common revision cases
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 66
diff changeset
97 // TODO check not -A, but defaults()/custom set of modifications
66
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
98 }
52dc3f4cfc76 Primitive test suite in org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 62
diff changeset
99
62
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
100 private static void report(String what, StatusCollector.Record r, StatusOutputParser statusParser) {
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
101 System.out.println(">>>" + what);
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 reportNotEqual("MODIFIED", r.getModified(), statusParser.getModified());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 reportNotEqual("ADDED", r.getAdded(), statusParser.getAdded());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
104 reportNotEqual("REMOVED", r.getRemoved(), statusParser.getRemoved());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
105 reportNotEqual("CLEAN", r.getClean(), statusParser.getClean());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 reportNotEqual("IGNORED", r.getIgnored(), statusParser.getIgnored());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
107 reportNotEqual("MISSING", r.getMissing(), statusParser.getMissing());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
108 reportNotEqual("UNKNOWN", r.getUnknown(), statusParser.getUnknown());
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
109 // TODO compare equals
62
25819103de17 Few more tests for status
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 61
diff changeset
110 System.out.println("<<<\n");
61
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
111 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
112
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
113 private static <T> void reportNotEqual(String what, Collection<T> l1, Collection<T> l2) {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
114 List<T> diff = difference(l1, l2);
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
115 System.out.print(what);
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 if (!diff.isEmpty()) {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
117 System.out.print(" are NOT the same: ");
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
118 for (T t : diff) {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
119 System.out.print(t);
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120 System.out.print(", ");
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
122 System.out.println();
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
123 } else {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 System.out.println(" are the same");
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
125 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
126 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
127
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
128 private static <T> List<T> difference(Collection<T> l1, Collection<T> l2) {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
129 LinkedList<T> result = new LinkedList<T>(l2);
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
130 for (T t : l1) {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
131 if (l2.contains(t)) {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
132 result.remove(t);
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
133 } else {
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
134 result.add(t);
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
135 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
136 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
137 return result;
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
138 }
fac8e7fcc8b0 Simple test framework - capable of parsing Hg cmdline output to compare with Java result
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
139 }