All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>, Petr Baudis <pasky@suse.cz>
Subject: [PATCH] cg-clean test
Date: Mon, 12 Dec 2005 15:56:15 -0500	[thread overview]
Message-ID: <1134420975.4695.16.camel@dv> (raw)

This is a test for cg-clean functionality.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/t/t9400-clean.sh b/t/t9400-clean.sh
new file mode 100755
index 0000000..76186b6
--- /dev/null
+++ b/t/t9400-clean.sh
@@ -0,0 +1,112 @@
+#!/usr/bin/env bash
+#
+# Copyright (c) 2005 Pvel Roskin
+#
+test_description="Tests basic cg-clean functionality
+
+Create files and directories and check that cg-clean removes them."
+
+. ./test-lib.sh
+
+# Use spaces in names to make sure they are handled properly.
+echo "repo file 1" >"repo file 1"
+mkdir "repo dir"
+echo "repo file 2" >"repo dir/repo file 2"
+echo "*.ign" >".gitignore"
+echo "*.ign1" >"repo dir/.gitignore"
+
+test_expect_success 'initialize repo' \
+	"(cg-add -r * .gitignore && \
+	  cg-commit -C -m\"Initial commit\")"
+
+echo "extra file 1" >"extra file 1"
+mkdir "extra dir 1"
+echo "extra file 2" >"repo dir/extra file 2"
+mkdir "repo dir/extra dir 2"
+echo "extra file 3" >"extra dir 1/extra file 3"
+echo "ign file 1" >"ign file 1.ign"
+echo "ign file 2" >"ign file 2.ign1"
+echo "ign file 3" >"repo dir/ign file 3.ign"
+echo "ign file 4" >"repo dir/ign file 4.ign1"
+
+# Create file lists under .git/temp, exclude .git/ from listings.
+# Compare lists before and after cg-clean and check if only the expected
+# files were removed.
+topdir="`pwd`"
+mkdir .git/temp
+list="$topdir/.git/temp/list"
+
+mklist()
+{
+	cd "$topdir"
+	find . 2>/dev/null |sed -n "/^.\/.git\//d;s/^..//p" | \
+		sort > "$list-$1"
+}
+
+check_loss()
+{
+	mklist new
+	echo "$loss" | cat - "$list-new" | \
+	grep -v ^$ | sort >"$list-combined"
+	diff -u "$list-init" "$list-combined" > "$list.diff" && \
+	cp -f "$list-new" "$list-init"
+}
+
+mklist init
+loss=''
+test_expect_success 'cg-clean -n in top-level dir' \
+	"(cg-clean -n && check_loss)"
+
+test_expect_success 'cg-clean -Ddxqn in top-level dir' \
+	"(cg-clean -Ddxqn && check_loss)"
+
+test_expect_success 'cg-clean -n in subdir' \
+	"(cd 'repo dir' && cg-clean -n && check_loss)"
+
+loss='repo dir/extra file 2'
+test_expect_success 'cg-clean in subdir' \
+	"(cd 'repo dir' && cg-clean && check_loss)"
+
+loss='repo dir/extra dir 2'
+test_expect_success 'cg-clean -d in subdir' \
+	"(cd 'repo dir' && cg-clean -d && check_loss)"
+
+loss='repo dir/ign file 3.ign
+repo dir/ign file 4.ign1'
+test_expect_success 'cg-clean -x in subdir' \
+	"(cd 'repo dir' && cg-clean -x && check_loss)"
+
+# Restore extra files in "repo dir"
+echo "extra file 2" >"repo dir/extra file 2"
+mkdir "repo dir/extra dir 2"
+echo "ign file 3" >"repo dir/ign file 3.ign"
+echo "ign file 4" >"repo dir/ign file 4.ign1"
+mklist init
+
+# FIXME: cg-clean shouldn't clean unknown directories without "-d"
+loss='extra file 1
+ign file 2.ign1
+extra dir 1/extra file 3
+repo dir/extra file 2'
+test_expect_success 'cg-clean in top-level dir' \
+	"(cg-clean && check_loss)"
+
+loss='ign file 1.ign
+repo dir/ign file 3.ign
+repo dir/ign file 4.ign1'
+test_expect_success 'cg-clean -x in top-level dir' \
+	"(cg-clean -x && check_loss)"
+
+loss='extra dir 1
+repo dir/extra dir 2'
+test_expect_success 'cg-clean -d in top-level dir' \
+	"(cg-clean -d && check_loss)"
+
+mkdir "extra dir 3"
+chmod 000 "extra dir 3"
+mklist init
+loss='extra dir 3'
+test_expect_success 'cg-clean -D in top-level dir' \
+	"(cg-clean -D && check_loss)"
+
+test_done


-- 
Regards,
Pavel Roskin

                 reply	other threads:[~2005-12-12 20:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1134420975.4695.16.camel@dv \
    --to=proski@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.