add simple tests of consistency across rebase types

Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin von Zweigbergk committed Jun 6, 2013 at 23:11 UTC 2aad7cace2253797fe0cd688e20f39ffb66db995
2 files changed +94
t/lib-rebase.sh
+16
@@ -65,3 +65,19 @@ EOF
65 test_set_editor "$(pwd)/fake-editor.sh"
66 chmod a+x fake-editor.sh
67 }
68 +
69 +# checks that the revisions in "$2" represent a linear range with the
70 +# subjects in "$1"
71 +test_linear_range () {
72 + revlist_merges=$(git rev-list --merges "$2") &&
73 + test -z "$revlist_merges" &&
74 + expected=$1
75 + set -- $(git log --reverse --format=%s "$2")
76 + test "$expected" = "$*"
77 +}
78 +
79 +reset_rebase () {
80 + test_might_fail git rebase --abort &&
81 + git reset --hard &&
82 + git clean -f
83 +}
t/t3421-rebase-topology-linear.sh new
+78
@@ -0,0 +1,78 @@
1 +#!/bin/sh
2 +
3 +test_description='basic rebase topology tests'
4 +. ./test-lib.sh
5 +. "$TEST_DIRECTORY"/lib-rebase.sh
6 +
7 +# a---b---c
8 +# \
9 +# d---e
10 +test_expect_success 'setup' '
11 + test_commit a &&
12 + test_commit b &&
13 + test_commit c &&
14 + git checkout b &&
15 + test_commit d &&
16 + test_commit e
17 +'
18 +
19 +test_run_rebase () {
20 + result=$1
21 + shift
22 + test_expect_$result "simple rebase $*" "
23 + reset_rebase &&
24 + git rebase $* c e &&
25 + test_cmp_rev c HEAD~2 &&
26 + test_linear_range 'd e' c..
27 + "
28 +}
29 +test_run_rebase success ''
30 +test_run_rebase success -m
31 +test_run_rebase success -i
32 +test_run_rebase success -p
33 +
34 +test_run_rebase () {
35 + result=$1
36 + shift
37 + test_expect_$result "rebase $* is no-op if upstream is an ancestor" "
38 + reset_rebase &&
39 + git rebase $* b e &&
40 + test_cmp_rev e HEAD
41 + "
42 +}
43 +test_run_rebase success ''
44 +test_run_rebase success -m
45 +test_run_rebase success -i
46 +test_run_rebase success -p
47 +
48 +test_run_rebase () {
49 + result=$1
50 + shift
51 + test_expect_$result "rebase $* -f rewrites even if upstream is an ancestor" "
52 + reset_rebase &&
53 + git rebase $* -f b e &&
54 + ! test_cmp_rev e HEAD &&
55 + test_cmp_rev b HEAD~2 &&
56 + test_linear_range 'd e' b..
57 + "
58 +}
59 +test_run_rebase success ''
60 +test_run_rebase success -m
61 +test_run_rebase success -i
62 +test_run_rebase failure -p
63 +
64 +test_run_rebase () {
65 + result=$1
66 + shift
67 + test_expect_$result "rebase $* fast-forwards from ancestor of upstream" "
68 + reset_rebase &&
69 + git rebase $* e b &&
70 + test_cmp_rev e HEAD
71 + "
72 +}
73 +test_run_rebase success ''
74 +test_run_rebase success -m
75 +test_run_rebase success -i
76 +test_run_rebase success -p
77 +
78 +test_done