##// END OF EJS Templates
tests: unify test-grep
Nicolas Dumazet -
r11902:3c9a5ed9 default
parent child Browse files
Show More
@@ -1,100 +1,164
1 #!/bin/sh
1 $ mkdir t
2 $ cd t
3 $ hg init
4 $ echo import > port
5 $ hg add port
6 $ hg commit -m 0 -u spam -d '0 0'
7 $ echo export >> port
8 $ hg commit -m 1 -u eggs -d '1 0'
9 $ echo export > port
10 $ echo vaportight >> port
11 $ echo 'import/export' >> port
12 $ hg commit -m 2 -u spam -d '2 0'
13 $ echo 'import/export' >> port
14 $ hg commit -m 3 -u eggs -d '3 0'
15 $ head -n 3 port > port1
16 $ mv port1 port
17 $ hg commit -m 4 -u spam -d '4 0'
18
19 pattern error
20
21 $ hg grep '**test**'
22 grep: invalid match pattern: nothing to repeat
23
24 simple
25
26 $ hg grep port port
27 port:4:export
28 port:4:vaportight
29 port:4:import/export
30
31 simple with color
32
33 $ hg --config extensions.color= grep --config color.mode=ansi \
34 > --color=always port port
35 port:4:export
36 port:4:vaportight
37 port:4:import/export
2
38
3 mkdir t
39 all
4 cd t
40
5 hg init
41 $ hg grep --traceback --all -nu port port
6 echo import > port
42 port:4:4:-:spam:import/export
7 hg add port
43 port:3:4:+:eggs:import/export
8 hg commit -m 0 -u spam -d '0 0'
44 port:2:1:-:spam:import
9 echo export >> port
45 port:2:2:-:spam:export
10 hg commit -m 1 -u eggs -d '1 0'
46 port:2:1:+:spam:export
11 echo export > port
47 port:2:2:+:spam:vaportight
12 echo vaportight >> port
48 port:2:3:+:spam:import/export
13 echo 'import/export' >> port
49 port:1:2:+:eggs:export
14 hg commit -m 2 -u spam -d '2 0'
50 port:0:1:+:spam:import
15 echo 'import/export' >> port
51
16 hg commit -m 3 -u eggs -d '3 0'
52 other
17 head -n 3 port > port1
53
18 mv port1 port
54 $ hg grep import port
19 hg commit -m 4 -u spam -d '4 0'
55 port:4:import/export
20 echo % pattern error
21 hg grep '**test**'
22 echo % simple
23 hg grep port port
24 echo % simple with color
25 hg --config extensions.color= grep --config color.mode=ansi \
26 --color=always port port
27 echo % all
28 hg grep --traceback --all -nu port port
29 echo % other
30 hg grep import port
31
56
32 hg cp port port2
57 $ hg cp port port2
33 hg commit -m 4 -u spam -d '5 0'
58 $ hg commit -m 4 -u spam -d '5 0'
34 echo % follow
59
35 hg grep --traceback -f 'import$' port2
60 follow
36 echo deport >> port2
61
37 hg commit -m 5 -u eggs -d '6 0'
62 $ hg grep --traceback -f 'import$' port2
38 hg grep -f --all -nu port port2
63 port:0:import
64 $ echo deport >> port2
65 $ hg commit -m 5 -u eggs -d '6 0'
66 $ hg grep -f --all -nu port port2
67 port2:6:4:+:eggs:deport
68 port:4:4:-:spam:import/export
69 port:3:4:+:eggs:import/export
70 port:2:1:-:spam:import
71 port:2:2:-:spam:export
72 port:2:1:+:spam:export
73 port:2:2:+:spam:vaportight
74 port:2:3:+:spam:import/export
75 port:1:2:+:eggs:export
76 port:0:1:+:spam:import
39
77
40 cd ..
78 $ cd ..
41 hg init t2
79 $ hg init t2
42 cd t2
80 $ cd t2
43 hg grep foobar foo
81 $ hg grep foobar foo
44 hg grep foobar
82 $ hg grep foobar
45 echo blue >> color
83 $ echo blue >> color
46 echo black >> color
84 $ echo black >> color
47 hg add color
85 $ hg add color
48 hg ci -m 0
86 $ hg ci -m 0
49 echo orange >> color
87 $ echo orange >> color
50 hg ci -m 1
88 $ hg ci -m 1
51 echo black > color
89 $ echo black > color
52 hg ci -m 2
90 $ hg ci -m 2
53 echo orange >> color
91 $ echo orange >> color
54 echo blue >> color
92 $ echo blue >> color
55 hg ci -m 3
93 $ hg ci -m 3
56 hg grep orange
94 $ hg grep orange
57 hg grep --all orange
95 color:3:orange
96 $ hg grep --all orange
97 color:3:+:orange
98 color:2:-:orange
99 color:1:+:orange
58
100
59 echo % match in last "line" without newline
101
60 python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
102 match in last "line" without newline
61 hg ci -Amnoeol
103
62 echo % last character omitted in output to avoid infinite loop
104 $ python -c 'fp = open("noeol", "wb"); fp.write("no infinite loop"); fp.close();'
63 hg grep loop
105 $ hg ci -Amnoeol
106 adding noeol
107
108 last character omitted in output to avoid infinite loop
109
110 $ hg grep loop
111 noeol:4:no infinite loo
112
113
114 $ cd ..
115
116 Got a traceback when using grep on a single
117 revision with renamed files.
118 issue 685
64
119
65 # Got a traceback when using grep on a single
120 $ hg init issue685
66 # revision with renamed files.
121 $ cd issue685
67 cd ..
122 $ echo octarine > color
68 echo % issue 685
123 $ hg ci -Amcolor
69 hg init issue685
124 adding color
70 cd issue685
125 $ hg rename color colour
71 echo octarine > color
126 $ hg ci -Am rename
72 hg ci -Amcolor
127 $ hg grep octarine
73 hg rename color colour
128 colour:1:octarine
74 hg ci -Am rename
129 color:0:octarine
75 hg grep octarine
130
76 # Used to crash here
131 Used to crash here
77 hg grep -r 1 octarine
132
133 $ hg grep -r 1 octarine
134 colour:1:octarine
135 $ cd ..
136
137
138 Issue337: test that grep follows parent-child relationships instead
139 of just using revision numbers.
78
140
79 # Issue337: test that grep follows parent-child relationships instead
141 $ hg init issue337
80 # of just using revision numbers.
142 $ cd issue337
81 cd ..
82 echo % issue 337
83 hg init issue337
84 cd issue337
85
143
86 echo white > color
144 $ echo white > color
87 hg commit -A -m "0 white"
145 $ hg commit -A -m "0 white"
146 adding color
147
148 $ echo red > color
149 $ hg commit -A -m "1 red"
88
150
89 echo red > color
151 $ hg update 0
90 hg commit -A -m "1 red"
152 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
153 $ echo black > color
154 $ hg commit -A -m "2 black"
155 created new head
91
156
92 hg update 0
157 $ hg update --clean 1
93 echo black > color
158 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
94 hg commit -A -m "2 black"
159 $ echo blue > color
160 $ hg commit -A -m "3 blue"
95
161
96 hg update --clean 1
162 $ hg grep --all red
97 echo blue > color
163 color:3:-:red
98 hg commit -A -m "3 blue"
164 color:1:+:red
99
100 hg grep --all red
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now