Duy Nguyen <pclo...@gmail.com> writes:

> On Sat, Jul 13, 2013 at 12:26 AM, Thomas Gummerer <t.gumme...@gmail.com> 
> wrote:
>>  t/perf/p0003-index.sh                            |   59 +
>>  t/t2104-update-index-skip-worktree.sh            |    1 +
>
> For such a big code addition, the test part seems modest. Speaking
> from my experience, I rarely run perf tests and "make test" does not
> activate v5 code at all. A few more tests would be nice. The good news
> is I changed default index version to 5 and ran "make test", all
> passed.

I was using the test suite with index version 5 as default index version
for testing of the new index file format.   I think that's the best way
to test the index, as it covers all aspects.  Maybe we should add a test
that covers the basic functionality, just to make sure nothing obvious
is broken when running the test suite with index-v2?  Something like
this maybe:

--->8---

>From c476b521c94f1a9b0b4fcfe92d63321442d79c9a Mon Sep 17 00:00:00 2001
From: Thomas Gummerer <t.gumme...@gmail.com>
Date: Mon, 15 Jul 2013 11:21:06 +0200
Subject: [PATCH] t1600: add basic test for index-v5

Add a test that checks the index-v5 file format when running the
test-suite with index-v2 as default index format.  When making changes
to the index, the test suite still should be run with both index v2 and
index v5 as default index format, for better coverage of all aspects of
the index.

Signed-off-by: Thomas Gummerer <t.gumme...@gmail.com>
---
 t/t1600-index-v5.sh | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100755 t/t1600-index-v5.sh

diff --git a/t/t1600-index-v5.sh b/t/t1600-index-v5.sh
new file mode 100755
index 0000000..528c17e
--- /dev/null
+++ b/t/t1600-index-v5.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+# Copyright (c) 2013 Thomas Gummerer
+
+test_description='Test basic functionaltiy of index-v5.
+
+This test just covers the basics, to make sure normal runs of the test
+suite cover this version of the index file format too.  For better
+testing of the index-v5 format, the default index version should be
+changed to 5 and the test suite should be re-run'
+
+. ./test-lib.sh
+
+check_resolve_undo () {
+       msg=$1
+       shift
+       while case $# in
+       0)      break ;;
+       1|2|3)  die "Bug in check-resolve-undo test" ;;
+       esac
+       do
+               path=$1
+               shift
+               for stage in 1 2 3
+               do
+                       sha1=$1
+                       shift
+                       case "$sha1" in
+                       '') continue ;;
+                       esac
+                       sha1=$(git rev-parse --verify "$sha1")
+                       printf "100644 %s %s\t%s\n" $sha1 $stage $path
+               done
+       done >"$msg.expect" &&
+       git ls-files --resolve-undo >"$msg.actual" &&
+       test_cmp "$msg.expect" "$msg.actual"
+}
+
+prime_resolve_undo () {
+       git reset --hard &&
+       git checkout second^0 &&
+       test_tick &&
+       test_must_fail git merge third^0 &&
+       echo merge does not leave anything &&
+       check_resolve_undo empty &&
+       echo different >fi/le &&
+       git add fi/le &&
+       echo resolving records &&
+       check_resolve_undo recorded fi/le initial:fi/le second:fi/le third:fi/le
+}
+
+test_expect_success 'setup' '
+       git update-index --index-version=5 &&
+       echo file1 >file1 &&
+       echo file2 >file2 &&
+       mkdir -p top/sub &&
+       echo x >top/x &&
+       echo xy >top/xy &&
+       echo y >top/y &&
+       echo yx >top/yx &&
+       echo sub1 >top/sub/sub1 &&
+       git add . &&
+       git commit -m "initial import"
+'
+
+test_expect_success 'ls-files shows all files' '
+       cat >expected <<-EOF &&
+       100644 e2129701f1a4d54dc44f03c93bca0a2aec7c5449 0       file1
+       100644 6c493ff740f9380390d5c9ddef4af18697ac9375 0       file2
+       100644 48df0cb83fee5d667537343f60a6057a63dd3c9b 0       top/sub/sub1
+       100644 587be6b4c3f93f93c489c0111bba5596147a26cb 0       top/x
+       100644 5aad9376af82d7b98a34f95fb0f298a162f52656 0       top/xy
+       100644 975fbec8256d3e8a3797e7a3611380f27c49f4ac 0       top/y
+       100644 ba1575927fa5b1f4bce72ad0c349566f1b02508e 0       top/yx
+       EOF
+       git ls-files --stage >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'ls-files with pathspec in subdir' '
+       cd top/sub &&
+       cat >expected <<-EOF &&
+       ../x
+       ../xy
+       EOF
+       git ls-files --error-unmatch ../x* >actual &&
+       test_cmp expected actual &&
+       cd ../..
+'
+
+test_expect_success 'read-tree HEAD establishes cache-tree' '
+       git read-tree HEAD &&
+       cat >expected <<-EOF &&
+       84e73410ea7864ccada24d897462e8ce1e1b872b  (7 entries, 1 subtrees)
+       602482536bd3852e8ac2977ed1a9913a8c244aa0 top/ (5 entries, 1 subtrees)
+       20bb0109200f37a7e19283b4abc4a672be3f0adb top/sub/ (1 entries, 0 
subtrees)
+       EOF
+       test-dump-cache-tree >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'setup resolve-undo' '
+       mkdir fi &&
+       printf "a\0a" >binary &&
+       git add binary &&
+       test_commit initial fi/le first &&
+       git branch side &&
+       git branch another &&
+       printf "a\0b" >binary &&
+       git add binary &&
+       test_commit second fi/le second &&
+       git checkout side &&
+       test_commit third fi/le third &&
+       git branch add-add &&
+       git checkout another &&
+       test_commit fourth fi/le fourth &&
+       git checkout add-add &&
+       test_commit fifth add-differently &&
+       git checkout master
+'
+
+test_expect_success 'add records switch clears' '
+       prime_resolve_undo &&
+       test_tick &&
+       git commit -m merged &&
+       echo committing keeps &&
+       check_resolve_undo kept fi/le initial:fi/le second:fi/le third:fi/le &&
+       git checkout second^0 &&
+       echo switching clears &&
+       check_resolve_undo cleared
+'
+
+test_done
--
1.8.3.453.g1dfc63d
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to