comparison tests/test-status-color @ 7458:03dd55115985

color: Add tests for colorized diff and status output.
author Augie Fackler <durin42@gmail.com>
date Tue, 02 Dec 2008 10:13:52 -0600
parents
children 7b3d837ca60e
comparison
equal deleted inserted replaced
7457:a70fb83cbb9e 7458:03dd55115985
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