diff --git a/functest/run.sh b/functest/run.sh index 756d9be39..3f9b1068a 100755 --- a/functest/run.sh +++ b/functest/run.sh @@ -10,6 +10,7 @@ TESTS+=" test-sync.sh" TESTS+=" test-repro-code.sh" TESTS+=" test-merge.sh" TESTS+=" test-checkout.sh" +TESTS+=" test-gc.sh" for t in $TESTS; do rm -rf $TEST_REPO diff --git a/functest/test-gc.sh b/functest/test-gc.sh new file mode 100755 index 000000000..6e52abaab --- /dev/null +++ b/functest/test-gc.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e + +source common.sh + +dvc_create_repo + +ORIG_CACHE=$(ls .dvc/cache) + +DUMMY_CACHE+=" .dvc/cache/1" +DUMMY_CACHE+=" .dvc/cache/2" +DUMMY_CACHE+=" .dvc/cache/3" + +dvc_info "Create dummy cache files" +touch $DUMMY_CACHE +if [ $? -ne 0 ]; then + dvc_error "Failed to create cache files" + dvc_fail +fi + +dvc_info "Run 'dvc gc'" +dvc gc + +dvc_info "Check that we didn't break good cache" +dvc_check_dirs ".dvc/cache" +pushd .dvc/cache +dvc_check_files $ORIG_CACHE +popd + +dvc_info "Check that dummy cache files were removed" +for d in $DUMMY_CACHE; do + if [ -f $d ]; then + dvc_error "Dummy cache file $d was not removed by gc" + dvc_fail + fi +done + +dvc_pass