Skip to content

Commit

Permalink
Merge branch 'tb/commit-graph-tests'
Browse files Browse the repository at this point in the history
Test updates.

* tb/commit-graph-tests:
  t/lib-commit-graph.sh: avoid sub-shell in `graph_git_behavior()`
  t5328: avoid top-level directory changes
  t5318: avoid top-level directory changes
  t/lib-commit-graph.sh: avoid directory change in `graph_git_behavior()`
  t/lib-commit-graph.sh: allow `graph_read_expect()` in sub-directories
  • Loading branch information
gitster committed Aug 7, 2023
2 parents ac83bc5 + f1b9ceb commit dee27be
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 242 deletions.
34 changes: 25 additions & 9 deletions t/lib-commit-graph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,37 @@ graph_git_two_modes() {
test_cmp expect output
}

# graph_git_behavior <name> <directory> <branch> <compare>
#
# Ensures that a handful of traversal operations produce the same
# results with and without the commit-graph in use.
#
# NOTE: it is a bug to call this function with <directory> containing
# any characters in $IFS.
graph_git_behavior() {
MSG=$1
DIR=$2
BRANCH=$3
COMPARE=$4
test_expect_success "check normal git operations: $MSG" '
cd "$TRASH_DIRECTORY/$DIR" &&
graph_git_two_modes "log --oneline $BRANCH" &&
graph_git_two_modes "log --topo-order $BRANCH" &&
graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
graph_git_two_modes "branch -vv" &&
graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
graph_git_two_modes "${DIR:+-C $DIR} log --oneline $BRANCH" &&
graph_git_two_modes "${DIR:+-C $DIR} log --topo-order $BRANCH" &&
graph_git_two_modes "${DIR:+-C $DIR} log --graph $COMPARE..$BRANCH" &&
graph_git_two_modes "${DIR:+-C $DIR} branch -vv" &&
graph_git_two_modes "${DIR:+-C $DIR} merge-base -a $BRANCH $COMPARE"
'
}

graph_read_expect() {
OPTIONAL=""
NUM_CHUNKS=3
DIR="."
if test "$1" = -C
then
shift
DIR="$1"
shift
fi
if test -n "$2"
then
OPTIONAL=" $2"
Expand All @@ -47,12 +60,15 @@ graph_read_expect() {
then
OPTIONS=" read_generation_data"
fi
cat >expect <<- EOF
cat >"$DIR/expect" <<-EOF
header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
num_commits: $1
chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
options:$OPTIONS
EOF
test-tool read-graph >output &&
test_cmp expect output
(
cd "$DIR" &&
test-tool read-graph >output &&
test_cmp expect output
)
}
Loading

0 comments on commit dee27be

Please sign in to comment.