Skip to content

Commit 1838e21

Browse files
derrickstoleegitster
authored andcommitted
t6019: modernize tests with helper
The tests in t6019 are repetitive, so create a helper that greatly simplifies the test script. In addition, update the common pattern that places 'git rev-list' on the left side of a pipe, which can hide some exit codes. Send the output to a 'raw' file that is then consumed by other tools so the Git exit code is verified as zero. And since we're using --format anyway, switch to `git log`, so that we get the desired format and can avoid using sed. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 11ea33c commit 1838e21

File tree

1 file changed

+25
-62
lines changed

1 file changed

+25
-62
lines changed

t/t6019-rev-list-ancestry-path.sh

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -50,73 +50,36 @@ test_expect_success setup '
5050
test_commit M
5151
'
5252

53-
test_expect_success 'rev-list D..M' '
54-
test_write_lines E F G H I J K L M >expect &&
55-
git rev-list --format=%s D..M |
56-
sed -e "/^commit /d" |
57-
sort >actual &&
58-
test_cmp expect actual
59-
'
60-
61-
test_expect_success 'rev-list --ancestry-path D..M' '
62-
test_write_lines E F H I J L M >expect &&
63-
git rev-list --ancestry-path --format=%s D..M |
64-
sed -e "/^commit /d" |
65-
sort >actual &&
66-
test_cmp expect actual
67-
'
68-
69-
test_expect_success 'rev-list D..M -- M.t' '
70-
echo M >expect &&
71-
git rev-list --format=%s D..M -- M.t |
72-
sed -e "/^commit /d" >actual &&
73-
test_cmp expect actual
74-
'
75-
76-
test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
77-
echo M >expect &&
78-
git rev-list --ancestry-path --format=%s D..M -- M.t |
79-
sed -e "/^commit /d" >actual &&
80-
test_cmp expect actual
81-
'
53+
test_ancestry () {
54+
args=$1
55+
expected=$2
56+
test_expect_success "log $args" "
57+
test_write_lines $expected >expect &&
58+
git log --format=%s $args >raw &&
59+
60+
if test -n \"$expected\"
61+
then
62+
sort raw >actual &&
63+
test_cmp expect actual
64+
else
65+
test_must_be_empty raw
66+
fi
67+
"
68+
}
8269

83-
test_expect_success 'rev-list F...I' '
84-
test_write_lines F G H I >expect &&
85-
git rev-list --format=%s F...I |
86-
sed -e "/^commit /d" |
87-
sort >actual &&
88-
test_cmp expect actual
89-
'
70+
test_ancestry "D..M" "E F G H I J K L M"
9071

91-
test_expect_success 'rev-list --ancestry-path F...I' '
92-
test_write_lines F H I >expect &&
93-
git rev-list --ancestry-path --format=%s F...I |
94-
sed -e "/^commit /d" |
95-
sort >actual &&
96-
test_cmp expect actual
97-
'
72+
test_ancestry "--ancestry-path D..M" "E F H I J L M"
9873

99-
# G.t is dropped in an "-s ours" merge
100-
test_expect_success 'rev-list G..M -- G.t' '
101-
git rev-list --format=%s G..M -- G.t |
102-
sed -e "/^commit /d" >actual &&
103-
test_must_be_empty actual
104-
'
74+
test_ancestry "D..M -- M.t" "M"
75+
test_ancestry "--ancestry-path D..M -- M.t" "M"
10576

106-
test_expect_success 'rev-list --ancestry-path G..M -- G.t' '
107-
echo L >expect &&
108-
git rev-list --ancestry-path --format=%s G..M -- G.t |
109-
sed -e "/^commit /d" >actual &&
110-
test_cmp expect actual
111-
'
77+
test_ancestry "F...I" "F G H I"
78+
test_ancestry "--ancestry-path F...I" "F H I"
11279

113-
test_expect_success 'rev-list --ancestry-path --simplify-merges G^..M -- G.t' '
114-
test_write_lines G L >expect &&
115-
git rev-list --ancestry-path --simplify-merges --format=%s G^..M -- G.t |
116-
sed -e "/^commit /d" |
117-
sort >actual &&
118-
test_cmp expect actual
119-
'
80+
test_ancestry "G..M -- G.t" ""
81+
test_ancestry "--ancestry-path G..M -- G.t" "L"
82+
test_ancestry "--ancestry-path --simplify-merges G^..M -- G.t" "G L"
12083

12184
# b---bc
12285
# / \ /

0 commit comments

Comments
 (0)