##// END OF EJS Templates
color: Add tests for colorized diff and status output.
Augie Fackler -
r7458:03dd5511 default
parent child Browse files
Show More
@@ -0,0 +1,36 b''
1 #!/bin/sh
2
3 echo "[extensions]" >> $HGRCPATH
4 echo "color=" >> $HGRCPATH
5
6 hg init repo
7 cd repo
8 cat > a <<EOF
9 c
10 c
11 a
12 a
13 b
14 a
15 a
16 c
17 c
18 EOF
19 hg ci -Am adda
20 cat > a <<EOF
21 c
22 c
23 a
24 a
25 dd
26 a
27 a
28 c
29 c
30 EOF
31
32 echo '% default context'
33 hg diff --nodates --color=always
34
35 echo '% --unified=2'
36 hg diff --nodates -U 2 --color=always No newline at end of file
@@ -0,0 +1,25 b''
1 adding a
2 % default context
3 diff -r cf9f4ba66af2 a
4 --- a/a
5 +++ b/a
6 @@ -2,7 +2,7 @@
7 c
8 a
9 a
10 -b
11 +dd
12 a
13 a
14 c
15 % --unified=2
16 diff -r cf9f4ba66af2 a
17 --- a/a
18 +++ b/a
19 @@ -3,5 +3,5 @@
20 a
21 a
22 -b
23 +dd
24 a
25 a
@@ -0,0 +1,97 b''
1 #!/bin/sh
2
3 echo "[extensions]" >> $HGRCPATH
4 echo "color=" >> $HGRCPATH
5
6 hg init repo1
7 cd repo1
8 mkdir a b a/1 b/1 b/2
9 touch in_root a/in_a b/in_b a/1/in_a_1 b/1/in_b_1 b/2/in_b_2
10 echo "hg status in repo root:"
11 hg status --color=always
12 echo "hg status . in repo root:"
13 hg status --color=always .
14 for dir in a b a/1 b/1 b/2; do
15 echo "hg status in $dir:"
16 hg status --color=always --cwd "$dir"
17 echo "hg status . in $dir:"
18 hg status --color=always --cwd "$dir" .
19 echo "hg status .. in $dir:"
20 hg status --color=always --cwd "$dir" ..
21 done
22 cd ..
23
24 hg init repo2
25 cd repo2
26 touch modified removed deleted ignored
27 echo "^ignored$" > .hgignore
28 hg ci -A -m 'initial checkin' -d "1000000 0"
29 touch modified added unknown ignored
30 hg add added
31 hg remove removed
32 rm deleted
33 echo "hg status:"
34 hg status --color=always
35 echo "hg status modified added removed deleted unknown never-existed ignored:"
36 hg status --color=always modified added removed deleted unknown never-existed ignored
37 hg copy modified copied
38 echo "hg status -C:"
39 hg status --color=always -C
40 echo "hg status -A:"
41 hg status --color=always -A
42 echo "^ignoreddir$" > .hgignore
43 mkdir ignoreddir
44 touch ignoreddir/file
45 echo "hg status ignoreddir/file:"
46 hg status --color=always ignoreddir/file
47 echo "hg status -i ignoreddir/file:"
48 hg status --color=always -i ignoreddir/file
49 cd ..
50
51 # check 'status -q' and some combinations
52 hg init repo3
53 cd repo3
54 touch modified removed deleted ignored
55 echo "^ignored$" > .hgignore
56 hg commit -A -m 'initial checkin'
57 touch added unknown ignored
58 hg add added
59 echo "test" >> modified
60 hg remove removed
61 rm deleted
62 hg copy modified copied
63
64 # Run status with 2 different flags.
65 # Check if result is the same or different.
66 # If result is not as expected, raise error
67 assert() {
68 hg status --color=always $1 > ../a
69 hg status --color=always $2 > ../b
70 out=`diff ../a ../b`
71 if [ $? -ne 0 ]; then
72 out=1
73 else
74 out=0
75 fi
76 if [ $3 -eq 0 ]; then
77 df="same"
78 else
79 df="different"
80 fi
81 if [ $out -ne $3 ]; then
82 echo "Error on $1 and $2, should be $df."
83 fi
84 }
85
86 # assert flag1 flag2 [0-same | 1-different]
87 assert "-q" "-mard" 0
88 assert "-A" "-marduicC" 0
89 assert "-qA" "-mardcC" 0
90 assert "-qAui" "-A" 0
91 assert "-qAu" "-marducC" 0
92 assert "-qAi" "-mardicC" 0
93 assert "-qu" "-u" 0
94 assert "-q" "-u" 1
95 assert "-m" "-a" 1
96 assert "-r" "-d" 1
97
@@ -0,0 +1,126 b''
1 hg status in repo root:
2 ? a/1/in_a_1
3 ? a/in_a
4 ? b/1/in_b_1
5 ? b/2/in_b_2
6 ? b/in_b
7 ? in_root
8 hg status . in repo root:
9 ? a/1/in_a_1
10 ? a/in_a
11 ? b/1/in_b_1
12 ? b/2/in_b_2
13 ? b/in_b
14 ? in_root
15 hg status in a:
16 ? a/1/in_a_1
17 ? a/in_a
18 ? b/1/in_b_1
19 ? b/2/in_b_2
20 ? b/in_b
21 ? in_root
22 hg status . in a:
23 ? 1/in_a_1
24 ? in_a
25 hg status .. in a:
26 ? 1/in_a_1
27 ? in_a
28 ? ../b/1/in_b_1
29 ? ../b/2/in_b_2
30 ? ../b/in_b
31 ? ../in_root
32 hg status in b:
33 ? a/1/in_a_1
34 ? a/in_a
35 ? b/1/in_b_1
36 ? b/2/in_b_2
37 ? b/in_b
38 ? in_root
39 hg status . in b:
40 ? 1/in_b_1
41 ? 2/in_b_2
42 ? in_b
43 hg status .. in b:
44 ? ../a/1/in_a_1
45 ? ../a/in_a
46 ? 1/in_b_1
47 ? 2/in_b_2
48 ? in_b
49 ? ../in_root
50 hg status in a/1:
51 ? a/1/in_a_1
52 ? a/in_a
53 ? b/1/in_b_1
54 ? b/2/in_b_2
55 ? b/in_b
56 ? in_root
57 hg status . in a/1:
58 ? in_a_1
59 hg status .. in a/1:
60 ? in_a_1
61 ? ../in_a
62 hg status in b/1:
63 ? a/1/in_a_1
64 ? a/in_a
65 ? b/1/in_b_1
66 ? b/2/in_b_2
67 ? b/in_b
68 ? in_root
69 hg status . in b/1:
70 ? in_b_1
71 hg status .. in b/1:
72 ? in_b_1
73 ? ../2/in_b_2
74 ? ../in_b
75 hg status in b/2:
76 ? a/1/in_a_1
77 ? a/in_a
78 ? b/1/in_b_1
79 ? b/2/in_b_2
80 ? b/in_b
81 ? in_root
82 hg status . in b/2:
83 ? in_b_2
84 hg status .. in b/2:
85 ? ../1/in_b_1
86 ? in_b_2
87 ? ../in_b
88 adding .hgignore
89 adding deleted
90 adding modified
91 adding removed
92 hg status:
93 A added
94 R removed
95 ! deleted
96 ? unknown
97 hg status modified added removed deleted unknown never-existed ignored:
98 never-existed: No such file or directory
99 A added
100 R removed
101 ! deleted
102 ? unknown
103 hg status -C:
104 A added
105 A copied
106  modified
107 R removed
108 ! deleted
109 ? unknown
110 hg status -A:
111 A added
112 A copied
113  modified
114 R removed
115 ! deleted
116 ? unknown
117 I ignored
118 C .hgignore
119 C modified
120 hg status ignoreddir/file:
121 hg status -i ignoreddir/file:
122 I ignoreddir/file
123 adding .hgignore
124 adding deleted
125 adding modified
126 adding removed
General Comments 0
You need to be logged in to leave comments. Login now