diff options
| author | Junio C Hamano <gitster@pobox.com> | 2023-08-07 11:57:18 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2023-08-07 11:57:18 -0700 |
| commit | dee27be9056c05067b6dba3fc5805f311f03ce67 (patch) | |
| tree | 795d5628da84689ef02ed6e3aff652234167ef84 /t/lib-commit-graph.sh | |
| parent | ac83bc5054c2ac489166072334b4147ce6d0fccb (diff) | |
| parent | f1b9cebc8bdc01c5b8643fac9f78f2962df82cf3 (diff) | |
| download | git-dee27be9056c05067b6dba3fc5805f311f03ce67.tar.xz | |
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
Diffstat (limited to 't/lib-commit-graph.sh')
| -rwxr-xr-x | t/lib-commit-graph.sh | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/t/lib-commit-graph.sh b/t/lib-commit-graph.sh index 5d79e1a4e9..89b26676fb 100755 --- a/t/lib-commit-graph.sh +++ b/t/lib-commit-graph.sh @@ -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" @@ -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 + ) } |
