Skip to content

Commit

Permalink
t6600-test-reach: generalize *_three_modes
Browse files Browse the repository at this point in the history
In a preparatory step to implement generation number v2, we add tests to
ensure Git can read and parse commit-graph files without Generation Data
chunk. These files represent commit-graph files written by Old Git and
are neccesary for backward compatability.

We extend run_three_modes() and test_three_modes() to *_all_modes() with
the fourth mode being "commit-graph without generation data chunk".

Signed-off-by: Abhishek Kumar <abhishekkumar8222@gmail.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
abhishekkumar2718 authored and gitster committed Jan 19, 2021
1 parent f90fca6 commit c0ef139
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions t/t6600-test-reach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test_expect_success 'setup' '
git config core.commitGraph true
'

run_three_modes () {
run_all_modes () {
test_when_finished rm -rf .git/objects/info/commit-graph &&
"$@" <input >actual &&
test_cmp expect actual &&
Expand All @@ -70,8 +70,8 @@ run_three_modes () {
test_cmp expect actual
}

test_three_modes () {
run_three_modes test-tool reach "$@"
test_all_modes () {
run_all_modes test-tool reach "$@"
}

test_expect_success 'ref_newer:miss' '
Expand All @@ -80,7 +80,7 @@ test_expect_success 'ref_newer:miss' '
B:commit-4-9
EOF
echo "ref_newer(A,B):0" >expect &&
test_three_modes ref_newer
test_all_modes ref_newer
'

test_expect_success 'ref_newer:hit' '
Expand All @@ -89,7 +89,7 @@ test_expect_success 'ref_newer:hit' '
B:commit-2-3
EOF
echo "ref_newer(A,B):1" >expect &&
test_three_modes ref_newer
test_all_modes ref_newer
'

test_expect_success 'in_merge_bases:hit' '
Expand All @@ -98,7 +98,7 @@ test_expect_success 'in_merge_bases:hit' '
B:commit-8-8
EOF
echo "in_merge_bases(A,B):1" >expect &&
test_three_modes in_merge_bases
test_all_modes in_merge_bases
'

test_expect_success 'in_merge_bases:miss' '
Expand All @@ -107,7 +107,7 @@ test_expect_success 'in_merge_bases:miss' '
B:commit-5-9
EOF
echo "in_merge_bases(A,B):0" >expect &&
test_three_modes in_merge_bases
test_all_modes in_merge_bases
'

test_expect_success 'in_merge_bases_many:hit' '
Expand All @@ -117,7 +117,7 @@ test_expect_success 'in_merge_bases_many:hit' '
X:commit-5-7
EOF
echo "in_merge_bases_many(A,X):1" >expect &&
test_three_modes in_merge_bases_many
test_all_modes in_merge_bases_many
'

test_expect_success 'in_merge_bases_many:miss' '
Expand All @@ -127,7 +127,7 @@ test_expect_success 'in_merge_bases_many:miss' '
X:commit-8-6
EOF
echo "in_merge_bases_many(A,X):0" >expect &&
test_three_modes in_merge_bases_many
test_all_modes in_merge_bases_many
'

test_expect_success 'in_merge_bases_many:miss-heuristic' '
Expand All @@ -137,7 +137,7 @@ test_expect_success 'in_merge_bases_many:miss-heuristic' '
X:commit-6-6
EOF
echo "in_merge_bases_many(A,X):0" >expect &&
test_three_modes in_merge_bases_many
test_all_modes in_merge_bases_many
'

test_expect_success 'is_descendant_of:hit' '
Expand All @@ -148,7 +148,7 @@ test_expect_success 'is_descendant_of:hit' '
X:commit-1-1
EOF
echo "is_descendant_of(A,X):1" >expect &&
test_three_modes is_descendant_of
test_all_modes is_descendant_of
'

test_expect_success 'is_descendant_of:miss' '
Expand All @@ -159,7 +159,7 @@ test_expect_success 'is_descendant_of:miss' '
X:commit-7-6
EOF
echo "is_descendant_of(A,X):0" >expect &&
test_three_modes is_descendant_of
test_all_modes is_descendant_of
'

test_expect_success 'get_merge_bases_many' '
Expand All @@ -174,7 +174,7 @@ test_expect_success 'get_merge_bases_many' '
git rev-parse commit-5-6 \
commit-4-7 | sort
} >expect &&
test_three_modes get_merge_bases_many
test_all_modes get_merge_bases_many
'

test_expect_success 'reduce_heads' '
Expand All @@ -196,7 +196,7 @@ test_expect_success 'reduce_heads' '
commit-2-8 \
commit-1-10 | sort
} >expect &&
test_three_modes reduce_heads
test_all_modes reduce_heads
'

test_expect_success 'can_all_from_reach:hit' '
Expand All @@ -219,7 +219,7 @@ test_expect_success 'can_all_from_reach:hit' '
Y:commit-8-1
EOF
echo "can_all_from_reach(X,Y):1" >expect &&
test_three_modes can_all_from_reach
test_all_modes can_all_from_reach
'

test_expect_success 'can_all_from_reach:miss' '
Expand All @@ -241,7 +241,7 @@ test_expect_success 'can_all_from_reach:miss' '
Y:commit-8-5
EOF
echo "can_all_from_reach(X,Y):0" >expect &&
test_three_modes can_all_from_reach
test_all_modes can_all_from_reach
'

test_expect_success 'can_all_from_reach_with_flag: tags case' '
Expand All @@ -264,7 +264,7 @@ test_expect_success 'can_all_from_reach_with_flag: tags case' '
Y:commit-8-1
EOF
echo "can_all_from_reach_with_flag(X,_,_,0,0):1" >expect &&
test_three_modes can_all_from_reach_with_flag
test_all_modes can_all_from_reach_with_flag
'

test_expect_success 'commit_contains:hit' '
Expand All @@ -280,8 +280,8 @@ test_expect_success 'commit_contains:hit' '
X:commit-9-3
EOF
echo "commit_contains(_,A,X,_):1" >expect &&
test_three_modes commit_contains &&
test_three_modes commit_contains --tag
test_all_modes commit_contains &&
test_all_modes commit_contains --tag
'

test_expect_success 'commit_contains:miss' '
Expand All @@ -297,8 +297,8 @@ test_expect_success 'commit_contains:miss' '
X:commit-9-3
EOF
echo "commit_contains(_,A,X,_):0" >expect &&
test_three_modes commit_contains &&
test_three_modes commit_contains --tag
test_all_modes commit_contains &&
test_all_modes commit_contains --tag
'

test_expect_success 'rev-list: basic topo-order' '
Expand All @@ -310,7 +310,7 @@ test_expect_success 'rev-list: basic topo-order' '
commit-6-2 commit-5-2 commit-4-2 commit-3-2 commit-2-2 commit-1-2 \
commit-6-1 commit-5-1 commit-4-1 commit-3-1 commit-2-1 commit-1-1 \
>expect &&
run_three_modes git rev-list --topo-order commit-6-6
run_all_modes git rev-list --topo-order commit-6-6
'

test_expect_success 'rev-list: first-parent topo-order' '
Expand All @@ -322,7 +322,7 @@ test_expect_success 'rev-list: first-parent topo-order' '
commit-6-2 \
commit-6-1 commit-5-1 commit-4-1 commit-3-1 commit-2-1 commit-1-1 \
>expect &&
run_three_modes git rev-list --first-parent --topo-order commit-6-6
run_all_modes git rev-list --first-parent --topo-order commit-6-6
'

test_expect_success 'rev-list: range topo-order' '
Expand All @@ -334,7 +334,7 @@ test_expect_success 'rev-list: range topo-order' '
commit-6-2 commit-5-2 commit-4-2 \
commit-6-1 commit-5-1 commit-4-1 \
>expect &&
run_three_modes git rev-list --topo-order commit-3-3..commit-6-6
run_all_modes git rev-list --topo-order commit-3-3..commit-6-6
'

test_expect_success 'rev-list: range topo-order' '
Expand All @@ -346,7 +346,7 @@ test_expect_success 'rev-list: range topo-order' '
commit-6-2 commit-5-2 commit-4-2 \
commit-6-1 commit-5-1 commit-4-1 \
>expect &&
run_three_modes git rev-list --topo-order commit-3-8..commit-6-6
run_all_modes git rev-list --topo-order commit-3-8..commit-6-6
'

test_expect_success 'rev-list: first-parent range topo-order' '
Expand All @@ -358,7 +358,7 @@ test_expect_success 'rev-list: first-parent range topo-order' '
commit-6-2 \
commit-6-1 commit-5-1 commit-4-1 \
>expect &&
run_three_modes git rev-list --first-parent --topo-order commit-3-8..commit-6-6
run_all_modes git rev-list --first-parent --topo-order commit-3-8..commit-6-6
'

test_expect_success 'rev-list: ancestry-path topo-order' '
Expand All @@ -368,7 +368,7 @@ test_expect_success 'rev-list: ancestry-path topo-order' '
commit-6-4 commit-5-4 commit-4-4 commit-3-4 \
commit-6-3 commit-5-3 commit-4-3 \
>expect &&
run_three_modes git rev-list --topo-order --ancestry-path commit-3-3..commit-6-6
run_all_modes git rev-list --topo-order --ancestry-path commit-3-3..commit-6-6
'

test_expect_success 'rev-list: symmetric difference topo-order' '
Expand All @@ -382,7 +382,7 @@ test_expect_success 'rev-list: symmetric difference topo-order' '
commit-3-8 commit-2-8 commit-1-8 \
commit-3-7 commit-2-7 commit-1-7 \
>expect &&
run_three_modes git rev-list --topo-order commit-3-8...commit-6-6
run_all_modes git rev-list --topo-order commit-3-8...commit-6-6
'

test_expect_success 'get_reachable_subset:all' '
Expand All @@ -402,7 +402,7 @@ test_expect_success 'get_reachable_subset:all' '
commit-1-7 \
commit-5-6 | sort
) >expect &&
test_three_modes get_reachable_subset
test_all_modes get_reachable_subset
'

test_expect_success 'get_reachable_subset:some' '
Expand All @@ -420,7 +420,7 @@ test_expect_success 'get_reachable_subset:some' '
git rev-parse commit-3-3 \
commit-1-7 | sort
) >expect &&
test_three_modes get_reachable_subset
test_all_modes get_reachable_subset
'

test_expect_success 'get_reachable_subset:none' '
Expand All @@ -434,7 +434,7 @@ test_expect_success 'get_reachable_subset:none' '
Y:commit-2-8
EOF
echo "get_reachable_subset(X,Y)" >expect &&
test_three_modes get_reachable_subset
test_all_modes get_reachable_subset
'

test_done

0 comments on commit c0ef139

Please sign in to comment.