From: Johan Herland <johan@herland.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <junkio@cox.net>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5/7] Softrefs: Add testcases for basic softrefs behaviour
Date: Sat, 09 Jun 2007 20:23:38 +0200 [thread overview]
Message-ID: <200706092023.38661.johan@herland.net> (raw)
In-Reply-To: <200706092019.13185.johan@herland.net>
Adds testing of the basic options available to the git-softref command.
Signed-off-by: Johan Herland <johan@herland.net>
---
t/t3050-softrefs.sh | 314 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 314 insertions(+), 0 deletions(-)
create mode 100755 t/t3050-softrefs.sh
diff --git a/t/t3050-softrefs.sh b/t/t3050-softrefs.sh
new file mode 100755
index 0000000..a925178
--- /dev/null
+++ b/t/t3050-softrefs.sh
@@ -0,0 +1,314 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Johan Herland
+#
+
+test_description='Basic functionality of soft references'
+. ./test-lib.sh
+
+
+# Prepare repo and create some notes
+
+test_expect_success 'Populating repo with test data' '
+ echo "foo" > foo &&
+ git-add foo &&
+ test_tick &&
+ git-commit -m "Initial commit" &&
+ git-tag -a -m "Tagging initial commit" footag &&
+ echo "bar" >> foo &&
+ test_tick &&
+ git-commit -m "Second commit" foo &&
+ git-tag -a -m "Tagging second commit" bartag
+'
+
+# At this point we should have:
+# - commit @ 301711b66fe71164f646b798706a2c1f7024da8d ("Initial commit")
+# - tag @ ad60bc179c6874af6d97f181c67f11adcca5122b ("footag")
+# - commit @ 9671cbee7ad26528645b2665c8f74d39a6288864 ("Second commit")
+# - tag @ a927fc832d42f1f64d8318e8acec43545d9562de ("bartag")
+# - The tag creation should also have created softrefs:
+# - From "Initial commit" to "footag"
+# - From "Second commit" to "bartag"
+
+# Testing git-softref --list
+
+test_expect_success 'Testing git-softref --list on initial test data (1)' '
+ cat > expected_output << EOF &&
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ git-softref > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list > actual_output 2>&1 &&
+ cmp actual_output expected_output
+'
+
+test_expect_success 'Testing git-softref --list on initial test data (2)' '
+ cat > expected_output << EOF &&
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ git-softref --list 9671cbee7ad26528645b2665c8f74d39a6288864 > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list HEAD > actual_output 2>&1 &&
+ cmp actual_output expected_output
+'
+
+test_expect_success 'Testing git-softref --list on initial test data (3)' '
+ cat > expected_output << EOF &&
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+EOF
+ git-softref --list 301711b66fe71164f646b798706a2c1f7024da8d > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list HEAD^ > actual_output 2>&1 &&
+ cmp actual_output expected_output
+'
+
+test_expect_success 'Testing git-softref --list on initial test data (4)' '
+ cat > expected_output << EOF &&
+EOF
+ git-softref --list footag > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list bartag > actual_output 2>&1 &&
+ cmp actual_output expected_output
+'
+
+# Testing git-softref --has
+
+test_expect_success 'Testing git-softref --has on initial test data' '
+ (git-softref --has 301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b;
+ test "$?" = "1") &&
+ (git-softref --has HEAD^ footag;
+ test "$?" = "1") &&
+ (git-softref --has footag^{} footag;
+ test "$?" = "1") &&
+ (git-softref --has 9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de;
+ test "$?" = "1") &&
+ (git-softref --has HEAD bartag;
+ test "$?" = "1") &&
+ (git-softref --has bartag^{} bartag;
+ test "$?" = "1") &&
+ (git-softref --has ad60bc179c6874af6d97f181c67f11adcca5122b 301711b66fe71164f646b798706a2c1f7024da8d;
+ test "$?" = "0") &&
+ (git-softref --has a927fc832d42f1f64d8318e8acec43545d9562de 9671cbee7ad26528645b2665c8f74d39a6288864;
+ test "$?" = "0") &&
+ (git-softref --has HEAD HEAD^;
+ test "$?" = "0") &&
+ (git-softref --has HEAD^ HEAD;
+ test "$?" = "0") &&
+ (git-softref --has footag HEAD;
+ test "$?" = "0") &&
+ (git-softref --has bartag HEAD;
+ test "$?" = "0") &&
+ (git-softref --has footag HEAD^;
+ test "$?" = "0") &&
+ (git-softref --has bartag HEAD^;
+ test "$?" = "0") &&
+ (git-softref --has footag bartag;
+ test "$?" = "0") &&
+ (git-softref --has bartag footag;
+ test "$?" = "0")
+'
+
+# Testing git-softref --rebuild-tags
+
+test_expect_success 'Testing git-softref --rebuild-tags on initial test data' '
+ cat > expected_output << EOF &&
+Added 0 missing softrefs for tag objects.
+EOF
+ cat .git/softrefs.* | sort > expected_softrefs &&
+ git-softref --rebuild-tags > actual_output 2>&1 &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+# Testing git-softref --add
+
+test_expect_success 'Testing git-softref --add with existing softref' '
+ cat > expected_output << EOF &&
+EOF
+ cat .git/softrefs.* | sort > expected_softrefs &&
+ git-softref --add HEAD bartag > actual_output 2>&1 &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+test_expect_success 'Testing git-softref --add with self-refential softref' '
+ cat > expected_output << EOF &&
+error: Cannot add self-reference (9671cbee7ad26528645b2665c8f74d39a6288864 -> 9671cbee7ad26528645b2665c8f74d39a6288864)
+fatal: Failed to create softref from HEAD to HEAD
+EOF
+ cat .git/softrefs.* | sort > expected_softrefs &&
+ (git-softref --add HEAD HEAD > actual_output 2>&1; test "$?" != "0") &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+test_expect_success 'Testing git-softref --add with non-existing objects (1)' '
+ cat > expected_output << EOF &&
+fatal: Not a valid object name 1234567890123456789012345678901234567890
+EOF
+ cat .git/softrefs.* | sort > expected_softrefs &&
+ (git-softref --add 1234567890123456789012345678901234567890 HEAD > actual_output 2>&1;
+ test "$?" != "0") &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs &&
+ (git-softref --add HEAD 1234567890123456789012345678901234567890 > actual_output 2>&1;
+ test "$?" != "0") &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+test_expect_success 'Testing git-softref --add with non-existing objects (2)' '
+ cat > expected_output << EOF &&
+fatal: Not a valid object name HEAD^^^
+EOF
+ cat .git/softrefs.* | sort > expected_softrefs &&
+ (git-softref --add HEAD^^^ HEAD > actual_output 2>&1; test "$?" != "0") &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+test_expect_success 'Testing git-softref --add with valid arguments (1)' '
+ cat > expected_output << EOF &&
+EOF
+ cat > new_softref << EOF
+301711b66fe71164f646b798706a2c1f7024da8d 9671cbee7ad26528645b2665c8f74d39a6288864
+EOF
+ cat .git/softrefs.* new_softref | sort > expected_softrefs &&
+ git-softref --add HEAD^ HEAD > actual_output 2>&1 &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+test_expect_success 'Testing git-softref --add with valid arguments (2)' '
+ cat > expected_output << EOF &&
+EOF
+ cat > new_softref << EOF
+ad60bc179c6874af6d97f181c67f11adcca5122b a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ cat .git/softrefs.* new_softref | sort > expected_softrefs &&
+ git-softref --add footag bartag > actual_output 2>&1 &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+# Removing softrefs
+
+test_expect_success 'Removing all softrefs' '
+ rm .git/softrefs.*
+'
+
+# Testing git-softref --list and --has
+
+test_expect_success 'Testing git-softref with no softrefs' '
+ cat > expected_output << EOF &&
+EOF
+ git-softref > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list 9671cbee7ad26528645b2665c8f74d39a6288864 > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list HEAD > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list HEAD^ > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list footag > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --list bartag > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --has HEAD bartag > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ git-softref --has HEAD^ footag > actual_output 2>&1 &&
+ cmp actual_output expected_output
+'
+
+# Testing git-softref --rebuild-tags
+# (Should recreated missing softrefs for tag objects reachable from 'refs/tags')
+
+test_expect_success 'Testing git-softref --rebuild-tags to rebuild missing tag softrefs' '
+ cat > expected_output << EOF &&
+Added 2 missing softrefs for tag objects.
+EOF
+ cat > new_softref << EOF
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ cat .git/softrefs.* new_softref | sort > expected_softrefs &&
+ git-softref --rebuild-tags > actual_output 2>&1 &&
+ cat .git/softrefs.* | sort > actual_softrefs &&
+ cmp actual_output expected_output &&
+ cmp actual_softrefs expected_softrefs
+'
+
+# Testing git-softref --merge-unsorted
+
+test_expect_success 'Testing git-softref --merge-unsorted' '
+ cat > expected_output << EOF &&
+EOF
+ rm .git/softrefs*
+ cat > .git/softrefs.unsorted << EOF
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+EOF
+ cat > expected_softrefs << EOF
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ git-softref --merge-unsorted > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ cmp .git/softrefs.sorted expected_softrefs &&
+ test ! -e .git/softrefs.unsorted
+'
+
+# Testing git-softref --merge-unsorted <filename>
+
+test_expect_success 'Testing git-softref --merge-unsorted <filename>' '
+ cat > expected_output << EOF &&
+EOF
+ rm .git/softrefs*
+ cat > new_softrefs << EOF
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+EOF
+ cat > expected_softrefs << EOF
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ git-softref --merge-unsorted new_softrefs > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ cmp .git/softrefs.sorted expected_softrefs &&
+ test -e new_softrefs
+'
+
+# Testing git-softref --merge-sorted <filename>
+
+test_expect_success 'Testing git-softref --merge-sorted <filename>' '
+ cat > expected_output << EOF &&
+EOF
+ rm .git/softrefs*
+ cat > new_softrefs << EOF
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ cat > expected_softrefs << EOF
+301711b66fe71164f646b798706a2c1f7024da8d ad60bc179c6874af6d97f181c67f11adcca5122b
+9671cbee7ad26528645b2665c8f74d39a6288864 a927fc832d42f1f64d8318e8acec43545d9562de
+EOF
+ git-softref --merge-sorted new_softrefs > actual_output 2>&1 &&
+ cmp actual_output expected_output &&
+ cmp .git/softrefs.sorted expected_softrefs &&
+ test -e new_softrefs
+'
+
+# FIXME: More testing needed on how softrefs interact with the rest of git
+
+test_done
--
1.5.2.1.144.gabc40
next prev parent reply other threads:[~2007-06-09 18:23 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-04 0:51 Refactoring the tag object; Introducing soft references (softrefs); Git 'notes' (take 2) Johan Herland
2007-06-04 0:51 ` [PATCH 0/6] Refactor the tag object Johan Herland
2007-06-04 0:52 ` [PATCH 1/6] Refactor git tag objects; make "tag" header optional; introduce new optional "keywords" header Johan Herland
2007-06-04 6:08 ` Matthias Lederhofer
2007-06-04 7:30 ` Johan Herland
2007-06-04 0:53 ` [PATCH 2/6] git-show: When showing tag objects with no tag name, show tag object's SHA1 instead of an empty string Johan Herland
2007-06-04 0:53 ` [PATCH 3/6] git-fsck: Do thorough verification of tag objects Johan Herland
2007-06-04 5:56 ` Matthias Lederhofer
2007-06-04 7:51 ` Johan Herland
2007-06-06 7:18 ` Junio C Hamano
2007-06-06 8:06 ` Johan Herland
2007-06-06 9:03 ` Junio C Hamano
2007-06-06 9:21 ` Junio C Hamano
2007-06-06 10:26 ` Johan Herland
2007-06-06 10:35 ` Junio C Hamano
2007-06-04 0:54 ` [PATCH 4/6] Documentation/git-mktag: Document the changes in tag object structure Johan Herland
2007-06-04 0:54 ` [PATCH 5/6] git-mktag tests: Fix and expand the mktag tests according to the new " Johan Herland
2007-06-04 0:54 ` [PATCH 6/6] Add fsck_verify_ref_to_tag_object() to verify that refname matches name stored in tag object Johan Herland
2007-06-04 20:32 ` [PATCH 0/6] Refactor the " Junio C Hamano
2007-06-07 22:13 ` [PATCH] Fix bug in tag parsing when thorough verification was in effect Johan Herland
2007-06-09 18:19 ` [PATCH 0/7] Introduce soft references (softrefs) Johan Herland
2007-06-09 18:21 ` [PATCH 1/7] Softrefs: Add softrefs header file with API documentation Johan Herland
2007-06-10 6:58 ` Johannes Schindelin
2007-06-10 7:43 ` Junio C Hamano
2007-06-10 7:54 ` Johannes Schindelin
2007-06-10 14:00 ` Johan Herland
2007-06-10 14:27 ` Jakub Narebski
2007-06-10 14:45 ` [PATCH] Teach git-gc to merge unsorted softrefs Johan Herland
2007-06-09 18:22 ` [PATCH 2/7] Softrefs: Add implementation of softrefs API Johan Herland
2007-06-09 18:22 ` [PATCH 3/7] Softrefs: Add git-softref, a builtin command for adding, listing and administering softrefs Johan Herland
2007-06-09 18:23 ` [PATCH 4/7] Softrefs: Add manual page documenting git-softref and softrefs subsystem in general Johan Herland
2007-06-09 18:23 ` Johan Herland [this message]
2007-06-09 18:24 ` [PATCH 6/7] Softrefs: Administrivia associated with softrefs subsystem and git-softref builtin Johan Herland
2007-06-09 18:24 ` [PATCH 7/7] Teach git-mktag to register softrefs for all tag objects Johan Herland
2007-06-09 18:25 ` [PATCH] Change softrefs file format from text (82 bytes per entry) to binary (40 bytes per entry) Johan Herland
2007-06-10 8:02 ` Johannes Schindelin
2007-06-10 8:30 ` Junio C Hamano
2007-06-10 9:46 ` Johannes Schindelin
2007-06-10 14:03 ` Johan Herland
2007-06-09 23:55 ` Comment on weak refs Junio C Hamano
2007-06-10 1:25 ` Johan Herland
2007-06-10 6:33 ` Johannes Schindelin
2007-06-10 13:41 ` Johan Herland
2007-06-10 14:09 ` Pierre Habouzit
2007-06-10 14:25 ` Pierre Habouzit
2007-06-10 9:03 ` Pierre Habouzit
2007-06-10 15:26 ` Jakub Narebski
2007-06-09 22:57 ` Refactoring the tag object; Introducing soft references (softrefs); Git 'notes' (take 2) Steven Grimm
2007-06-09 23:16 ` Johan Herland
2007-06-10 8:29 ` Pierre Habouzit
2007-06-10 14:31 ` Johan Herland
2007-06-10 19:42 ` Steven Grimm
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=200706092023.38661.johan@herland.net \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=torvalds@linux-foundation.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).