30
test_cmp_config_output expect actual
31
'
32
33
+test_expect_success 'bundle_uri_parse_line(): relative URIs' '
34
+ cat >in <<-\EOF &&
35
+ bundle.one.uri=bundle.bdl
36
+ bundle.two.uri=../bundle.bdl
37
+ bundle.three.uri=sub/dir/bundle.bdl
38
+ EOF
39
+
40
+ cat >expect <<-\EOF &&
41
+ [bundle]
42
+ version = 1
43
+ mode = all
44
+ [bundle "one"]
45
+ uri = <uri>/bundle.bdl
46
+ [bundle "two"]
47
+ uri = bundle.bdl
48
+ [bundle "three"]
49
+ uri = <uri>/sub/dir/bundle.bdl
50
+ EOF
51
+
52
+ test-tool bundle-uri parse-key-values in >actual 2>err &&
53
+ test_must_be_empty err &&
54
+ test_cmp_config_output expect actual
55
+'
56
+
57
+test_expect_success 'bundle_uri_parse_line(): relative URIs and parent paths' '
58
+ cat >in <<-\EOF &&
59
+ bundle.one.uri=bundle.bdl
60
+ bundle.two.uri=../bundle.bdl
61
+ bundle.three.uri=../../bundle.bdl
62
+ EOF
63
+
64
+ cat >expect <<-\EOF &&
65
+ [bundle]
66
+ version = 1
67
+ mode = all
68
+ [bundle "one"]
69
+ uri = <uri>/bundle.bdl
70
+ [bundle "two"]
71
+ uri = bundle.bdl
72
+ [bundle "three"]
73
+ uri = <uri>/../bundle.bdl
74
+ EOF
75
+
76
+ # TODO: We would prefer if parsing a bundle list would not cause
77
+ # a die() and instead would give a warning and allow the rest of
78
+ # a Git command to continue. This test_must_fail is necessary for
79
+ # now until the interface for relative_url() allows for reporting
80
+ # an error instead of die()ing.
81
+ test_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&
82
+ grep "fatal: cannot strip one component off url" err
83
+'
84
+
85
test_expect_success 'bundle_uri_parse_line() parsing edge cases: empty key or value' '
86
cat >in <<-\EOF &&
87
=bogus-value
188
test_cmp_config_output expect actual
189
'
190
191
+test_expect_success 'parse config format: relative URIs' '
192
+ cat >in <<-\EOF &&
193
+ [bundle]
194
+ version = 1
195
+ mode = all
196
+ [bundle "one"]
197
+ uri = bundle.bdl
198
+ [bundle "two"]
199
+ uri = ../bundle.bdl
200
+ [bundle "three"]
201
+ uri = sub/dir/bundle.bdl
202
+ EOF
203
+
204
+ cat >expect <<-\EOF &&
205
+ [bundle]
206
+ version = 1
207
+ mode = all
208
+ [bundle "one"]
209
+ uri = <uri>/bundle.bdl
210
+ [bundle "two"]
211
+ uri = bundle.bdl
212
+ [bundle "three"]
213
+ uri = <uri>/sub/dir/bundle.bdl
214
+ EOF
215
+
216
+ test-tool bundle-uri parse-config in >actual 2>err &&
217
+ test_must_be_empty err &&
218
+ test_cmp_config_output expect actual
219
+'
220
+
221
test_expect_success 'parse config format edge cases: empty key or value' '
222
cat >in1 <<-\EOF &&
223
= bogus-value