git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
blob badd82d8a485a9c28b5be1513674473d7d806045 17526 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
 
#!/bin/sh

test_description='Test the dir-iterator functionality'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup -- dir with a single file' '
	mkdir dir1 &&
	>dir1/a
'
test_expect_success 'dirs-ignore of dir with a file' '
	cat >expected-out <<-EOF &&
	[f] (a) [a] ./dir1/a
	EOF

	test-tool dir-iterator ./dir1 >actual-out &&
	test_cmp expected-out actual-out
'
test_expect_success 'dirs-before of dir with a file' '
	cat >expected-out <<-EOF &&
	[f] (a) [a] ./dir1/a
	EOF

	test-tool dir-iterator --dirs-before ./dir1 >actual-out &&
	test_cmp expected-out actual-out
'

test_expect_success 'setup -- dir with a single dir' '
	mkdir -p dir2/a
'
test_expect_success 'dirs-ignore of dir with a single dir' '
	cat >expected-out <<-EOF &&
	EOF

	test-tool dir-iterator ./dir2 >actual-out &&
	test_cmp expected-out actual-out
'
test_expect_success 'dirs-before of dir with a single dir' '
	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir2/a
	EOF

	test-tool dir-iterator --dirs-before ./dir2 >actual-out &&
	test_cmp expected-out actual-out
'

test_expect_success POSIXPERM,SANITY 'setup -- dir w/ single dir w/o perms' '
	mkdir -p dir3/a
'
test_expect_success POSIXPERM,SANITY 'dirs-ignore of dir w/ dir w/o perms' '
	cat >expected-out <<-EOF &&
	EOF

	chmod 0 dir3/a &&

	test-tool dir-iterator ./dir3/ >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir3/a
'
test_expect_success POSIXPERM,SANITY 'pedantic dirs-ignore of dir w/ dir w/o perms' '
	cat >expected-out <<-EOF &&
	dir_iterator_advance failure: EACCES
	EOF

	chmod 0 dir3/a &&

	test_must_fail test-tool dir-iterator --pedantic ./dir3/ >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir3/a
'
test_expect_success POSIXPERM,SANITY 'dirs-before of dir w/ dir w/o perms' '
	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir3/a
	EOF

	chmod 0 dir3/a &&

	test-tool dir-iterator --dirs-before ./dir3/ >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir3/a
'
test_expect_success POSIXPERM,SANITY 'pedantic dirs-before of dir w/ dir w/o perms' '
	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir3/a
	dir_iterator_advance failure: EACCES
	EOF

	chmod 0 dir3/a &&

	test_must_fail test-tool dir-iterator --dirs-before \
		--pedantic ./dir3/ >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir3/a
'

test_expect_success 'setup -- dir w/ five files' '
	mkdir dir4 &&
	>dir4/a &&
	>dir4/b &&
	>dir4/c &&
	>dir4/d &&
	>dir4/e
'
test_expect_success 'dirs-ignore of dir w/ five files' '
	cat >expected-sorted-out <<-EOF &&
	[f] (a) [a] ./dir4/a
	[f] (b) [b] ./dir4/b
	[f] (c) [c] ./dir4/c
	[f] (d) [d] ./dir4/d
	[f] (e) [e] ./dir4/e
	EOF

	test-tool dir-iterator ./dir4 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success 'dirs-before of dir w/ five files' '
	cat >expected-sorted-out <<-EOF &&
	[f] (a) [a] ./dir4/a
	[f] (b) [b] ./dir4/b
	[f] (c) [c] ./dir4/c
	[f] (d) [d] ./dir4/d
	[f] (e) [e] ./dir4/e
	EOF

	test-tool dir-iterator --dirs-before ./dir4 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'

test_expect_success 'setup -- dir w/ dir w/ a file' '
	mkdir -p dir5/a &&
	>dir5/a/b
'
test_expect_success 'dirs-ignore of dir w/ dir w/ a file' '
	cat >expected-out <<-EOF &&
	[f] (a/b) [b] ./dir5/a/b
	EOF

	test-tool dir-iterator ./dir5 >actual-out &&
	test_cmp expected-out actual-out
'
test_expect_success 'dirs-before of dir w/ dir w/ a file' '
	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir5/a
	[f] (a/b) [b] ./dir5/a/b
	EOF

	test-tool dir-iterator --dirs-before ./dir5 >actual-out &&
	test_cmp expected-out actual-out
'

test_expect_success 'setup -- dir w/ three nested dirs w/ file' '
	mkdir -p dir6/a/b/c &&
	>dir6/a/b/c/d
'
test_expect_success 'dirs-ignore of dir w/ three nested dirs w/ file' '
	cat >expected-out <<-EOF &&
	[f] (a/b/c/d) [d] ./dir6/a/b/c/d
	EOF

	test-tool dir-iterator ./dir6 >actual-out &&
	test_cmp expected-out actual-out
'
test_expect_success 'dirs-before of dir w/ three nested dirs w/ file' '
	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir6/a
	[d] (a/b) [b] ./dir6/a/b
	[d] (a/b/c) [c] ./dir6/a/b/c
	[f] (a/b/c/d) [d] ./dir6/a/b/c/d
	EOF

	test-tool dir-iterator --dirs-before ./dir6 >actual-out &&
	test_cmp expected-out actual-out
'

test_expect_success POSIXPERM,SANITY \
'setup -- dir w/ three nested dirs w/ file, second nested dir w/o perms' '

	mkdir -p dir7/a/b/c &&
	>dir7/a/b/c/d
'
test_expect_success POSIXPERM,SANITY \
'dirs-ignore of dir w/ three nested dirs w/ file, second w/o perms' '

	cat >expected-out <<-EOF &&
	EOF

	chmod 0 dir7/a/b &&

	test-tool dir-iterator ./dir7 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir7/a/b
'
test_expect_success POSIXPERM,SANITY \
'pedantic dirs-ignore of dir w/ three nested dirs w/ file, second w/o perms' '

	cat >expected-out <<-EOF &&
	dir_iterator_advance failure: EACCES
	EOF

	chmod 0 dir7/a/b &&

	test_must_fail test-tool dir-iterator --pedantic ./dir7 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir7/a/b
'
test_expect_success POSIXPERM,SANITY \
'dirs-before of dir w/ three nested dirs w/ file, second w/o perms' '

	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir7/a
	[d] (a/b) [b] ./dir7/a/b
	EOF

	chmod 0 dir7/a/b &&

	test-tool dir-iterator --dirs-before ./dir7 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir7/a/b
'
test_expect_success POSIXPERM,SANITY \
'pedantic dirs-before of dir w/ three nested dirs w/ file, second w/o perms' '

	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir7/a
	[d] (a/b) [b] ./dir7/a/b
	dir_iterator_advance failure: EACCES
	EOF

	chmod 0 dir7/a/b &&

	test_must_fail test-tool dir-iterator --dirs-before \
		--pedantic ./dir7 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir7/a/b
'

test_expect_success 'setup -- dir w/ two dirs each w/ file' '
	mkdir -p dir8/a &&
	>dir8/a/b &&
	mkdir dir8/c &&
	>dir8/c/d
'
test_expect_success 'dirs-ignore of dir w/ two dirs each w/ file' '
	cat >expected-out1 <<-EOF &&
	[f] (a/b) [b] ./dir8/a/b
	[f] (c/d) [d] ./dir8/c/d
	EOF
	cat >expected-out2 <<-EOF &&
	[f] (c/d) [d] ./dir8/c/d
	[f] (a/b) [b] ./dir8/a/b
	EOF

	test-tool dir-iterator ./dir8 >actual-out &&
	(
		test_cmp expected-out1 actual-out ||
		test_cmp expected-out2 actual-out
	)
'
test_expect_success 'dirs-before of dir w/ two dirs each w/ file' '
	cat >expected-out1 <<-EOF &&
	[d] (a) [a] ./dir8/a
	[f] (a/b) [b] ./dir8/a/b
	[d] (c) [c] ./dir8/c
	[f] (c/d) [d] ./dir8/c/d
	EOF
	cat >expected-out2 <<-EOF &&
	[d] (c) [c] ./dir8/c
	[f] (c/d) [d] ./dir8/c/d
	[d] (a) [a] ./dir8/a
	[f] (a/b) [b] ./dir8/a/b
	EOF

	test-tool dir-iterator --dirs-before ./dir8 >actual-out &&
	(
		test_cmp expected-out1 actual-out ||
		test_cmp expected-out2 actual-out
	)
'

test_expect_success 'setup -- dir w/ two dirs, one w/ two and one w/ one files' '
	mkdir -p dir9/a &&
	>dir9/a/b &&
	>dir9/a/c &&
	mkdir dir9/d &&
	>dir9/d/e
'
test_expect_success \
'dirs-ignore of dir w/ two dirs, one w/ two and one w/ one files' '

	cat >expected-out1 <<-EOF &&
	[f] (a/b) [b] ./dir9/a/b
	[f] (a/c) [c] ./dir9/a/c
	[f] (d/e) [e] ./dir9/d/e
	EOF
	cat >expected-out2 <<-EOF &&
	[f] (a/c) [c] ./dir9/a/c
	[f] (a/b) [b] ./dir9/a/b
	[f] (d/e) [e] ./dir9/d/e
	EOF
	cat >expected-out3 <<-EOF &&
	[f] (d/e) [e] ./dir9/d/e
	[f] (a/b) [b] ./dir9/a/b
	[f] (a/c) [c] ./dir9/a/c
	EOF
	cat >expected-out4 <<-EOF &&
	[f] (d/e) [e] ./dir9/d/e
	[f] (a/c) [c] ./dir9/a/c
	[f] (a/b) [b] ./dir9/a/b
	EOF

	test-tool dir-iterator ./dir9 >actual-out &&
	(
		test_cmp expected-out1 actual-out ||
		test_cmp expected-out2 actual-out ||
		test_cmp expected-out3 actual-out ||
		test_cmp expected-out4 actual-out
	)
'
test_expect_success \
'dirs-before of dir w/ two dirs, one w/ two and one w/ one files' '

	cat >expected-out1 <<-EOF &&
	[d] (a) [a] ./dir9/a
	[f] (a/b) [b] ./dir9/a/b
	[f] (a/c) [c] ./dir9/a/c
	[d] (d) [d] ./dir9/d
	[f] (d/e) [e] ./dir9/d/e
	EOF
	cat >expected-out2 <<-EOF &&
	[d] (a) [a] ./dir9/a
	[f] (a/c) [c] ./dir9/a/c
	[f] (a/b) [b] ./dir9/a/b
	[d] (d) [d] ./dir9/d
	[f] (d/e) [e] ./dir9/d/e
	EOF
	cat >expected-out3 <<-EOF &&
	[d] (d) [d] ./dir9/d
	[f] (d/e) [e] ./dir9/d/e
	[d] (a) [a] ./dir9/a
	[f] (a/b) [b] ./dir9/a/b
	[f] (a/c) [c] ./dir9/a/c
	EOF
	cat >expected-out4 <<-EOF &&
	[d] (d) [d] ./dir9/d
	[f] (d/e) [e] ./dir9/d/e
	[d] (a) [a] ./dir9/a
	[f] (a/c) [c] ./dir9/a/c
	[f] (a/b) [b] ./dir9/a/b
	EOF

	test-tool dir-iterator --dirs-before ./dir9 >actual-out &&
	(
		test_cmp expected-out1 actual-out ||
		test_cmp expected-out2 actual-out ||
		test_cmp expected-out3 actual-out ||
		test_cmp expected-out4 actual-out
	)
'

test_expect_success 'setup -- dir w/ two nested dirs, each w/ file' '
	mkdir -p dir10/a &&
	>dir10/a/b &&
	mkdir dir10/a/c &&
	>dir10/a/c/d
'
test_expect_success 'dirs-ignore of dir w/ two nested dirs, each w/ file' '
	cat >expected-out1 <<-EOF &&
	[f] (a/b) [b] ./dir10/a/b
	[f] (a/c/d) [d] ./dir10/a/c/d
	EOF
	cat >expected-out2 <<-EOF &&
	[f] (a/c/d) [d] ./dir10/a/c/d
	[f] (a/b) [b] ./dir10/a/b
	EOF

	test-tool dir-iterator ./dir10/ >actual-out &&
	(
		test_cmp expected-out1 actual-out ||
		test_cmp expected-out2 actual-out
	)
'
test_expect_success 'dirs-before of dir w/ two nested dirs, each w/ file' '
	cat >expected-out1 <<-EOF &&
	[d] (a) [a] ./dir10/a
	[f] (a/b) [b] ./dir10/a/b
	[d] (a/c) [c] ./dir10/a/c
	[f] (a/c/d) [d] ./dir10/a/c/d
	EOF
	cat >expected-out2 <<-EOF &&
	[d] (a) [a] ./dir10/a
	[d] (a/c) [c] ./dir10/a/c
	[f] (a/c/d) [d] ./dir10/a/c/d
	[f] (a/b) [b] ./dir10/a/b
	EOF

	test-tool dir-iterator --dirs-before ./dir10/ >actual-out &&
	(
		test_cmp expected-out1 actual-out ||
		test_cmp expected-out2 actual-out
	)
'

test_expect_success 'setup -- dir w/ complex structure' '
	mkdir -p dir11 &&
	mkdir -p dir11/a/b/c/ &&
	>dir11/b &&
	>dir11/c &&
	mkdir -p dir11/d/e/d/ &&
	>dir11/a/b/c/d &&
	>dir11/a/e &&
	>dir11/d/e/d/a
'
test_expect_success 'dirs-ignore of dir w/ complex structure' '
	cat >expected-sorted-out <<-EOF &&
	[f] (a/b/c/d) [d] ./dir11/a/b/c/d
	[f] (a/e) [e] ./dir11/a/e
	[f] (b) [b] ./dir11/b
	[f] (c) [c] ./dir11/c
	[f] (d/e/d/a) [a] ./dir11/d/e/d/a
	EOF

	test-tool dir-iterator ./dir11 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success 'dirs-before of dir w/ complex structure' '
	cat >expected-sorted-out <<-EOF &&
	[d] (a) [a] ./dir11/a
	[d] (a/b) [b] ./dir11/a/b
	[d] (a/b/c) [c] ./dir11/a/b/c
	[d] (d) [d] ./dir11/d
	[d] (d/e) [e] ./dir11/d/e
	[d] (d/e/d) [d] ./dir11/d/e/d
	[f] (a/b/c/d) [d] ./dir11/a/b/c/d
	[f] (a/e) [e] ./dir11/a/e
	[f] (b) [b] ./dir11/b
	[f] (c) [c] ./dir11/c
	[f] (d/e/d/a) [a] ./dir11/d/e/d/a
	EOF

	test-tool dir-iterator --dirs-before ./dir11 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'

test_expect_success POSIXPERM,SANITY 'setup -- dir w/o perms' '
	mkdir -p dir12/a &&
	>dir12/a/b
'
test_expect_success POSIXPERM,SANITY 'dirs-ignore of root dir w/o perms' '
	cat >expected-out <<-EOF &&
	dir_iterator_begin failure: EACCES
	EOF

	chmod 0 dir12 &&

	test_must_fail test-tool dir-iterator ./dir12 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir12
'
test_expect_success POSIXPERM,SANITY 'pedantic dirs-ignore of root dir w/o perms' '
	cat >expected-out <<-EOF &&
	dir_iterator_begin failure: EACCES
	EOF

	chmod 0 dir12 &&

	test_must_fail test-tool dir-iterator --pedantic ./dir12 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir12
'
test_expect_success POSIXPERM,SANITY 'dirs-before of root dir w/o perms' '
	cat >expected-out <<-EOF &&
	dir_iterator_begin failure: EACCES
	EOF

	chmod 0 dir12 &&

	test_must_fail test-tool dir-iterator --dirs-before ./dir12 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir12
'
test_expect_success POSIXPERM,SANITY 'pedantic dirs-before of root dir w/o perms' '
	cat >expected-out <<-EOF &&
	dir_iterator_begin failure: EACCES
	EOF

	chmod 0 dir12 &&

	test_must_fail test-tool dir-iterator --dirs-before \
		--pedantic ./dir12 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir12
'

test_expect_success 'begin should fail upon inexistent paths' '
	echo "dir_iterator_begin failure: ENOENT" >expected-out &&

	test_must_fail test-tool dir-iterator ./inexistent-path >actual-out &&

	test_cmp expected-out actual-out
'

test_expect_success 'begin should fail upon non directory paths' '
	>some-file &&

	echo "dir_iterator_begin failure: ENOTDIR" >expected-out &&

	test_must_fail test-tool dir-iterator ./some-file >actual-out &&

	test_cmp expected-out actual-out
'

test_expect_success POSIXPERM,SANITY 'setup -- dir w/ dir w/o perms w/ file' '
	mkdir -p dir13/a &&
	>dir13/a/b
'
test_expect_success POSIXPERM,SANITY \
'dirs-ignore of dir w/ dir w/o perms w/ file' '

	cat >expected-out <<-EOF &&
	EOF

	chmod 0 dir13/a &&

	test-tool dir-iterator ./dir13 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir13/a
'
test_expect_success POSIXPERM,SANITY \
'pedantic dirs-ignore of dir w/ dir w/o perms w/ file' '

	cat >expected-out <<-EOF &&
	dir_iterator_advance failure: EACCES
	EOF

	chmod 0 dir13/a &&

	test_must_fail test-tool dir-iterator --pedantic ./dir13 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir13/a
'
test_expect_success POSIXPERM,SANITY \
'dirs-before of dir w/ dir w/o perms w/ file' '

	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir13/a
	EOF

	chmod 0 dir13/a &&

	test-tool dir-iterator --dirs-before ./dir13 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir13/a
'
test_expect_success POSIXPERM,SANITY \
'pedantic dirs-before of dir w/ dir w/o perms w/ file' '

	cat >expected-out <<-EOF &&
	[d] (a) [a] ./dir13/a
	dir_iterator_advance failure: EACCES
	EOF

	chmod 0 dir13/a &&

	test_must_fail test-tool dir-iterator --dirs-before \
		--pedantic ./dir13 >actual-out &&
	test_cmp expected-out actual-out &&

	chmod 755 dir13/a
'

test_expect_success SYMLINKS 'setup -- dir w/ symlinks w/o cycle' '
	mkdir -p dir14/a &&
	mkdir -p dir14/b/c &&
	>dir14/a/d &&
	ln -s d dir14/a/e &&
	ln -s ../b dir14/a/f
'
test_expect_success SYMLINKS 'dirs-ignore of dir w/ symlinks w/o cycle' '
	cat >expected-sorted-out <<-EOF &&
	[f] (a/d) [d] ./dir14/a/d
	[s] (a/e) [e] ./dir14/a/e
	[s] (a/f) [f] ./dir14/a/f
	EOF

	test-tool dir-iterator ./dir14 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success SYMLINKS \
'follow-symlinks dirs-ignore of dir w/ symlinks, w/o cycle' '

	cat >expected-sorted-out <<-EOF &&
	[f] (a/d) [d] ./dir14/a/d
	[f] (a/e) [e] ./dir14/a/e
	EOF

	test-tool dir-iterator --follow-symlinks ./dir14 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success SYMLINKS 'dirs-before of dir w/ symlinks w/o cycle' '
	cat >expected-sorted-out <<-EOF &&
	[d] (a) [a] ./dir14/a
	[d] (b) [b] ./dir14/b
	[d] (b/c) [c] ./dir14/b/c
	[f] (a/d) [d] ./dir14/a/d
	[s] (a/e) [e] ./dir14/a/e
	[s] (a/f) [f] ./dir14/a/f
	EOF

	test-tool dir-iterator --dirs-before ./dir14 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success SYMLINKS \
'follow-symlinks dirs-before of dir w/ symlinks w/o cycle' '

	cat >expected-sorted-out <<-EOF &&
	[d] (a) [a] ./dir14/a
	[d] (a/f) [f] ./dir14/a/f
	[d] (a/f/c) [c] ./dir14/a/f/c
	[d] (b) [b] ./dir14/b
	[d] (b/c) [c] ./dir14/b/c
	[f] (a/d) [d] ./dir14/a/d
	[f] (a/e) [e] ./dir14/a/e
	EOF

	test-tool dir-iterator --dirs-before --follow-symlinks ./dir14 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'

test_expect_success SYMLINKS 'setup -- dir w/ symlinks w/ cycle' '
	mkdir -p dir15/a/b &&
	mkdir -p dir15/a/c &&
	ln -s ../c dir15/a/b/d &&
	ln -s ../ dir15/a/b/e &&
	ln -s ../../ dir15/a/b/f
'
test_expect_success SYMLINKS 'dirs-ignore of dir w/ symlinks w/ cycle' '
	cat >expected-sorted-out <<-EOF &&
	[s] (a/b/d) [d] ./dir15/a/b/d
	[s] (a/b/e) [e] ./dir15/a/b/e
	[s] (a/b/f) [f] ./dir15/a/b/f
	EOF

	test-tool dir-iterator ./dir15 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success SYMLINKS \
'pedantic follow-symlinks dirs-ignore of dir w/ symlinks w/ cycle' '

	cat >expected-tailed-out <<-EOF &&
	dir_iterator_advance failure: ELOOP
	EOF

	test_must_fail test-tool dir-iterator \
		--pedantic --follow-symlinks ./dir15 >actual-out &&
	tail -n 1 actual-out >actual-tailed-out &&

	test_cmp expected-tailed-out actual-tailed-out
'
test_expect_success SYMLINKS 'dirs-before of dir w/ symlinks w/ cycle' '

	cat >expected-sorted-out <<-EOF &&
	[d] (a) [a] ./dir15/a
	[d] (a/b) [b] ./dir15/a/b
	[d] (a/c) [c] ./dir15/a/c
	[s] (a/b/d) [d] ./dir15/a/b/d
	[s] (a/b/e) [e] ./dir15/a/b/e
	[s] (a/b/f) [f] ./dir15/a/b/f
	EOF

	test-tool dir-iterator --dirs-before ./dir15 >actual-out &&
	sort actual-out >actual-sorted-out &&

	test_cmp expected-sorted-out actual-sorted-out
'
test_expect_success SYMLINKS \
'pedantic follow-symlinks dirs-before of dir w/ symlinks w/ cycle' '

	cat >expected-tailed-out <<-EOF &&
	dir_iterator_advance failure: ELOOP
	EOF

	test_must_fail test-tool dir-iterator --dirs-before \
		--pedantic --follow-symlinks ./dir15 >actual-out &&
	tail -n 1 actual-out >actual-tailed-out &&

	test_cmp expected-tailed-out actual-tailed-out
'

test_done

debug log:

solving badd82d8a4 ...
found badd82d8a4 in https://public-inbox.org/git/20220509175159.2948802-14-kioplato@gmail.com/
found 8ab8811fb5 in https://public-inbox.org/git/20220509175159.2948802-13-kioplato@gmail.com/
found 52b0217bde in https://public-inbox.org/git/20220509175159.2948802-12-kioplato@gmail.com/
found 04e51928bc in https://public-inbox.org/git/20220509175159.2948802-10-kioplato@gmail.com/
found 9b3ce99382 in https://public-inbox.org/git/20220509175159.2948802-9-kioplato@gmail.com/
found 932b1f291c in https://public-inbox.org/git/20220509175159.2948802-8-kioplato@gmail.com/
found 61b02423d5 in https://public-inbox.org/git/20220509175159.2948802-7-kioplato@gmail.com/
found b21c58ade3 in https://public-inbox.org/git/20220509175159.2948802-4-kioplato@gmail.com/
found 801749eb7e in https://public-inbox.org/git/20220509175159.2948802-3-kioplato@gmail.com/
found 807c43d447 in https://public-inbox.org/git/20220509175159.2948802-2-kioplato@gmail.com/
found 63a1a45cd3 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 63a1a45cd30921a5b0d28b8d5db63046aeb2a3ea	t/t0066-dir-iterator.sh

applying [1/10] https://public-inbox.org/git/20220509175159.2948802-2-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 63a1a45cd3..807c43d447 100755


applying [2/10] https://public-inbox.org/git/20220509175159.2948802-3-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 807c43d447..801749eb7e 100755


applying [3/10] https://public-inbox.org/git/20220509175159.2948802-4-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 801749eb7e..b21c58ade3 100755


applying [4/10] https://public-inbox.org/git/20220509175159.2948802-7-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index b21c58ade3..61b02423d5 100755


applying [5/10] https://public-inbox.org/git/20220509175159.2948802-8-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 61b02423d5..932b1f291c 100755


applying [6/10] https://public-inbox.org/git/20220509175159.2948802-9-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 932b1f291c..9b3ce99382 100755


applying [7/10] https://public-inbox.org/git/20220509175159.2948802-10-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 9b3ce99382..04e51928bc 100755


applying [8/10] https://public-inbox.org/git/20220509175159.2948802-12-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 04e51928bc..52b0217bde 100755


applying [9/10] https://public-inbox.org/git/20220509175159.2948802-13-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 52b0217bde..8ab8811fb5 100755


applying [10/10] https://public-inbox.org/git/20220509175159.2948802-14-kioplato@gmail.com/
diff --git a/t/t0066-dir-iterator.sh b/t/t0066-dir-iterator.sh
index 8ab8811fb5..badd82d8a4 100755

Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.
Checking patch t/t0066-dir-iterator.sh...
Applied patch t/t0066-dir-iterator.sh cleanly.

index at:
100755 badd82d8a485a9c28b5be1513674473d7d806045	t/t0066-dir-iterator.sh

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).