@matheusbsbs / matheus-bagliano / commits / b8c0689bb9
Fork 0

t9351: derive anonymized tree checks from original repo

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>

Jeff King committed Jun 23, 2020 at 11:24 UTC b8c0689bb97b3ef3027e4d3670538d4cdacd638d
1 file changed +6 -10
t/t9351-fast-export-anonymize.sh
+6 -10
@@ -71,22 +71,18 @@ test_expect_success 'repo has original shape and timestamps' '
71
72 test_expect_success 'root tree has original shape' '
73 # the output entries are not necessarily in the same
74 - # order, but we know at least that we will have one tree
75 - # and one blob, so just check the sorted order
76 - cat >expect <<-\EOF &&
77 - blob
78 - tree
79 - EOF
74 + # order, but we should at least have the same set of
75 + # object types.
76 + git -C .. ls-tree HEAD >orig-root &&
77 + cut -d" " -f2 <orig-root | sort >expect &&
78 git ls-tree $other_branch >root &&
79 cut -d" " -f2 <root | sort >actual &&
80 test_cmp expect actual
81 '
82
83 test_expect_success 'paths in subdir ended up in one tree' '
86 - cat >expect <<-\EOF &&
87 - blob
88 - blob
89 - EOF
84 + git -C .. ls-tree other:subdir >orig-subdir &&
85 + cut -d" " -f2 <orig-subdir | sort >expect &&
86 tree=$(grep tree root | cut -f2) &&
87 git ls-tree $other_branch:$tree >tree &&
88 cut -d" " -f2 <tree >actual &&