Fossil SCM

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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button