|
057e4b0…
|
mistachkin
|
1 |
# |
|
057e4b0…
|
mistachkin
|
2 |
# Copyright (c) 2016 D. Richard Hipp |
|
057e4b0…
|
mistachkin
|
3 |
# |
|
057e4b0…
|
mistachkin
|
4 |
# This program is free software; you can redistribute it and/or |
|
057e4b0…
|
mistachkin
|
5 |
# modify it under the terms of the Simplified BSD License (also |
|
057e4b0…
|
mistachkin
|
6 |
# known as the "2-Clause License" or "FreeBSD License".) |
|
057e4b0…
|
mistachkin
|
7 |
# |
|
057e4b0…
|
mistachkin
|
8 |
# This program is distributed in the hope that it will be useful, |
|
057e4b0…
|
mistachkin
|
9 |
# but without any warranty; without even the implied warranty of |
|
057e4b0…
|
mistachkin
|
10 |
# merchantability or fitness for a particular purpose. |
|
057e4b0…
|
mistachkin
|
11 |
# |
|
057e4b0…
|
mistachkin
|
12 |
# Author contact information: |
|
057e4b0…
|
mistachkin
|
13 |
# [email protected] |
|
057e4b0…
|
mistachkin
|
14 |
# http://www.hwaci.com/drh/ |
|
057e4b0…
|
mistachkin
|
15 |
# |
|
057e4b0…
|
mistachkin
|
16 |
############################################################################ |
|
057e4b0…
|
mistachkin
|
17 |
# |
|
057e4b0…
|
mistachkin
|
18 |
# Tests for the diff command. |
|
057e4b0…
|
mistachkin
|
19 |
# |
|
057e4b0…
|
mistachkin
|
20 |
|
|
057e4b0…
|
mistachkin
|
21 |
require_no_open_checkout |
|
057e4b0…
|
mistachkin
|
22 |
|
|
057e4b0…
|
mistachkin
|
23 |
test_setup; set rootDir [file normalize [pwd]] |
|
057e4b0…
|
mistachkin
|
24 |
|
|
057e4b0…
|
mistachkin
|
25 |
################################### |
|
057e4b0…
|
mistachkin
|
26 |
# Tests of binary file detection. # |
|
057e4b0…
|
mistachkin
|
27 |
################################### |
|
057e4b0…
|
mistachkin
|
28 |
|
|
057e4b0…
|
mistachkin
|
29 |
file mkdir .fossil-settings |
|
057e4b0…
|
mistachkin
|
30 |
write_file [file join .fossil-settings binary-glob] "*" |
|
057e4b0…
|
mistachkin
|
31 |
|
|
057e4b0…
|
mistachkin
|
32 |
write_file file0.dat ""; # no content. |
|
057e4b0…
|
mistachkin
|
33 |
write_file file1.dat "test file 1 (one line no term)." |
|
057e4b0…
|
mistachkin
|
34 |
write_file file2.dat "test file 2 (NUL character).\0" |
|
547585b…
|
mistachkin
|
35 |
write_file file3.dat "test file 3 (long line).[string repeat x 32768]" |
|
547585b…
|
mistachkin
|
36 |
write_file file4.dat "test file 4 (long line).[string repeat y 32768]\ntwo" |
|
547585b…
|
mistachkin
|
37 |
write_file file5.dat "[string repeat z 32768]\ntest file 5 (long line)." |
|
057e4b0…
|
mistachkin
|
38 |
|
|
057e4b0…
|
mistachkin
|
39 |
fossil add $rootDir |
|
057e4b0…
|
mistachkin
|
40 |
fossil commit -m "c1" |
|
057e4b0…
|
mistachkin
|
41 |
|
|
057e4b0…
|
mistachkin
|
42 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
43 |
|
|
057e4b0…
|
mistachkin
|
44 |
fossil ls |
|
057e4b0…
|
mistachkin
|
45 |
test diff-ls-1 {[normalize_result] eq \ |
|
057e4b0…
|
mistachkin
|
46 |
"file0.dat\nfile1.dat\nfile2.dat\nfile3.dat\nfile4.dat\nfile5.dat"} |
|
057e4b0…
|
mistachkin
|
47 |
|
|
057e4b0…
|
mistachkin
|
48 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
49 |
|
|
057e4b0…
|
mistachkin
|
50 |
write_file file0.dat "\0" |
|
057e4b0…
|
mistachkin
|
51 |
fossil diff file0.dat |
|
057e4b0…
|
mistachkin
|
52 |
|
|
057e4b0…
|
mistachkin
|
53 |
test diff-file0-1 {[normalize_result] eq {Index: file0.dat |
|
057e4b0…
|
mistachkin
|
54 |
================================================================== |
|
057e4b0…
|
mistachkin
|
55 |
--- file0.dat |
|
057e4b0…
|
mistachkin
|
56 |
+++ file0.dat |
|
057e4b0…
|
mistachkin
|
57 |
cannot compute difference between binary files}} |
|
057e4b0…
|
mistachkin
|
58 |
|
|
057e4b0…
|
mistachkin
|
59 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
60 |
|
|
547585b…
|
mistachkin
|
61 |
write_file file1.dat [string repeat z 32768] |
|
057e4b0…
|
mistachkin
|
62 |
fossil diff file1.dat |
|
057e4b0…
|
mistachkin
|
63 |
|
|
057e4b0…
|
mistachkin
|
64 |
test diff-file1-1 {[normalize_result] eq {Index: file1.dat |
|
057e4b0…
|
mistachkin
|
65 |
================================================================== |
|
057e4b0…
|
mistachkin
|
66 |
--- file1.dat |
|
057e4b0…
|
mistachkin
|
67 |
+++ file1.dat |
|
057e4b0…
|
mistachkin
|
68 |
cannot compute difference between binary files}} |
|
057e4b0…
|
mistachkin
|
69 |
|
|
057e4b0…
|
mistachkin
|
70 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
71 |
|
|
057e4b0…
|
mistachkin
|
72 |
write_file file2.dat "test file 2 (no NUL character)." |
|
057e4b0…
|
mistachkin
|
73 |
fossil diff file2.dat |
|
057e4b0…
|
mistachkin
|
74 |
|
|
057e4b0…
|
mistachkin
|
75 |
test diff-file2-1 {[normalize_result] eq {Index: file2.dat |
|
057e4b0…
|
mistachkin
|
76 |
================================================================== |
|
057e4b0…
|
mistachkin
|
77 |
--- file2.dat |
|
057e4b0…
|
mistachkin
|
78 |
+++ file2.dat |
|
057e4b0…
|
mistachkin
|
79 |
cannot compute difference between binary files}} |
|
057e4b0…
|
mistachkin
|
80 |
|
|
057e4b0…
|
mistachkin
|
81 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
82 |
|
|
057e4b0…
|
mistachkin
|
83 |
write_file file3.dat "test file 3 (not a long line)." |
|
057e4b0…
|
mistachkin
|
84 |
fossil diff file3.dat |
|
057e4b0…
|
mistachkin
|
85 |
|
|
057e4b0…
|
mistachkin
|
86 |
test diff-file3-1 {[normalize_result] eq {Index: file3.dat |
|
057e4b0…
|
mistachkin
|
87 |
================================================================== |
|
057e4b0…
|
mistachkin
|
88 |
--- file3.dat |
|
057e4b0…
|
mistachkin
|
89 |
+++ file3.dat |
|
057e4b0…
|
mistachkin
|
90 |
cannot compute difference between binary files}} |
|
057e4b0…
|
mistachkin
|
91 |
|
|
057e4b0…
|
mistachkin
|
92 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
93 |
|
|
057e4b0…
|
mistachkin
|
94 |
write_file file4.dat "test file 4 (not a long line).\ntwo" |
|
057e4b0…
|
mistachkin
|
95 |
fossil diff file4.dat |
|
057e4b0…
|
mistachkin
|
96 |
|
|
057e4b0…
|
mistachkin
|
97 |
test diff-file4-1 {[normalize_result] eq {Index: file4.dat |
|
057e4b0…
|
mistachkin
|
98 |
================================================================== |
|
057e4b0…
|
mistachkin
|
99 |
--- file4.dat |
|
057e4b0…
|
mistachkin
|
100 |
+++ file4.dat |
|
057e4b0…
|
mistachkin
|
101 |
cannot compute difference between binary files}} |
|
057e4b0…
|
mistachkin
|
102 |
|
|
057e4b0…
|
mistachkin
|
103 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
104 |
|
|
057e4b0…
|
mistachkin
|
105 |
write_file file5.dat "[string repeat 0 16]\ntest file 5 (not a long line)." |
|
057e4b0…
|
mistachkin
|
106 |
fossil diff file5.dat |
|
057e4b0…
|
mistachkin
|
107 |
|
|
057e4b0…
|
mistachkin
|
108 |
test diff-file5-1 {[normalize_result] eq {Index: file5.dat |
|
057e4b0…
|
mistachkin
|
109 |
================================================================== |
|
057e4b0…
|
mistachkin
|
110 |
--- file5.dat |
|
057e4b0…
|
mistachkin
|
111 |
+++ file5.dat |
|
057e4b0…
|
mistachkin
|
112 |
cannot compute difference between binary files}} |
|
a45c7f0…
|
drh
|
113 |
|
|
a45c7f0…
|
drh
|
114 |
############################################################################### |
|
a45c7f0…
|
drh
|
115 |
|
|
a45c7f0…
|
drh
|
116 |
write_file file6a.dat "{\n \"abc\": {\n \"def\": false,\n \"ghi\": false\n }\n}\n" |
|
a45c7f0…
|
drh
|
117 |
write_file file6b.dat "{\n \"abc\": {\n \"def\": false,\n \"ghi\": false\n },\n \"jkl\": {\n \"mno\": {\n \"pqr\": false\n }\n }\n}\n" |
|
a45c7f0…
|
drh
|
118 |
fossil xdiff -y -W 16 file6a.dat file6b.dat |
|
a45c7f0…
|
drh
|
119 |
test diff-file-6-1 {[normalize_result] eq {========== file6a.dat ===== versus ===== file6b.dat ===== |
|
a45c7f0…
|
drh
|
120 |
1 { 1 { |
|
a45c7f0…
|
drh
|
121 |
2 "abc": { 2 "abc": { |
|
a45c7f0…
|
drh
|
122 |
3 "def": false, 3 "def": false, |
|
a45c7f0…
|
drh
|
123 |
4 "ghi": false 4 "ghi": false |
|
a45c7f0…
|
drh
|
124 |
> 5 }, |
|
a45c7f0…
|
drh
|
125 |
> 6 "jkl": { |
|
a45c7f0…
|
drh
|
126 |
> 7 "mno": { |
|
a45c7f0…
|
drh
|
127 |
> 8 "pqr": false |
|
a45c7f0…
|
drh
|
128 |
> 9 } |
|
a45c7f0…
|
drh
|
129 |
5 } 10 } |
|
a45c7f0…
|
drh
|
130 |
6 } 11 }}} |
|
caa6ad3…
|
drh
|
131 |
|
|
caa6ad3…
|
drh
|
132 |
############################################################################### |
|
caa6ad3…
|
drh
|
133 |
|
|
caa6ad3…
|
drh
|
134 |
fossil rm file1.dat |
|
caa6ad3…
|
drh
|
135 |
fossil diff -v file1.dat |
|
caa6ad3…
|
drh
|
136 |
|
|
caa6ad3…
|
drh
|
137 |
test diff-deleted-file-1 {[normalize_result] eq {DELETED file1.dat |
|
caa6ad3…
|
drh
|
138 |
Index: file1.dat |
|
caa6ad3…
|
drh
|
139 |
================================================================== |
|
caa6ad3…
|
drh
|
140 |
--- file1.dat |
|
caa6ad3…
|
drh
|
141 |
+++ /dev/null |
|
caa6ad3…
|
drh
|
142 |
@@ -1,1 +0,0 @@ |
|
caa6ad3…
|
drh
|
143 |
-test file 1 (one line no term).}} |
|
caa6ad3…
|
drh
|
144 |
|
|
caa6ad3…
|
drh
|
145 |
############################################################################### |
|
caa6ad3…
|
drh
|
146 |
|
|
caa6ad3…
|
drh
|
147 |
write_file file6.dat "test file 6 (one line no term)." |
|
caa6ad3…
|
drh
|
148 |
fossil add file6.dat |
|
caa6ad3…
|
drh
|
149 |
|
|
caa6ad3…
|
drh
|
150 |
fossil diff -v file6.dat |
|
caa6ad3…
|
drh
|
151 |
|
|
caa6ad3…
|
drh
|
152 |
test diff-added-file-1 {[normalize_result] eq {ADDED file6.dat |
|
caa6ad3…
|
drh
|
153 |
Index: file6.dat |
|
caa6ad3…
|
drh
|
154 |
================================================================== |
|
caa6ad3…
|
drh
|
155 |
--- /dev/null |
|
caa6ad3…
|
drh
|
156 |
+++ file6.dat |
|
caa6ad3…
|
drh
|
157 |
@@ -0,0 +1,1 @@ |
|
caa6ad3…
|
drh
|
158 |
+test file 6 (one line no term).}} |
|
057e4b0…
|
mistachkin
|
159 |
|
|
057e4b0…
|
mistachkin
|
160 |
############################################################################### |
|
057e4b0…
|
mistachkin
|
161 |
|
|
057e4b0…
|
mistachkin
|
162 |
test_cleanup |