|
1
|
# |
|
2
|
# Copyright (c) 2009 D. Richard Hipp |
|
3
|
# |
|
4
|
# This program is free software; you can redistribute it and/or |
|
5
|
# modify it under the terms of the Simplified BSD License (also |
|
6
|
# known as the "2-Clause License" or "FreeBSD License".) |
|
7
|
# |
|
8
|
# This program is distributed in the hope that it will be useful, |
|
9
|
# but without any warranty; without even the implied warranty of |
|
10
|
# merchantability or fitness for a particular purpose. |
|
11
|
# |
|
12
|
# Author contact information: |
|
13
|
# [email protected] |
|
14
|
# http://www.hwaci.com/drh/ |
|
15
|
# |
|
16
|
############################################################################ |
|
17
|
# |
|
18
|
# Tests of the 3-way merge |
|
19
|
# |
|
20
|
|
|
21
|
test_setup "" |
|
22
|
|
|
23
|
proc merge-test {testid basis v1 v2 result1 result2 {fossil_args ""}} { |
|
24
|
write_file t1 [join [string trim $basis] \n]\n |
|
25
|
write_file t2 [join [string trim $v1] \n]\n |
|
26
|
write_file t3 [join [string trim $v2] \n]\n |
|
27
|
fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args |
|
28
|
fossil 3-way-merge t1 t3 t2 t5 {*}$fossil_args |
|
29
|
set x [read_file t4] |
|
30
|
regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $x {>} x |
|
31
|
regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $x {#} x |
|
32
|
regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $x {=} x |
|
33
|
regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $x {<} x |
|
34
|
set x [split [string trim $x] \n] |
|
35
|
set y [read_file t5] |
|
36
|
regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $y {>} y |
|
37
|
regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $y {#} y |
|
38
|
regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $y {=} y |
|
39
|
regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $y {<} y |
|
40
|
set y [split [string trim $y] \n] |
|
41
|
set result1 [string trim $result1] |
|
42
|
if {$x!=$result1} { |
|
43
|
protOut " Expected \[$result1\]" |
|
44
|
protOut " Got \[$x\]" |
|
45
|
test merge4-$testid 0 |
|
46
|
} else { |
|
47
|
set result2 [string trim $result2] |
|
48
|
if {$y!=$result2} { |
|
49
|
protOut " Expected \[$result2\]" |
|
50
|
protOut " Got \[$y\]" |
|
51
|
test merge4-$testid 0 |
|
52
|
} else { |
|
53
|
test merge4-$testid 1 |
|
54
|
} |
|
55
|
} |
|
56
|
} |
|
57
|
|
|
58
|
merge-test 1000 { |
|
59
|
1 2 3 4 5 6 7 8 9 |
|
60
|
} { |
|
61
|
1 2b 3b 4b 5 6b 7b 8b 9 |
|
62
|
} { |
|
63
|
1 2 3 4c 5c 6c 7 8 9 |
|
64
|
} { |
|
65
|
1 > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 < 9 |
|
66
|
} { |
|
67
|
1 > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b < 9 |
|
68
|
} -expectError |
|
69
|
merge-test 1001 { |
|
70
|
1 2 3 4 5 6 7 8 9 |
|
71
|
} { |
|
72
|
1 2b 3b 4 5 6 7b 8b 9 |
|
73
|
} { |
|
74
|
1 2 3 4c 5c 6c 7 8 9 |
|
75
|
} { |
|
76
|
1 2b 3b 4c 5c 6c 7b 8b 9 |
|
77
|
} { |
|
78
|
1 2b 3b 4c 5c 6c 7b 8b 9 |
|
79
|
} |
|
80
|
merge-test 1002 { |
|
81
|
2 3 4 5 6 7 8 |
|
82
|
} { |
|
83
|
2b 3b 4b 5 6b 7b 8b |
|
84
|
} { |
|
85
|
2 3 4c 5c 6c 7 8 |
|
86
|
} { |
|
87
|
> 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 < |
|
88
|
} { |
|
89
|
> 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b < |
|
90
|
} -expectError |
|
91
|
merge-test 1003 { |
|
92
|
2 3 4 5 6 7 8 |
|
93
|
} { |
|
94
|
2b 3b 4 5 6 7b 8b |
|
95
|
} { |
|
96
|
2 3 4c 5c 6c 7 8 |
|
97
|
} { |
|
98
|
2b 3b 4c 5c 6c 7b 8b |
|
99
|
} { |
|
100
|
2b 3b 4c 5c 6c 7b 8b |
|
101
|
} |
|
102
|
|
|
103
|
############################################################################### |
|
104
|
|
|
105
|
test_cleanup |
|
106
|
|