annotate test/org/tmatesoft/hg/test/TestDirstate.java @ 609:e4a71afd3c71

Test TODOs: test for ConfigFile (covering %include and %unset directives)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 08 May 2013 17:11:45 +0200
parents 2813a26b8999
children
rev   line source
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
609
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
2 * Copyright (c) 2011-2013 TMate Software Ltd
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.test;
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
296
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
19 import static java.lang.Character.*;
609
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
20 import static org.junit.Assert.*;
296
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
21
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
22 import java.util.TreeSet;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
23
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import org.junit.Assert;
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 import org.junit.Test;
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import org.tmatesoft.hg.core.Nodeid;
296
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
27 import org.tmatesoft.hg.repo.HgDirstate;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
28 import org.tmatesoft.hg.repo.HgDirstate.EntryKind;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
29 import org.tmatesoft.hg.repo.HgDirstate.Record;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
30 import org.tmatesoft.hg.repo.HgInternals;
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import org.tmatesoft.hg.repo.HgLookup;
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 import org.tmatesoft.hg.repo.HgRepository;
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 import org.tmatesoft.hg.util.Pair;
296
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
34 import org.tmatesoft.hg.util.Path;
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 /**
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 *
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 * @author Artem Tikhomirov
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 * @author TMate Software Ltd.
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 */
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 public class TestDirstate {
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 private HgRepository repo;
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 @Test
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 public void testParents() throws Exception {
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 repo = Configuration.get().find("log-branches");
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 final Pair<Nodeid, Nodeid> wcParents = repo.getWorkingCopyParents();
609
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
48 assertEquals("5f24ef64e9dfb1540db524f88cb5c3d265e1a3b5", wcParents.first().toString());
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
49 assertTrue(wcParents.second().isNull());
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 //
609
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
51 HgDirstate ds = new HgInternals(repo).getDirstate();
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
52 final Pair<Nodeid, Nodeid> wcParents2 = ds.parents();
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
53 assertEquals(wcParents.first(), wcParents2.first());
e4a71afd3c71 Test TODOs: test for ConfigFile (covering %include and %unset directives)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 536
diff changeset
54 assertEquals(wcParents.second(), wcParents2.second());
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 }
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 @Test
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 public void testParentsEmptyRepo() throws Exception {
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 // check contract return values for empty/nonexistent dirstate
536
2813a26b8999 Tests: refactor various utility methods to a single location
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 410
diff changeset
60 repo = new HgLookup().detect(RepoUtils.initEmptyTempRepo("testParentsEmptyRepo"));
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 final Pair<Nodeid, Nodeid> wcParents = repo.getWorkingCopyParents();
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 Assert.assertTrue(wcParents.first().isNull());
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 Assert.assertTrue(wcParents.second().isNull());
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 }
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 @Test
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 public void testBranchName() throws Exception {
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 repo = Configuration.get().find("log-branches");
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 Assert.assertEquals("test", repo.getWorkingCopyBranchName());
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70 repo = Configuration.get().own();
410
df5009d67be2 Fixed test to pass in a branch other than default
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 296
diff changeset
71 OutputParser.Stub output = new OutputParser.Stub();
df5009d67be2 Fixed test to pass in a branch other than default
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 296
diff changeset
72 ExecHelper eh = new ExecHelper(output, repo.getWorkingDir());
df5009d67be2 Fixed test to pass in a branch other than default
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 296
diff changeset
73 eh.run("hg", "branch");
df5009d67be2 Fixed test to pass in a branch other than default
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 296
diff changeset
74 String branchName = output.result().toString().trim();
df5009d67be2 Fixed test to pass in a branch other than default
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 296
diff changeset
75 Assert.assertEquals(branchName, repo.getWorkingCopyBranchName());
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 }
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 286
diff changeset
77
296
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
78 @Test
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
79 public void testMixedNameCaseHandling() throws Exception {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
80 // General idea: to check cases like
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 286
diff changeset
81 // 1. dirstate: /a/b/c, FileIterator: /a/B/C
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 286
diff changeset
82 // 2. dirstate: /a/B/C, FileIterator: /a/b/c
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 286
diff changeset
83 // 2. dirstate: /a/B/C, FileIterator: /A/b/C
296
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
84 repo = Configuration.get().find("mixed-case");
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
85 // Windows, case-insensitive file system
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
86 final HgInternals testAccess = new HgInternals(repo);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
87 HgDirstate dirstate = testAccess.createDirstate(false);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
88 final TreeSet<Path> entries = new TreeSet<Path>();
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
89 dirstate.walk(new HgDirstate.Inspector() {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
90
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
91 public boolean next(EntryKind kind, Record entry) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
92 entries.add(entry.name());
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
93 return true;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
94 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
95 });
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
96 Path[] expected = new Path[] {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
97 Path.create("a/low/low"),
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
98 Path.create("a/low/UP"),
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
99 Path.create("a/UP/low"),
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
100 Path.create("a/UP/UP"),
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
101 };
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
102 Path[] allLower = new Path[expected.length];
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
103 Path[] allUpper = new Path[expected.length];
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
104 Path[] mixedNonMatching = new Path[expected.length];
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
105 for (int i = 0; i < expected.length; i++) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
106 assertTrue("prereq", entries.contains(expected[i]));
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
107 final String s = expected[i].toString();
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
108 allLower[i] = Path.create(s.toLowerCase());
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
109 allUpper[i] = Path.create(s.toUpperCase());
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
110 char[] ss = s.toCharArray();
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
111 for (int j = 0; j < ss.length; j++) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
112 if (isLetter(ss[j])) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
113 ss[j] = isLowerCase(ss[j]) ? toUpperCase(ss[j]) : toLowerCase(ss[j]);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
114 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
115 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
116 Path mixed = Path.create(new String(ss));
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
117 mixedNonMatching[i] = mixed;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
118 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
119 // prereq
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
120 checkKnownInDirstate(testAccess, dirstate, expected, expected);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
121 // all upper
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
122 checkKnownInDirstate(testAccess, dirstate, allUpper, expected);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
123 // all lower
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
124 checkKnownInDirstate(testAccess, dirstate, allLower, expected);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
125 // mixed
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
126 checkKnownInDirstate(testAccess, dirstate, mixedNonMatching, expected);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
127 //
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
128 // check that in case-sensitive file system mangled names do not match
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
129 dirstate = testAccess.createDirstate(true);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
130 // ensure read
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
131 dirstate.walk(new HgDirstate.Inspector() {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
132 public boolean next(EntryKind kind, Record entry) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
133 return false;
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
134 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
135 });
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
136 Path[] known = testAccess.checkKnown(dirstate, mixedNonMatching);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
137 for (int i = 0; i < known.length; i++) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
138 if (known[i] != null) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
139 fail(expected[i] + " in case-sensitive dirstate matched " + known[i]);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
140 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
141 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
142
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
143 }
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
144
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
145 private static void checkKnownInDirstate(HgInternals testAccess, HgDirstate dirstate, Path[] toCheck, Path[] expected) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
146 Path[] known = testAccess.checkKnown(dirstate, toCheck);
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
147 for (int i = 0; i < expected.length; i++) {
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
148 assertTrue(expected[i].equals(known[i]));
02f2963c70fa Issue 13: Tests for mixed-cased filenames in case-insensitive FS
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 293
diff changeset
149 }
293
9774f47d904d Issue 13: Status reports filenames with case other than in dirstate incorrectly
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 286
diff changeset
150 }
286
954763c82cc3 Few tests for working copy information (branch, parents)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
151 }