|
1
|
# |
|
2
|
# Copyright (c) 2015 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 of the "clean" command, including the ability to undo it. |
|
19
|
# |
|
20
|
|
|
21
|
test_setup |
|
22
|
|
|
23
|
############################################################################### |
|
24
|
|
|
25
|
fossil extra |
|
26
|
test clean-0 {[normalize_result] eq {}} |
|
27
|
|
|
28
|
############################################################################### |
|
29
|
|
|
30
|
write_file f1 "f1 line" |
|
31
|
fossil add f1 |
|
32
|
fossil commit -m "base file" |
|
33
|
fossil ls |
|
34
|
test clean-1 {[normalize_result] eq {f1}} |
|
35
|
|
|
36
|
############################################################################### |
|
37
|
|
|
38
|
fossil extra |
|
39
|
test clean-2 {[normalize_result] eq {}} |
|
40
|
|
|
41
|
############################################################################### |
|
42
|
|
|
43
|
write_file f2 "f2 line" |
|
44
|
fossil extra |
|
45
|
test clean-3 {[normalize_result] eq {f2}} |
|
46
|
|
|
47
|
############################################################################### |
|
48
|
|
|
49
|
# clean w/undo enabled, should not prompt, 1 file < 10MiB |
|
50
|
fossil clean |
|
51
|
test clean-4 {[normalize_result] eq \ |
|
52
|
{"fossil undo" is available to undo changes to the working checkout.}} |
|
53
|
|
|
54
|
############################################################################### |
|
55
|
|
|
56
|
fossil extra |
|
57
|
test clean-5 {[normalize_result] eq {}} |
|
58
|
|
|
59
|
############################################################################### |
|
60
|
|
|
61
|
fossil undo |
|
62
|
test clean-6 {[normalize_result] eq {NEW f2}} |
|
63
|
test clean-7 {[read_file f2] eq "f2 line"} |
|
64
|
|
|
65
|
############################################################################### |
|
66
|
|
|
67
|
fossil extra |
|
68
|
test clean-8 {[normalize_result] eq {f2}} |
|
69
|
|
|
70
|
############################################################################### |
|
71
|
|
|
72
|
write_file f3 [string repeat ABCDEFGHIJK 1048576] |
|
73
|
fossil extra |
|
74
|
test clean-9 {[normalize_result] eq {f2 |
|
75
|
f3}} |
|
76
|
|
|
77
|
############################################################################### |
|
78
|
|
|
79
|
# clean w/undo enabled, no prompt, 1 file < 10MiB, 1 file > 10MiB |
|
80
|
fossil clean --no-prompt |
|
81
|
test clean-10 {[normalize_result] eq \ |
|
82
|
{"fossil undo" is available to undo changes to the working checkout.}} |
|
83
|
|
|
84
|
############################################################################### |
|
85
|
|
|
86
|
fossil extra |
|
87
|
test clean-11 {[normalize_result] eq {f3}} |
|
88
|
|
|
89
|
############################################################################### |
|
90
|
|
|
91
|
fossil undo |
|
92
|
test clean-12 {[normalize_result] eq {NEW f2}} |
|
93
|
test clean-13 {[read_file f2] eq "f2 line"} |
|
94
|
test clean-14 {[read_file f3] eq [string repeat ABCDEFGHIJK 1048576]} |
|
95
|
|
|
96
|
############################################################################### |
|
97
|
|
|
98
|
fossil extra |
|
99
|
test clean-15 {[normalize_result] eq {f2 |
|
100
|
f3}} |
|
101
|
|
|
102
|
############################################################################### |
|
103
|
|
|
104
|
# clean w/undo enabled, force, 1 file < 10MiB, 1 file > 10MiB |
|
105
|
fossil clean --force |
|
106
|
test clean-16 {[normalize_result] eq \ |
|
107
|
{"fossil undo" is available to undo changes to the working checkout.}} |
|
108
|
|
|
109
|
############################################################################### |
|
110
|
|
|
111
|
fossil extra |
|
112
|
test clean-17 {[normalize_result] eq {}} |
|
113
|
|
|
114
|
############################################################################### |
|
115
|
|
|
116
|
fossil undo |
|
117
|
test clean-18 {[normalize_result] eq {NEW f2}} |
|
118
|
test clean-19 {[read_file f2] eq "f2 line"} |
|
119
|
|
|
120
|
############################################################################### |
|
121
|
|
|
122
|
write_file f4 [string repeat KJIHGFEDCBA 1048576] |
|
123
|
fossil extra |
|
124
|
test clean-20 {[normalize_result] eq {f2 |
|
125
|
f4}} |
|
126
|
|
|
127
|
############################################################################### |
|
128
|
|
|
129
|
# clean w/undo disabled, no prompt, 1 file < 10MiB, 1 file > 10MiB |
|
130
|
fossil clean --disable-undo --no-prompt |
|
131
|
test clean-21 {[normalize_result] eq {}} |
|
132
|
|
|
133
|
############################################################################### |
|
134
|
|
|
135
|
fossil extra |
|
136
|
test clean-22 {[normalize_result] eq {f2 |
|
137
|
f4}} |
|
138
|
|
|
139
|
############################################################################### |
|
140
|
|
|
141
|
fossil undo -expectError |
|
142
|
test clean-23 {[normalize_result] eq {nothing to undo}} |
|
143
|
|
|
144
|
############################################################################### |
|
145
|
|
|
146
|
# clean w/undo disabled, force, 1 file < 10MiB, 1 file > 10MiB |
|
147
|
fossil clean --disable-undo --force |
|
148
|
test clean-24 {[normalize_result] eq {}} |
|
149
|
|
|
150
|
############################################################################### |
|
151
|
|
|
152
|
fossil extra |
|
153
|
test clean-25 {[normalize_result] eq {}} |
|
154
|
|
|
155
|
############################################################################### |
|
156
|
|
|
157
|
fossil undo -expectError |
|
158
|
test clean-26 {[normalize_result] eq {nothing to undo}} |
|
159
|
|
|
160
|
############################################################################### |
|
161
|
|
|
162
|
write_file f5 "f5 line" |
|
163
|
fossil extra |
|
164
|
test clean-27 {[normalize_result] eq {f5}} |
|
165
|
|
|
166
|
############################################################################### |
|
167
|
|
|
168
|
# clean w/undo disabled, should prompt, 1 file < 10MiB |
|
169
|
fossil_maybe_answer Y clean --disable-undo |
|
170
|
test clean-28 {[normalize_result] eq \ |
|
171
|
{WARNING: Deletion of this file will not be undoable via the 'undo' |
|
172
|
command because undo is disabled for this operation. |
|
173
|
|
|
174
|
Remove unmanaged file "f5" (a=all/y/N)?}} |
|
175
|
|
|
176
|
############################################################################### |
|
177
|
|
|
178
|
fossil extra |
|
179
|
test clean-29 {[normalize_result] eq {}} |
|
180
|
|
|
181
|
############################################################################### |
|
182
|
|
|
183
|
fossil undo -expectError |
|
184
|
test clean-30 {[normalize_result] eq {nothing to undo}} |
|
185
|
|
|
186
|
############################################################################### |
|
187
|
|
|
188
|
fossil extra |
|
189
|
test clean-31 {[normalize_result] eq {}} |
|
190
|
|
|
191
|
############################################################################### |
|
192
|
|
|
193
|
test_cleanup |
|
194
|
|