3 test_description
='topgit_deps.awk functionality'
7 ap
="$(tg --awk-path)" && test -n "$ap" && test -d "$ap" || die
9 test -f "$aptd" && test -r "$aptd" && test -x "$aptd" || die
11 # Final output of topgit_deps_prepare looks like:
13 # 5e6bd1db23329803939ffa1e1f9052e678ea4a06 t/sample
15 # That output then gets piped through this:
17 # git cat-file --batch='%(objecttype) %(objectsize) %(rest)' | tr '\0' '\27'
19 # and fed to the topgit_deps script. awk is not guaranteed to handle the
20 # NUL character so by running through tr (which is POSIXly supposed to) if
21 # some unfortunate blob is involved this topgit_deps script still has a
22 # chance of doing something correct with the result
24 # note that despite the format provided, "missing" will always be the second
25 # field output for missing objects
29 v_blobify
() { eval "$1="'"$(git hash-object -t blob -w --stdin)"'; }
30 v_blobify mtblob
</dev
/null || die
31 noeol
="$(printf '%s' "noeol
" | git hash-object -t blob -w --stdin)" || die
32 v_blobify mtline
<<-EOT || die
35 v_blobify looper
<<-EOT || die
38 v_blobify deps
<<-EOT || die
42 v_blobify alts
<<-EOT || die
46 v_blobify dupe2
<<-EOT || die
50 v_blobify dupe3
<<-EOT || die
55 v_blobify dupe32
<<-EOT || die
62 v_blobify looperduper
<<-EOT || die
71 v_blobify tens
<<-EOT || die
89 git cat-file
--batch='%(objecttype) %(objectsize) %(rest)' |
97 test_expect_success
'topgit_deps runs' '
98 # some stupid awks might not even compile it
99 awk -f "$aptd" </dev/null &&
100 # and make sure the helper works too
104 test_expect_success
'invalid anfile fails if read' '
105 rm -f no-such-file &&
106 test ! -e no-such-file &&
108 </dev/null dotgdeps -v anfile=no-such-file >actual &&
109 test_cmp actual expected &&
110 </dev/null dotgdeps -v withan=1 -v anfile=no-such-file >actual &&
111 test_cmp actual expected &&
112 echo "..." | test_must_fail dotgdeps -v anfile=no-such-file >actual &&
113 test_cmp actual expected &&
114 echo "..." | dotgdeps -v withan=1 -v anfile=no-such-file >actual &&
115 test_cmp actual expected &&
116 test ! -e no-such-file
119 test_expect_success
'invalid brfile fails if read' '
120 rm -f no-such-file &&
121 test ! -e no-such-file &&
123 </dev/null dotgdeps -v brfile=no-such-file >actual &&
124 test_cmp actual expected &&
125 </dev/null dotgdeps -v tgonly=1 -v brfile=no-such-file >actual &&
126 test_cmp actual expected &&
128 test_must_fail dotgdeps -v tgonly=1 -v brfile=no-such-file >actual &&
129 test_cmp actual expected &&
130 echo "..." | dotgdeps -v brfile=no-such-file >actual &&
131 test_cmp actual expected &&
132 test ! -e no-such-file
135 test_expect_success
'anfile unperturbed without rman' '
136 echo "an file here" >anorig &&
137 cat anorig >anfile &&
139 </dev/null dotgdeps -v anfile=anfile >actual &&
140 test_cmp actual expected &&
141 test_cmp anfile anorig &&
142 </dev/null dotgdeps -v withan=1 -v anfile=anfile >actual &&
143 test_cmp actual expected &&
144 test_cmp anfile anorig &&
145 echo "..." | dotgdeps -v anfile=anfile >actual &&
146 test_cmp actual expected &&
147 test_cmp anfile anorig &&
148 echo "..." | dotgdeps -v withan=1 -v anfile=anfile >actual &&
149 test_cmp actual expected &&
150 test_cmp anfile anorig
153 test_expect_success
'brfile unperturbed without rmbr' '
154 echo "br file here" >brorig &&
155 cat brorig >brfile &&
157 </dev/null dotgdeps -v brfile=brfile >actual &&
158 test_cmp actual expected &&
159 test_cmp brfile brorig &&
160 </dev/null dotgdeps -v tgonly=1 -v brfile=brfile >actual &&
161 test_cmp actual expected &&
162 test_cmp brfile brorig &&
163 echo "..." | dotgdeps -v brfile=brfile >actual &&
164 test_cmp actual expected &&
165 test_cmp brfile brorig &&
166 echo "..." | dotgdeps -v tgonly=1 -v brfile=brfile >actual &&
167 test_cmp actual expected &&
168 test_cmp brfile brorig
171 test_expect_success
'anfile removed with rman' '
172 echo "an file here" >anorig &&
174 cat anorig >anfile &&
175 </dev/null dotgdeps -v anfile=anfile -v rman=1 >actual &&
176 test_cmp actual expected &&
178 cat anorig >anfile &&
179 </dev/null dotgdeps -v withan=1 -v anfile=anfile -v rman=1 >actual &&
180 test_cmp actual expected &&
182 cat anorig >anfile &&
183 echo "..." | dotgdeps -v anfile=anfile -v rman=1 >actual &&
184 test_cmp actual expected &&
186 cat anorig >anfile &&
187 echo "..." | dotgdeps -v withan=1 -v anfile=anfile -v rman=1 >actual &&
188 test_cmp actual expected &&
192 test_expect_success
'brfile removed with rmbr' '
193 echo "br file here" >brorig &&
195 cat brorig >brfile &&
196 </dev/null dotgdeps -v brfile=brfile -v rmbr=1 >actual &&
197 test_cmp actual expected &&
199 cat brorig >brfile &&
200 </dev/null dotgdeps -v tgonly=1 -v brfile=brfile -v rmbr=1 >actual &&
201 test_cmp actual expected &&
203 cat brorig >brfile &&
204 echo "..." | dotgdeps -v brfile=brfile -v rmbr=1 >actual &&
205 test_cmp actual expected &&
207 cat brorig >brfile &&
208 echo "..." | dotgdeps -v tgonly=1 -v brfile=brfile -v rmbr=1 >actual &&
209 test_cmp actual expected &&
213 test_expect_success
'basic functionality' '
214 echo "t/basic dep1" >expected &&
215 echo "t/basic dep2" >>expected &&
216 echo "$deps t/basic" | dotgdeps >actual &&
217 test_cmp actual expected
220 test_expect_success
'basic noeol functionality' '
221 echo "t/noeol1 noeol" >expected &&
222 echo "t/basic dep1" >>expected &&
223 echo "t/basic dep2" >>expected &&
224 echo "t/noeol2 noeol" >>expected &&
225 <<-EOT dotgdeps >actual &&
230 test_cmp actual expected
233 test_expect_success
'basic functionality rev' '
234 echo "dep2 t/basic" >expected &&
235 echo "dep1 t/basic" >>expected &&
236 echo "$deps t/basic" | dotgdeps -v rev=1 >actual &&
237 test_cmp actual expected
240 test_expect_success
'basic functionality withbr' '
241 echo "t/basic dep1" >expected &&
242 echo "t/basic dep2" >>expected &&
243 echo "t/basic t/basic" >>expected &&
244 echo "$deps t/basic" | dotgdeps -v withbr=1 >actual &&
245 test_cmp actual expected
248 test_expect_success
'basic functionality withbr rev' '
249 echo "t/basic t/basic" >expected &&
250 echo "dep2 t/basic" >>expected &&
251 echo "dep1 t/basic" >>expected &&
252 echo "$deps t/basic" | dotgdeps -v withbr=1 -v rev=1 >actual &&
253 test_cmp actual expected
256 test_expect_success
'multi functionality' '
257 echo "t/basic dep1" >expected &&
258 echo "t/basic dep2" >>expected &&
259 echo "t/multi alt1" >>expected &&
260 echo "t/multi alt2" >>expected &&
261 <<-EOT dotgdeps >actual &&
265 test_cmp actual expected
268 test_expect_success
'multi functionality rev' '
269 echo "dep2 t/basic" >expected &&
270 echo "dep1 t/basic" >>expected &&
271 echo "alt2 t/multi" >>expected &&
272 echo "alt1 t/multi" >>expected &&
273 <<-EOT dotgdeps -v rev=1 >actual &&
277 test_cmp actual expected
280 test_expect_success
'multi functionality withbr' '
281 echo "t/basic dep1" >expected &&
282 echo "t/basic dep2" >>expected &&
283 echo "t/basic t/basic" >>expected &&
284 echo "t/multi alt1" >>expected &&
285 echo "t/multi alt2" >>expected &&
286 echo "t/multi t/multi" >>expected &&
287 <<-EOT dotgdeps -v withbr=1 >actual &&
291 test_cmp actual expected
294 test_expect_success
'multi functionality rev withbr' '
295 echo "t/basic t/basic" >expected &&
296 echo "dep2 t/basic" >>expected &&
297 echo "dep1 t/basic" >>expected &&
298 echo "t/multi t/multi" >>expected &&
299 echo "alt2 t/multi" >>expected &&
300 echo "alt1 t/multi" >>expected &&
301 <<-EOT dotgdeps -v rev=1 -v withbr=1 >actual &&
305 test_cmp actual expected
308 test_expect_success
'self loop omitted' '
310 echo "$looper looper" | dotgdeps >actual &&
311 test_cmp actual expected
314 test_expect_success
'self loop omitted withbr' '
315 echo "looper looper" >expected &&
316 echo "$looper looper" | dotgdeps -v withbr=1 >actual &&
317 test_cmp actual expected
320 test_expect_success
'dupes omitted' '
321 echo "t/check dupe" >expected &&
322 echo "$dupe2 t/check" | dotgdeps >actual &&
323 test_cmp actual expected &&
324 echo "$dupe3 t/check" | dotgdeps >actual &&
325 test_cmp actual expected
328 test_expect_success
'dupes omitted withbr' '
329 echo "t/check dupe" >expected &&
330 echo "t/check t/check" >>expected &&
331 echo "$dupe2 t/check" | dotgdeps -v withbr=1 >actual &&
332 test_cmp actual expected &&
333 echo "$dupe3 t/check" | dotgdeps -v withbr=1 >actual &&
334 test_cmp actual expected
337 test_expect_success
'multi dupes omitted' '
338 echo "t/check dupe" >expected &&
339 echo "t/check dupe" >>expected &&
340 echo "t/check2 dupe" >>expected &&
341 echo "t/check2 dupe" >>expected &&
342 <<-EOT dotgdeps >actual &&
348 test_cmp actual expected
351 test_expect_success
'multi dupes omitted withbr' '
352 echo "t/check dupe" >expected &&
353 echo "t/check t/check" >>expected &&
354 echo "t/check dupe" >>expected &&
355 echo "t/check t/check" >>expected &&
356 echo "t/check2 dupe" >>expected &&
357 echo "t/check2 t/check2" >>expected &&
358 echo "t/check2 dupe" >>expected &&
359 echo "t/check2 t/check2" >>expected &&
360 <<-EOT dotgdeps -v withbr=1 >actual &&
366 test_cmp actual expected
369 test_expect_success
'super multi loop dupes omitted' '
370 echo "t/check dupe" >expected &&
371 echo "t/check two" >>expected &&
372 echo "looper dupe" >>expected &&
373 echo "looper two" >>expected &&
374 <<-EOT dotgdeps >actual &&
378 test_cmp actual expected
381 test_expect_success
'super multi loop dupes omitted rev' '
382 echo "two t/check" >expected &&
383 echo "dupe t/check" >>expected &&
384 echo "two looper" >>expected &&
385 echo "dupe looper" >>expected &&
386 <<-EOT dotgdeps -v rev=1 >actual &&
390 test_cmp actual expected
393 test_expect_success
'super multi loop dupes omitted withbr' '
394 echo "t/check dupe" >expected &&
395 echo "t/check two" >>expected &&
396 echo "t/check t/check" >>expected &&
397 echo "looper dupe" >>expected &&
398 echo "looper two" >>expected &&
399 echo "looper looper" >>expected &&
400 <<-EOT dotgdeps -v withbr=1 >actual &&
404 test_cmp actual expected
407 test_expect_success
'super multi loop dupes omitted rev withbr' '
408 echo "t/check t/check" >expected &&
409 echo "two t/check" >>expected &&
410 echo "dupe t/check" >>expected &&
411 echo "looper looper" >>expected &&
412 echo "two looper" >>expected &&
413 echo "dupe looper" >>expected &&
414 <<-EOT dotgdeps -v rev=1 -v withbr=1 >actual &&
418 test_cmp actual expected
421 test_expect_success
'exclbr other' '
422 for b in one two three four five six seven eight nine ten; do
425 echo "$tens t/excl" | dotgdeps -v exclbr="other" >actual &&
426 test_cmp actual expected
429 test_expect_success
'exclbr even' '
430 for b in one three five seven nine; do
433 echo "$tens t/excl" |
434 dotgdeps -v exclbr="two four six eight ten" >actual &&
435 test_cmp actual expected
438 test_expect_success
'exclbr odd' '
439 for b in two four six eight ten; do
442 echo "$tens t/excl" |
443 dotgdeps -v exclbr="one three five seven nine" >actual &&
444 test_cmp actual expected
447 test_expect_success
'exclbr primes' '
448 for b in one four six eight nine ten; do
451 echo "$tens t/excl" |
452 dotgdeps -v exclbr="two three five seven" >actual &&
453 test_cmp actual expected
456 test_expect_success
'inclbr other' '
458 echo "$tens t/excl" | dotgdeps -v inclbr="other" >actual &&
459 test_cmp actual expected
462 test_expect_success
'inclbr even' '
463 for b in two four six eight ten; do
466 echo "$tens t/excl" |
467 dotgdeps -v inclbr="two four six eight ten" >actual &&
468 test_cmp actual expected
471 test_expect_success
'inclbr odd' '
472 for b in one three five seven nine; do
475 echo "$tens t/excl" |
476 dotgdeps -v inclbr="one three five seven nine" >actual &&
477 test_cmp actual expected
480 test_expect_success
'inclbr primes' '
481 for b in two three five seven; do
484 echo "$tens t/excl" |
485 dotgdeps -v inclbr="two three five seven" >actual &&
486 test_cmp actual expected
489 test_expect_success
'inclbr odd exclbr primes' '
490 echo "t/incexc one" >expected &&
491 echo "t/incexc nine" >>expected &&
492 echo "t/excinc one" >>expected &&
493 echo "t/excinc nine" >>expected &&
494 <<-EOT dotgdeps -v inclbr="one three five seven nine" \
495 -v exclbr="two three five seven" >actual &&
499 test_cmp actual expected
502 test_expect_success
'exclbr even inclbr primes rev withbr' '
503 echo "seven t/excinc" >expected &&
504 echo "five t/excinc" >>expected &&
505 echo "three t/excinc" >>expected &&
506 echo "t/incexc t/incexc" >>expected &&
507 echo "nine t/incexc" >>expected &&
508 echo "seven t/incexc" >>expected &&
509 echo "five t/incexc" >>expected &&
510 echo "three t/incexc" >>expected &&
511 echo "one t/incexc" >>expected &&
512 <<-EOT dotgdeps -v rev=1 -v withbr=1 \
513 -v exclbr="two four six eight ten" \
514 -v inclbr="two three t/incexc five seven" >actual &&
518 test_cmp actual expected
521 test_expect_success
'exclbr branch deps inclbr rev' '
522 echo "seven t/second" >expected &&
523 <<-EOT dotgdeps -v rev=1 -v exclbr=t/first -v inclbr=seven >actual &&
527 test_cmp actual expected
530 test_expect_success
'anfile works' '
531 echo "t/top dep1" >expected &&
532 echo "t/top dep2" >>expected &&
533 echo "t/top t/top" >>expected &&
534 echo "dep1 dep1" >>expected &&
535 echo "dep2 dep2" >>expected &&
536 echo "dep1" >anfile &&
537 <<-EOT dotgdeps -v withbr=1 >actual &&
542 test_cmp actual expected &&
543 <<-EOT dotgdeps -v withbr=1 -v withan=1 -v anfile=anfile >actual &&
548 test_cmp actual expected &&
549 echo "t/top dep2" >expected &&
550 echo "t/top t/top" >>expected &&
551 echo "dep2 dep2" >>expected &&
552 <<-EOT dotgdeps -v withbr=1 -v anfile=anfile >actual &&
557 test_cmp actual expected &&
558 echo "t/top dep1" >expected &&
559 echo "t/top dep2" >>expected &&
560 <<-EOT dotgdeps >actual &&
565 test_cmp actual expected &&
566 <<-EOT dotgdeps -v withan=1 -v anfile=anfile >actual &&
571 test_cmp actual expected &&
572 echo "t/top dep2" >expected &&
573 <<-EOT dotgdeps -v anfile=anfile >actual &&
578 test_cmp actual expected
581 test_expect_success
'brfile works' '
582 echo "t/top dep1" >expected &&
583 echo "t/top dep2" >>expected &&
584 echo "t/top t/top" >>expected &&
585 echo "dep1 dep1" >>expected &&
586 echo "dep2 dep2" >>expected &&
587 echo "t/top" >brfile &&
588 <<-EOT dotgdeps -v withbr=1 >actual &&
593 test_cmp actual expected &&
594 <<-EOT dotgdeps -v withbr=1 -v brfile=brfile >actual &&
599 test_cmp actual expected &&
600 echo "t/top t/top" >expected &&
601 <<-EOT dotgdeps -v withbr=1 -v brfile=brfile -v tgonly=1 >actual &&
606 test_cmp actual expected &&
607 echo "t/top dep1" >expected &&
608 echo "t/top dep2" >>expected &&
609 <<-EOT dotgdeps >actual &&
614 test_cmp actual expected &&
615 <<-EOT dotgdeps -v brfile=brfile >actual &&
620 test_cmp actual expected &&
622 <<-EOT dotgdeps -v brfile=brfile -v tgonly=1 >actual &&
627 test_cmp actual expected
630 test_expect_success
'anfile + brfile works' '
641 echo "alt2" >>anfl &&
642 echo "t/top" >brfl &&
643 echo "dupe" >>brfl &&
645 echo "alt2" >>brfl &&
646 <<-EOT cat >expected &&
661 <input dotgdeps -v withbr=1 >actual &&
662 test_cmp actual expected &&
663 <input dotgdeps -v withbr=1 -v brfile=brfl >actual &&
664 test_cmp actual expected &&
665 <input dotgdeps -v withbr=1 -v anfile=anfl -v withan=1 >actual &&
666 test_cmp actual expected &&
667 <input dotgdeps -v withbr=1 -v brfile=brfl -v anfile=anfl -v withan=1 >actual &&
668 test_cmp actual expected &&
669 <<-EOT cat >expected &&
678 <input dotgdeps -v withbr=1 -v brfile=brfl -v tgonly=1 >actual &&
679 test_cmp actual expected &&
680 <input dotgdeps -v withbr=1 -v brfile=brfl -v anfile=anfl -v withan=1 -v tgonly=1 >actual &&
681 test_cmp actual expected &&
682 <<-EOT cat >expected &&
693 <input dotgdeps -v withbr=1 -v anfile=anfl >actual &&
694 test_cmp actual expected &&
695 <input dotgdeps -v withbr=1 -v brfile=brfl -v anfile=anfl >actual &&
696 test_cmp actual expected &&
697 <<-EOT cat >expected &&
704 <input dotgdeps -v withbr=1 -v brfile=brfl -v anfile=anfl -v tgonly=1 >actual &&
705 test_cmp actual expected &&
707 # again but now without withbr=1
709 <<-EOT cat >expected &&
717 <input dotgdeps >actual &&
718 test_cmp actual expected &&
719 <input dotgdeps -v brfile=brfl >actual &&
720 test_cmp actual expected &&
721 <input dotgdeps -v anfile=anfl -v withan=1 >actual &&
722 test_cmp actual expected &&
723 <input dotgdeps -v brfile=brfl -v anfile=anfl -v withan=1 >actual &&
724 test_cmp actual expected &&
725 <<-EOT cat >expected &&
730 <input dotgdeps -v brfile=brfl -v tgonly=1 >actual &&
731 test_cmp actual expected &&
732 <input dotgdeps -v brfile=brfl -v anfile=anfl -v withan=1 -v tgonly=1 >actual &&
733 test_cmp actual expected &&
734 <<-EOT cat >expected &&
740 <input dotgdeps -v anfile=anfl >actual &&
741 test_cmp actual expected &&
742 <input dotgdeps -v brfile=brfl -v anfile=anfl >actual &&
743 test_cmp actual expected &&
744 <<-EOT cat >expected &&
748 <input dotgdeps -v brfile=brfl -v anfile=anfl -v tgonly=1 >actual &&
749 test_cmp actual expected