3 test_description
='ref_match.awk functionality'
9 ap
="$(tg --awk-path)" && test -n "$ap" && test -d "$ap" || die
11 test -f "$aprm" && test -r "$aprm" && test -x "$aprm" || die
15 test_expect_success
'ref_match runs' '
16 # some stupid awks might not even compile it
17 awk -f "$aprm" </dev/null
20 test_expect_success
'ref_match normal order' '
28 " && printf >expect "%s" "\
35 " && awk -f "$aprm" <input >actual &&
36 test_cmp expect actual
39 test_expect_success
'ref_match pckdrefs order' '
47 " && printf >expect "%s" "\
54 " && awk -v pckdrefs=1 -f "$aprm" <input >actual &&
55 test_cmp expect actual
58 test_expect_success
'ref_match duplicate elimination' '
68 " && printf >expect "%s" "\
75 " && awk -f "$aprm" <input >actual &&
76 test_cmp expect actual
79 test_expect_success
'ref_match duplicate retention' '
89 " && printf >expect "%s" "\
98 " && awk -v dupesok=1 -f "$aprm" <input >actual &&
99 test_cmp expect actual
102 test_expect_success
'ref_match formatted output' '
103 printf >input "%s" "\
112 " && printf >expect "%s" "\
125 " && awk -v matchfmt="%(refname) %3c%%%3E %(objectname)%0a%(objecttype)" -f "$aprm" <input >actual &&
126 test_cmp expect actual
129 test_expect_success
'ref_match formatted output with repeats' '
130 printf >input "%s" "\
139 " && printf >expect "%s" "\
152 " && awk -v matchfmt="%(refname) %3c%%%3E %(objectname)%0a%(objecttype)%(refname)" -f "$aprm" <input >actual &&
153 test_cmp expect actual
156 test_expect_success
'ref_match sort reversed' '
157 printf >input "%s" "\
166 " && printf >expect "%s" "\
173 " && awk -v sortkey="-refname" -f "$aprm" <input >actual &&
174 test_cmp expect actual
177 test_expect_success
'ref_match sort reversed with dupes' '
178 printf >input "%s" "\
187 " && printf >expect "%s" "\
196 " && awk -v sortkey="-refname" -v dupesok=1 -f "$aprm" <input >actual &&
197 test_cmp expect actual
200 test_expect_success
'ref_match one exact pattern' '
201 printf >input "%s" "\
210 " && printf >expect "%s" "\
212 " && awk -v patterns="refs/a" -f "$aprm" <input >actual &&
213 test_cmp expect actual
216 test_expect_success
'ref_match one exact pattern one input' '
217 printf >input "%s" "\
219 " && printf >expect "%s" "\
221 " && awk -v patterns="refs/a" -f "$aprm" <input >actual &&
222 test_cmp expect actual
225 test_expect_success
'ref_match one exact pattern one input with slash' '
226 printf >input "%s" "\
228 " && printf >expect "%s" "\
230 " && awk -v patterns="refs/a/" -f "$aprm" <input >actual &&
231 test_cmp expect actual
234 test_expect_success
'ref_match one prefix pattern' '
235 printf >input "%s" "\
244 " && printf >expect "%s" "\
248 " && awk -v patterns="refs/l" -f "$aprm" <input >actual &&
249 test_cmp expect actual
251 test_expect_success
'ref_match two patterns' '
252 printf >input "%s" "\
261 " && printf >expect "%s" "\
268 " && awk -v patterns="refs/n refs/l" -f "$aprm" <input >actual &&
269 test_cmp expect actual
272 test_expect_success
'ref_match output limit' '
273 printf >input "%s" "\
282 " && printf >expect "%s" "\
287 " && awk -v patterns="refs/n refs/l" -v maxout=4 -f "$aprm" <input >actual &&
288 test_cmp expect actual
291 test_expect_success
'ref_match objectname sort' '
292 printf >input "%s" "\
301 " && printf >expect "%s" "\
308 " && awk -v sortkey="objectname" -f "$aprm" <input >actual &&
309 test_cmp expect actual
312 test_expect_success
'ref_match objectname sort with dupes' '
313 printf >input "%s" "\
322 " && printf >expect "%s" "\
331 " && awk -v sortkey="objectname" -v dupesok=1 -f "$aprm" <input >actual &&
332 test_cmp expect actual
335 test_expect_success
'ref_match objectname sort with dupes reversed' '
336 printf >input "%s" "\
345 " && printf >expect "%s" "\
354 " && awk -v sortkey="-objectname" -v dupesok=1 -f "$aprm" <input >actual &&
355 test_cmp expect actual
358 test_expect_success
'ref_match -refname,-objectname sort with dupes' '
359 printf >input "%s" "\
368 " && printf >expect "%s" "\
377 " && awk -v sortkey="-refname,-objectname" -v dupesok=1 -f "$aprm" <input >actual &&
378 test_cmp expect actual
381 test_expect_success
'ref_match -refname,-objectname sort no dupes' '
382 printf >input "%s" "\
391 " && printf >expect "%s" "\
398 " && awk -v sortkey="-refname,-objectname" -f "$aprm" <input >actual &&
399 test_cmp expect actual
402 test_expect_success
'ref_match -refname,objectname sort no dupes' '
403 printf >input "%s" "\
412 " && printf >expect "%s" "\
419 " && awk -v sortkey="-refname,objectname" -f "$aprm" <input >actual &&
420 test_cmp expect actual