# # 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