5
. ./test-lib.sh
6
7
reinit_git () {
8
+ if ! test_declared_prereq PIPE
9
+ then
10
+ echo >&4 "reinit_git: need to declare PIPE prerequisite"
11
+ return 127
12
+ fi
13
rm -fr .git &&
9
- git init
14
+ rm -f stream backflow &&
15
+ git init &&
16
+ mkfifo stream backflow
17
+}
18
+
19
+try_dump () {
20
+ input=$1 &&
21
+ maybe_fail=${2:+test_$2} &&
22
+
23
+ {
24
+ $maybe_fail test-svn-fe "$input" >stream 3<backflow &
25
+ } &&
26
+ git fast-import --cat-blob-fd=3 <stream 3>backflow &&
27
+ wait $!
28
}
29
30
properties () {
53
54
>empty
55
38
-test_expect_success 'empty dump' '
56
+test_expect_success 'setup: have pipes?' '
57
+ rm -f frob &&
58
+ if mkfifo frob
59
+ then
60
+ test_set_prereq PIPE
61
+ fi
62
+'
63
+
64
+test_expect_success PIPE 'empty dump' '
65
reinit_git &&
66
echo "SVN-fs-dump-format-version: 2" >input &&
41
- test-svn-fe input >stream &&
42
- git fast-import <stream
67
+ try_dump input
68
'
69
45
-test_expect_success 'v4 dumps not supported' '
70
+test_expect_success PIPE 'v4 dumps not supported' '
71
reinit_git &&
72
echo "SVN-fs-dump-format-version: 4" >v4.dump &&
48
- test_must_fail test-svn-fe v4.dump >stream &&
49
- test_cmp empty stream
73
+ try_dump v4.dump must_fail
74
'
75
52
-test_expect_failure 'empty revision' '
76
+test_expect_failure PIPE 'empty revision' '
77
reinit_git &&
78
printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
79
cat >emptyrev.dump <<-\EOF &&
88
Content-length: 0
89
90
EOF
67
- test-svn-fe emptyrev.dump >stream &&
68
- git fast-import <stream &&
91
+ try_dump emptyrev.dump &&
92
git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
93
test_cmp expect actual
94
'
95
73
-test_expect_success 'empty properties' '
96
+test_expect_success PIPE 'empty properties' '
97
reinit_git &&
98
printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
99
cat >emptyprop.dump <<-\EOF &&
111
112
PROPS-END
113
EOF
91
- test-svn-fe emptyprop.dump >stream &&
92
- git fast-import <stream &&
114
+ try_dump emptyprop.dump &&
115
git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
116
test_cmp expect actual
117
'
118
97
-test_expect_success 'author name and commit message' '
119
+test_expect_success PIPE 'author name and commit message' '
120
reinit_git &&
121
echo "<author@example.com, author@example.com@local>" >expect.author &&
122
cat >message <<-\EOF &&
143
echo &&
144
cat props
145
} >log.dump &&
124
- test-svn-fe log.dump >stream &&
125
- git fast-import <stream &&
146
+ try_dump log.dump &&
147
git log -p --format="%B" HEAD >actual.log &&
148
git log --format="<%an, %ae>" >actual.author &&
149
test_cmp message actual.log &&
150
test_cmp expect.author actual.author
151
'
152
132
-test_expect_success 'unsupported properties are ignored' '
153
+test_expect_success PIPE 'unsupported properties are ignored' '
154
reinit_git &&
155
echo author >expect &&
156
cat >extraprop.dump <<-\EOF &&
170
author
171
PROPS-END
172
EOF
152
- test-svn-fe extraprop.dump >stream &&
153
- git fast-import <stream &&
173
+ try_dump extraprop.dump &&
174
git log -p --format=%an HEAD >actual &&
175
test_cmp expect actual
176
'
177
158
-test_expect_failure 'timestamp and empty file' '
178
+test_expect_failure PIPE 'timestamp and empty file' '
179
echo author@example.com >expect.author &&
180
echo 1999-01-01 >expect.date &&
181
echo file >expect.files &&
206
207
EOF
208
} >emptyfile.dump &&
189
- test-svn-fe emptyfile.dump >stream &&
190
- git fast-import <stream &&
209
+ try_dump emptyfile.dump &&
210
git log --format=%an HEAD >actual.author &&
211
git log --date=short --format=%ad HEAD >actual.date &&
212
git ls-tree -r --name-only HEAD >actual.files &&
217
test_cmp empty file
218
'
219
201
-test_expect_success 'directory with files' '
220
+test_expect_success PIPE 'directory with files' '
221
reinit_git &&
222
printf "%s\n" directory/file1 directory/file2 >expect.files &&
223
echo hi >hi &&
261
EOF
262
text_no_props hi
263
} >directory.dump &&
245
- test-svn-fe directory.dump >stream &&
246
- git fast-import <stream &&
264
+ try_dump directory.dump &&
265
266
git ls-tree -r --name-only HEAD >actual.files &&
267
git checkout HEAD directory &&
270
test_cmp hi directory/file2
271
'
272
255
-test_expect_success 'node without action' '
273
+test_expect_success PIPE 'node without action' '
274
+ reinit_git &&
275
cat >inaction.dump <<-\EOF &&
276
SVN-fs-dump-format-version: 3
277
288
289
PROPS-END
290
EOF
272
- test_must_fail test-svn-fe inaction.dump
291
+ try_dump inaction.dump must_fail
292
'
293
275
-test_expect_success 'action: add node without text' '
294
+test_expect_success PIPE 'action: add node without text' '
295
+ reinit_git &&
296
cat >textless.dump <<-\EOF &&
297
SVN-fs-dump-format-version: 3
298
310
311
PROPS-END
312
EOF
293
- test_must_fail test-svn-fe textless.dump
313
+ try_dump textless.dump must_fail
314
'
315
296
-test_expect_failure 'change file mode but keep old content' '
316
+test_expect_failure PIPE 'change file mode but keep old content' '
317
reinit_git &&
318
cat >expect <<-\EOF &&
319
OBJID
376
377
PROPS-END
378
EOF
359
- test-svn-fe filemode.dump >stream &&
360
- git fast-import <stream &&
379
+ try_dump filemode.dump &&
380
{
381
git rev-list HEAD |
382
git diff-tree --root --stdin |
389
test_cmp hello actual.target
390
'
391
373
-test_expect_success 'change file mode and reiterate content' '
392
+test_expect_success PIPE 'change file mode and reiterate content' '
393
reinit_git &&
394
cat >expect <<-\EOF &&
395
OBJID
401
EOF
402
echo "link hello" >expect.blob &&
403
echo hello >hello &&
385
- cat >filemode.dump <<-\EOF &&
404
+ cat >filemode2.dump <<-\EOF &&
405
SVN-fs-dump-format-version: 3
406
407
Revision-number: 1
456
PROPS-END
457
link hello
458
EOF
440
- test-svn-fe filemode.dump >stream &&
441
- git fast-import <stream &&
459
+ try_dump filemode2.dump &&
460
{
461
git rev-list HEAD |
462
git diff-tree --root --stdin |
469
test_cmp hello actual.target
470
'
471
454
-test_expect_success 'deltas not supported' '
472
+test_expect_success PIPE 'deltas not supported' '
473
+ reinit_git &&
474
{
475
# (old) h + (inline) ello + (old) \n
476
printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
530
echo PROPS-END &&
531
cat delta
532
} >delta.dump &&
514
- test_must_fail test-svn-fe delta.dump
533
+ test_must_fail try_dump delta.dump
534
'
535
517
-test_expect_success 'property deltas supported' '
536
+test_expect_success PIPE 'property deltas supported' '
537
reinit_git &&
538
cat >expect <<-\EOF &&
539
OBJID
589
PROPS-END
590
EOF
591
} >propdelta.dump &&
573
- test-svn-fe propdelta.dump >stream &&
574
- git fast-import <stream &&
592
+ try_dump propdelta.dump &&
593
{
594
git rev-list HEAD |
595
git diff-tree --stdin |
598
test_cmp expect actual
599
'
600
583
-test_expect_success 'properties on /' '
601
+test_expect_success PIPE 'properties on /' '
602
reinit_git &&
603
cat <<-\EOF >expect &&
604
OBJID
643
644
PROPS-END
645
EOF
628
- test-svn-fe changeroot.dump >stream &&
629
- git fast-import <stream &&
646
+ try_dump changeroot.dump &&
647
{
648
git rev-list HEAD |
649
git diff-tree --root --always --stdin |
652
test_cmp expect actual
653
'
654
638
-test_expect_success 'deltas for typechange' '
655
+test_expect_success PIPE 'deltas for typechange' '
656
reinit_git &&
657
cat >expect <<-\EOF &&
658
OBJID
728
PROPS-END
729
link testing 321
730
EOF
714
- test-svn-fe deleteprop.dump >stream &&
715
- git fast-import <stream &&
731
+ try_dump deleteprop.dump &&
732
{
733
git rev-list HEAD |
734
git diff-tree --root --stdin |
752
fi
753
'
754
739
-test_expect_success SVNREPO 't9135/svn.dump' '
740
- git init simple-git &&
741
- test-svn-fe "$TEST_DIRECTORY/t9135/svn.dump" >simple.fe &&
755
+test_expect_success SVNREPO,PIPE 't9135/svn.dump' '
756
+ mkdir -p simple-git &&
757
(
758
cd simple-git &&
744
- git fast-import <../simple.fe
759
+ reinit_git &&
760
+ try_dump "$TEST_DIRECTORY/t9135/svn.dump"
761
) &&
762
(
763
cd simple-svnco &&