summaryrefslogtreecommitdiff
path: root/t/t6019-rev-list-ancestry-path.sh
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2022-08-19 04:28:09 +0000
committerJunio C Hamano <gitster@pobox.com>2022-08-19 10:45:07 -0700
commit1838e21cff17f97900a4987b35ba70ca48bce4b7 (patch)
tree7ac22e068f1fb3b100bc78050acae4fe1e408963 /t/t6019-rev-list-ancestry-path.sh
parent11ea33ce444f929908990ec24c58d848373bdda3 (diff)
downloadgit-1838e21cff17f97900a4987b35ba70ca48bce4b7.tar.gz
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 <derrickstolee@github.com> Signed-off-by: Elijah Newren <newren@gmail.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6019-rev-list-ancestry-path.sh')
-rwxr-xr-xt/t6019-rev-list-ancestry-path.sh87
1 files changed, 25 insertions, 62 deletions
diff --git a/t/t6019-rev-list-ancestry-path.sh b/t/t6019-rev-list-ancestry-path.sh
index af57a04b7f..5bd787a3c0 100755
--- a/t/t6019-rev-list-ancestry-path.sh
+++ b/t/t6019-rev-list-ancestry-path.sh
@@ -50,73 +50,36 @@ test_expect_success setup '
test_commit M
'
-test_expect_success 'rev-list D..M' '
- test_write_lines E F G H I J K L M >expect &&
- git rev-list --format=%s D..M |
- sed -e "/^commit /d" |
- sort >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'rev-list --ancestry-path D..M' '
- test_write_lines E F H I J L M >expect &&
- git rev-list --ancestry-path --format=%s D..M |
- sed -e "/^commit /d" |
- sort >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'rev-list D..M -- M.t' '
- echo M >expect &&
- git rev-list --format=%s D..M -- M.t |
- sed -e "/^commit /d" >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
- echo M >expect &&
- git rev-list --ancestry-path --format=%s D..M -- M.t |
- sed -e "/^commit /d" >actual &&
- test_cmp expect actual
-'
+test_ancestry () {
+ args=$1
+ expected=$2
+ test_expect_success "log $args" "
+ test_write_lines $expected >expect &&
+ git log --format=%s $args >raw &&
+
+ if test -n \"$expected\"
+ then
+ sort raw >actual &&
+ test_cmp expect actual
+ else
+ test_must_be_empty raw
+ fi
+ "
+}
-test_expect_success 'rev-list F...I' '
- test_write_lines F G H I >expect &&
- git rev-list --format=%s F...I |
- sed -e "/^commit /d" |
- sort >actual &&
- test_cmp expect actual
-'
+test_ancestry "D..M" "E F G H I J K L M"
-test_expect_success 'rev-list --ancestry-path F...I' '
- test_write_lines F H I >expect &&
- git rev-list --ancestry-path --format=%s F...I |
- sed -e "/^commit /d" |
- sort >actual &&
- test_cmp expect actual
-'
+test_ancestry "--ancestry-path D..M" "E F H I J L M"
-# G.t is dropped in an "-s ours" merge
-test_expect_success 'rev-list G..M -- G.t' '
- git rev-list --format=%s G..M -- G.t |
- sed -e "/^commit /d" >actual &&
- test_must_be_empty actual
-'
+test_ancestry "D..M -- M.t" "M"
+test_ancestry "--ancestry-path D..M -- M.t" "M"
-test_expect_success 'rev-list --ancestry-path G..M -- G.t' '
- echo L >expect &&
- git rev-list --ancestry-path --format=%s G..M -- G.t |
- sed -e "/^commit /d" >actual &&
- test_cmp expect actual
-'
+test_ancestry "F...I" "F G H I"
+test_ancestry "--ancestry-path F...I" "F H I"
-test_expect_success 'rev-list --ancestry-path --simplify-merges G^..M -- G.t' '
- test_write_lines G L >expect &&
- git rev-list --ancestry-path --simplify-merges --format=%s G^..M -- G.t |
- sed -e "/^commit /d" |
- sort >actual &&
- test_cmp expect actual
-'
+test_ancestry "G..M -- G.t" ""
+test_ancestry "--ancestry-path G..M -- G.t" "L"
+test_ancestry "--ancestry-path --simplify-merges G^..M -- G.t" "G L"
# b---bc
# / \ /