Skip to content

Commit 920f7c5

Browse files
rjboukit-ty-kate
authored andcommitted
Add a library test for the new OCaml implementation of patch and diff
1 parent 4efcfb5 commit 920f7c5

File tree

4 files changed

+659
-0
lines changed

4 files changed

+659
-0
lines changed

master_changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ users)
174174
## Internal: Windows
175175

176176
## Test
177+
* Add a library test for the new OCaml implementation of patch and diff [#5892 @rjbou]
177178

178179
## Benchmarks
179180
* Add benchmarks for `opam show` [#6212 @kit-ty-kate]

tests/lib/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
(libraries opam-format)
99
(modules TypeGymnastics)
1010
(action (run %{test})))
11+
12+
(test
13+
(name patchDiff)
14+
(modules patchDiff)
15+
(libraries opam-repository))

tests/lib/patchDiff.expected

Lines changed: 339 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,339 @@
1+
2+
----------------------
3+
Test 1: normal
4+
----------------------
5+
6+
*** SETUP ***
7+
+ first/
8+
+ first/diff-dir-plus-fst
9+
+ first/diff-dir-plus-fst/fst
10+
> foo
11+
+ first/diff-dir-plus-snd
12+
+ first/diff-dir-plus-snd/fst
13+
> foo
14+
> bar
15+
+ first/diff-file
16+
> foo
17+
+ first/diff-file-plus-fst
18+
> foo
19+
> bar
20+
+ first/diff-file-plus-snd
21+
> foo
22+
+ first/dir-only-fst
23+
+ first/dir-only-fst/fst
24+
> foo
25+
+ first/file-only-fst
26+
> foo
27+
+ first/same-file
28+
> foo
29+
+ second/
30+
+ second/diff-dir-plus-fst
31+
+ second/diff-dir-plus-fst/fst
32+
> foo
33+
> bar
34+
+ second/diff-dir-plus-snd
35+
+ second/diff-dir-plus-snd/fst
36+
> foo
37+
+ second/diff-file
38+
> bar
39+
+ second/diff-file-plus-fst
40+
> foo
41+
+ second/diff-file-plus-snd
42+
> foo
43+
> bar
44+
+ second/file-only-snd
45+
> foo
46+
+ second/same-file
47+
> foo
48+
49+
*** DIFF ***
50+
--- first/diff-dir-plus-fst/fst
51+
+++ second/diff-dir-plus-fst/fst
52+
@@ -2,0 +2,1 @@
53+
+bar
54+
--- first/diff-dir-plus-snd/fst
55+
+++ second/diff-dir-plus-snd/fst
56+
@@ -2,1 +2,0 @@
57+
-bar
58+
--- first/diff-file
59+
+++ second/diff-file
60+
@@ -1,1 +1,1 @@
61+
-foo
62+
+bar
63+
--- first/diff-file-plus-fst
64+
+++ second/diff-file-plus-fst
65+
@@ -2,1 +2,0 @@
66+
-bar
67+
--- first/diff-file-plus-snd
68+
+++ second/diff-file-plus-snd
69+
@@ -2,0 +2,1 @@
70+
+bar
71+
--- first/dir-only-fst/fst
72+
+++ /dev/null
73+
@@ -1,1 +0,0 @@
74+
-foo
75+
--- first/file-only-fst
76+
+++ /dev/null
77+
@@ -1,1 +0,0 @@
78+
-foo
79+
--- /dev/null
80+
+++ second/file-only-snd
81+
@@ -0,0 +1,1 @@
82+
+foo
83+
84+
*** PATCHED ***
85+
+ first/
86+
+ first/diff-dir-plus-fst
87+
+ first/diff-dir-plus-fst/fst
88+
> foo
89+
> bar
90+
+ first/diff-dir-plus-snd
91+
+ first/diff-dir-plus-snd/fst
92+
> foo
93+
+ first/diff-file
94+
> bar
95+
+ first/diff-file-plus-fst
96+
> foo
97+
+ first/diff-file-plus-snd
98+
> foo
99+
> bar
100+
+ first/dir-only-fst
101+
+ first/file-only-snd
102+
> foo
103+
+ first/same-file
104+
> foo
105+
+ second/
106+
+ second/diff-dir-plus-fst
107+
+ second/diff-dir-plus-fst/fst
108+
> foo
109+
> bar
110+
+ second/diff-dir-plus-snd
111+
+ second/diff-dir-plus-snd/fst
112+
> foo
113+
+ second/diff-file
114+
> bar
115+
+ second/diff-file-plus-fst
116+
> foo
117+
+ second/diff-file-plus-snd
118+
> foo
119+
> bar
120+
+ second/file-only-snd
121+
> foo
122+
+ second/same-file
123+
> foo
124+
125+
126+
----------------------
127+
Test 2: diff file/dir error
128+
----------------------
129+
130+
*** SETUP ***
131+
+ first/
132+
+ first/file-fst-dir-snd
133+
> foo
134+
+ first/same-file
135+
> foo
136+
+ second/
137+
+ second/file-fst-dir-snd
138+
+ second/file-fst-dir-snd/fst
139+
> foo
140+
+ second/same-file
141+
> foo
142+
143+
*** DIFF ***
144+
ERROR: Change from a regular file to a directory is unsupported
145+
146+
----------------------
147+
Test 3: diff dir/file error
148+
----------------------
149+
150+
*** SETUP ***
151+
+ first/
152+
+ first/dir-fst-file-snd
153+
+ first/dir-fst-file-snd/fst
154+
> foo
155+
+ first/same-file
156+
> foo
157+
+ second/
158+
+ second/dir-fst-file-snd
159+
> foo
160+
+ second/same-file
161+
> foo
162+
163+
*** DIFF ***
164+
ERROR: Change from a directory to a regular file is unsupported
165+
166+
----------------------
167+
Test 4: symlink fst
168+
----------------------
169+
170+
*** SETUP ***
171+
+ first/
172+
+ first/linked-file-fst
173+
> bar
174+
+ first/same-file
175+
> foo
176+
+ second/
177+
+ second/linked-file-fst
178+
> foo
179+
+ second/same-file
180+
> foo
181+
182+
*** DIFF ***
183+
ERROR: Symlinks are unsupported
184+
185+
----------------------
186+
Test 5: symlink snd
187+
----------------------
188+
189+
*** SETUP ***
190+
+ first/
191+
+ first/linked-file-snd
192+
> foo
193+
+ first/same-file
194+
> foo
195+
+ second/
196+
+ second/linked-file-snd
197+
> bar
198+
+ second/same-file
199+
> foo
200+
201+
*** DIFF ***
202+
ERROR: Symlinks are unsupported
203+
204+
----------------------
205+
Test 6: hardlink fst
206+
----------------------
207+
208+
*** SETUP ***
209+
+ first/
210+
+ first/hardlinked-file-fst
211+
> bar
212+
+ first/same-file
213+
> foo
214+
+ second/
215+
+ second/hardlinked-file-fst
216+
> foo
217+
+ second/same-file
218+
> foo
219+
220+
*** DIFF ***
221+
--- first/hardlinked-file-fst
222+
+++ second/hardlinked-file-fst
223+
@@ -1,1 +1,1 @@
224+
-bar
225+
+foo
226+
227+
*** PATCHED ***
228+
+ first/
229+
+ first/hardlinked-file-fst
230+
> foo
231+
+ first/same-file
232+
> foo
233+
+ second/
234+
+ second/hardlinked-file-fst
235+
> foo
236+
+ second/same-file
237+
> foo
238+
239+
240+
----------------------
241+
Test 7: hardlink snd
242+
----------------------
243+
244+
*** SETUP ***
245+
+ first/
246+
+ first/hardlinked-file-snd
247+
> foo
248+
+ first/same-file
249+
> foo
250+
+ second/
251+
+ second/hardlinked-file-snd
252+
> foo
253+
+ second/same-file
254+
> foo
255+
256+
*** DIFF ***
257+
No diff
258+
259+
----------------------
260+
Test 8: patch error garbage
261+
----------------------
262+
263+
*** SETUP ***
264+
+ first/
265+
+ first/diff-file
266+
> foo
267+
+ first/same-file
268+
> foo
269+
+ second/
270+
+ second/diff-file
271+
> bar
272+
+ second/same-file
273+
> foo
274+
275+
*** GIVEN DIFF ***
276+
something in
277+
the file
278+
that is not
279+
patch format
280+
281+
*** PATCHED ***
282+
+ first/
283+
+ first/diff-file
284+
> foo
285+
+ first/same-file
286+
> foo
287+
+ second/
288+
+ second/diff-file
289+
> bar
290+
+ second/same-file
291+
> foo
292+
293+
294+
----------------------
295+
Test 9: patch truncated
296+
----------------------
297+
298+
*** SETUP ***
299+
+ first/
300+
+ first/diff-file
301+
> foo
302+
+ first/diff-file-plus-fst
303+
> foo
304+
> bar
305+
+ first/same-file
306+
> foo
307+
+ second/
308+
+ second/diff-file
309+
> bar
310+
+ second/diff-file-plus-fst
311+
> foo
312+
+ second/same-file
313+
> foo
314+
315+
*** GIVEN DIFF ***
316+
--- first/diff-file
317+
+++ second/diff-file
318+
@@ -1,1 +1,1 @@
319+
-foo
320+
+bar
321+
--- first/diff-fi
322+
323+
*** PATCHED ***
324+
+ first/
325+
+ first/diff-file
326+
> bar
327+
+ first/diff-file-plus-fst
328+
> foo
329+
> bar
330+
+ first/same-file
331+
> foo
332+
+ second/
333+
+ second/diff-file
334+
> bar
335+
+ second/diff-file-plus-fst
336+
> foo
337+
+ second/same-file
338+
> foo
339+

0 commit comments

Comments
 (0)