Merge branch 'ds/t7700-kept-pack-test'

Test clean-up.

* ds/t7700-kept-pack-test:
  test-lib-functions: remove test_subcommand_inexact
  t7700: check post-condition in kept-pack test
This commit is contained in:
Junio C Hamano 2022-04-04 10:56:21 -07:00
commit e8926670d4
2 changed files with 54 additions and 37 deletions

View File

@ -369,10 +369,61 @@ test_expect_success '--write-midx with preferred bitmap tips' '
)
'
# The first argument is expected to be a filename
# and that file should contain the name of a .idx
# file. Send the list of objects in that .idx file
# into stdout.
get_sorted_objects_from_pack () {
git show-index <$(cat "$1") >raw &&
cut -d" " -f2 raw
}
test_expect_success '--write-midx -b packs non-kept objects' '
GIT_TRACE2_EVENT="$(pwd)/trace.txt" \
git repack --write-midx -a -b &&
test_subcommand_inexact git pack-objects --honor-pack-keep <trace.txt
git init repo &&
test_when_finished "rm -fr repo" &&
(
cd repo &&
# Create a kept pack-file
test_commit base &&
git repack -ad &&
find $objdir/pack -name "*.idx" >before &&
test_line_count = 1 before &&
before_name=$(cat before) &&
>${before_name%.idx}.keep &&
# Create a non-kept pack-file
test_commit other &&
git repack &&
# Create loose objects
test_commit loose &&
# Repack everything
git repack --write-midx -a -b -d &&
# There should be two pack-files now, the
# old, kept pack and the new, non-kept pack.
find $objdir/pack -name "*.idx" | sort >after &&
test_line_count = 2 after &&
find $objdir/pack -name "*.keep" >kept &&
kept_name=$(cat kept) &&
echo ${kept_name%.keep}.idx >kept-idx &&
test_cmp before kept-idx &&
# Get object list from the kept pack.
get_sorted_objects_from_pack before >old.objects &&
# Get object list from the one non-kept pack-file
comm -13 before after >new-pack &&
test_line_count = 1 new-pack &&
get_sorted_objects_from_pack new-pack >new.objects &&
# None of the objects in the new pack should
# exist within the kept pack.
comm -12 old.objects new.objects >shared.objects &&
test_must_be_empty shared.objects
)
'
test_expect_success TTY '--quiet disables progress' '

View File

@ -1864,40 +1864,6 @@ test_subcommand () {
fi
}
# Check that the given command was invoked as part of the
# trace2-format trace on stdin, but without an exact set of
# arguments.
#
# test_subcommand [!] <command> <args>... < <trace>
#
# For example, to look for an invocation of "git pack-objects"
# with the "--honor-pack-keep" argument, use
#
# GIT_TRACE2_EVENT=event.log git repack ... &&
# test_subcommand git pack-objects --honor-pack-keep <event.log
#
# If the first parameter passed is !, this instead checks that
# the given command was not called.
#
test_subcommand_inexact () {
local negate=
if test "$1" = "!"
then
negate=t
shift
fi
local expr=$(printf '"%s".*' "$@")
expr="${expr%,}"
if test -n "$negate"
then
! grep "\"event\":\"child_start\".*\[$expr\]"
else
grep "\"event\":\"child_start\".*\[$expr\]"
fi
}
# Check that the given command was invoked as part of the
# trace2-format trace on stdin.
#