Skip to content

Commit dee27be

Browse files
committed
Merge branch 'tb/commit-graph-tests'
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
2 parents ac83bc5 + f1b9ceb commit dee27be

File tree

3 files changed

+224
-242
lines changed

3 files changed

+224
-242
lines changed

t/lib-commit-graph.sh

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,37 @@ graph_git_two_modes() {
1414
test_cmp expect output
1515
}
1616

17+
# graph_git_behavior <name> <directory> <branch> <compare>
18+
#
19+
# Ensures that a handful of traversal operations produce the same
20+
# results with and without the commit-graph in use.
21+
#
22+
# NOTE: it is a bug to call this function with <directory> containing
23+
# any characters in $IFS.
1724
graph_git_behavior() {
1825
MSG=$1
1926
DIR=$2
2027
BRANCH=$3
2128
COMPARE=$4
2229
test_expect_success "check normal git operations: $MSG" '
23-
cd "$TRASH_DIRECTORY/$DIR" &&
24-
graph_git_two_modes "log --oneline $BRANCH" &&
25-
graph_git_two_modes "log --topo-order $BRANCH" &&
26-
graph_git_two_modes "log --graph $COMPARE..$BRANCH" &&
27-
graph_git_two_modes "branch -vv" &&
28-
graph_git_two_modes "merge-base -a $BRANCH $COMPARE"
30+
graph_git_two_modes "${DIR:+-C $DIR} log --oneline $BRANCH" &&
31+
graph_git_two_modes "${DIR:+-C $DIR} log --topo-order $BRANCH" &&
32+
graph_git_two_modes "${DIR:+-C $DIR} log --graph $COMPARE..$BRANCH" &&
33+
graph_git_two_modes "${DIR:+-C $DIR} branch -vv" &&
34+
graph_git_two_modes "${DIR:+-C $DIR} merge-base -a $BRANCH $COMPARE"
2935
'
3036
}
3137

3238
graph_read_expect() {
3339
OPTIONAL=""
3440
NUM_CHUNKS=3
41+
DIR="."
42+
if test "$1" = -C
43+
then
44+
shift
45+
DIR="$1"
46+
shift
47+
fi
3548
if test -n "$2"
3649
then
3750
OPTIONAL=" $2"
@@ -47,12 +60,15 @@ graph_read_expect() {
4760
then
4861
OPTIONS=" read_generation_data"
4962
fi
50-
cat >expect <<- EOF
63+
cat >"$DIR/expect" <<-EOF
5164
header: 43475048 1 $(test_oid oid_version) $NUM_CHUNKS 0
5265
num_commits: $1
5366
chunks: oid_fanout oid_lookup commit_metadata$OPTIONAL
5467
options:$OPTIONS
5568
EOF
56-
test-tool read-graph >output &&
57-
test_cmp expect output
69+
(
70+
cd "$DIR" &&
71+
test-tool read-graph >output &&
72+
test_cmp expect output
73+
)
5874
}

0 commit comments

Comments
 (0)