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