]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t9351: derive anonymized tree checks from original repo
authorJeff King <peff@peff.net>
Tue, 23 Jun 2020 15:24:47 +0000 (11:24 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2020 02:56:26 +0000 (19:56 -0700)
Our tests of the anonymized repo just hard-code the expected set of
objects in the root and subdirectory trees. This makes them brittle to
the test setup changing (e.g., adding new paths that need tested).

Let's look at the original repo to compute our expected set of objects.
Note that this isn't completely perfect (e.g., we still rely on there
being only one tree in the root), but it does simplify later patches.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t9351-fast-export-anonymize.sh

index 897dc509075a887268f472b8bbdbb5bf67e4d00f..e772cf993082e9f18cbe8b69d39bafa4b3fa54fe 100755 (executable)
@@ -71,22 +71,18 @@ test_expect_success 'repo has original shape and timestamps' '
 
 test_expect_success 'root tree has original shape' '
        # the output entries are not necessarily in the same
-       # order, but we know at least that we will have one tree
-       # and one blob, so just check the sorted order
-       cat >expect <<-\EOF &&
-       blob
-       tree
-       EOF
+       # order, but we should at least have the same set of
+       # object types.
+       git -C .. ls-tree HEAD >orig-root &&
+       cut -d" " -f2 <orig-root | sort >expect &&
        git ls-tree $other_branch >root &&
        cut -d" " -f2 <root | sort >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'paths in subdir ended up in one tree' '
-       cat >expect <<-\EOF &&
-       blob
-       blob
-       EOF
+       git -C .. ls-tree other:subdir >orig-subdir &&
+       cut -d" " -f2 <orig-subdir | sort >expect &&
        tree=$(grep tree root | cut -f2) &&
        git ls-tree $other_branch:$tree >tree &&
        cut -d" " -f2 <tree >actual &&