Fossil SCM

Add tests for fossil update.

preben 2024-01-09 18:13 testing-improvements
Commit 78f3ec4c64f759ec8162fe9ac2f2381d7f48c2ed3e2b3d614271fa4d96b73ab0
1 file changed +164
--- a/test/update.test
+++ b/test/update.test
@@ -0,0 +1,164 @@
1
+warninghe hope that it will be useful,
2
+# but without any warranty; without even the implied warranty of
3
+# merchantability or fitness for a particular purpose.
4
+#
5
+# Author contact information:
6
+# [email protected]
7
+# http://www.hwaci.com/drh/
8
+#
9
+######################################}
10
+}
11
+
12
+# Use a sequence number for file content that is not important for the test.
13
+set UPDATE_SEQ_NO 0
14
+proc write_seq_to_file {fname} {
15
+ global UPDATE_SEQ_NO
16
+ incr UPDATE_SEQ_NO
17
+ write_file $fname "$UPDATE_SEQ_NO\n"
18
+}
19
+
20
+# Make sure we are not in an open repository and initialize new repository
21
+test_setup
22
+
23
+###############################################################################
24
+
25
+fossil update --verbose
26
+test update-already-up-to-date {
27
+ [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
28
+}
29
+
30
+# Remaining tests are carried out in the order update_cmd() performs checks.
31
+#
32
+# Common approach for tests below:
33
+# 1. Set the testname
34
+# 2. Set the file name, done by calling update_setup
35
+# 3. Set message and changes, the expected message message and subsequent changes
36
+# 3. Optionally set up and commit a common base for the next steps
37
+# 4. C} {e that it will be warninghe evious version
38
+# 6. Make changes
39
+# 7. Call test_update to attempt and update to tip
40
+
41
+
42
+set testname "conflict-standard"
43
+set fname [test_update_setup $testname]
44
+set message "CONFLICT $fname"
45
+set changes "EDITED $fname"
46
+write_seq_to_file $fname
47
+fossil add $fname
48
+fossil commit -m "Add $fname"
49
+fossil up previous
50
+write_seq_to_file $fname
51
+fossil add $fname
52
+test_update $testname $message $changes -expectError
53
+
54
+set testname "add-overwrites"
55
+set fname [test_update_setup $testname]
56
+set message "ADD $fname - overwrites an unmanaged file, original copy backe
57
+fossil add $fname
58
+fossil commit -m "Add $fname"
59
+write_seq_to_file $fname
60
+name"
61
+fossil up previous
62
+
63
+ fossil changes
64
+ test "update-changes-$testname" {$changes == $::RESULT}
65
+}
66
+
67
+# Use a sequence number for file content that is not important for the test.
68
+set UPDATE_SEQ_NO 0
69
+proc write_seq_to_file {fname} {
70
+ global UPDATE_SEQ_NO
71
+ incr UPDATE_SEQ_NO
72
+ write_file $fname "$UPDATE_SEQ_NO\n"
73
+}
74
+
75
+# Make sure we are not in an open repository and initialize new repository
76
+test_setup
77
+
78
+###############################################################################
79
+
80
+fossil update --verbose
81
+test update-already-up-to-date {
82
+ [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
83
+}
84
+
85
+# Remaining tests are carried out in the order update_cmd() performs checks.
86
+#
87
+# Common approaile $fname
88
+warning, te set up in test_update_setup. This helps ensure
89
+# that generated files are ordered in `fossil update --verbose` mode.
90
+set UPDATE_TEST 0
91
+
92
+proc test_update_setup {desc} {
93
+ global UPDATE_TEST
94
+ incr UPDATE_TEST
95
+ fossil revert
96
+ fossil eben Guldnerg <[email protected]>
97
+#
98
+# This program is free software; you can redistribute it and/or
99
+# modify it under the terms of the Simplified BSD License (also
100
+# known as the "2-Clause License" or "FreeBSD License".)
101
+#
102
+# This program is distributed in the hope that it will be useful,
103
+# but without any warranty; without even the implied warranty of
104
+# merchantability or fitness for a particular purpose.
105
+#
106
+# Author contact information:
107
+# [email protected]
108
+# http://www.hwaci.com/drh/
109
+#
110
+############################################################################
111
+#
112
+# Tests for the "update
113
+ test "update-changes-$testname" {$changes == $::RESULT}
114
+}
115
+
116
+# Use a sequence number for file content that is not important for the test.
117
+set UPDATE_SEQ_NO 0
118
+proc write_seq_to_file {fname} {
119
+ global UPDATE_SEQ_NO
120
+ incr UPDATE_SEQ_NO
121
+ write_file $fname "$UPDATE_SEQ_NO\n"
122
+}
123
+
124
+# Make sure we are not in an open repository and initialize new repository
125
+test_setup
126
+
127
+###############################################################################
128
+
129
+fossil update --verbose
130
+test update-already-up-to-date {
131
+ [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
132
+}
133
+
134
+# Remaining tests are carried out in the order update_cmd() performs checks.
135
+#
136
+# Common approach for tests below:
137
+# 1. Set the testname
138
+# 2. Set the file name, done by calling update_setup
139
+# 3. Set message and changes, the expected message message and subsequent changes
140
+# 3. Optionally set up and commit a common base for the next steps
141
+# 4. Commit a change to the repository (new tip)
142
+# 5. Update to the previous version
143
+# 6. Make changes
144
+# 7. Call test_update to attempt and update to tip
145
+
146
+
147
+set testname "conflict-standard"
148
+set fname [test_update_setup $testname]
149
+set message "CONFLICT $fname"
150
+set changes "EDITED $fname"
151
+write_seq_to_file $fname
152
+fossil add $fname
153
+fossil commit -m "Add $fname"
154
+fossil up previous
155
+write_seq_to_file $fname
156
+fossil add $fname
157
+test_update $testname $message $changes -expectError
158
+
159
+set testname "add-overwrites"
160
+set fname [test_update_setup $testname]
161
+set message "ADD $fname - overwrites an unmanaged file, original copy backe
162
+fossil add $fname
163
+fossil commit -m "Add $fname"
164
+write
--- a/test/update.test
+++ b/test/update.test
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/update.test
+++ b/test/update.test
@@ -0,0 +1,164 @@
1 warninghe hope that it will be useful,
2 # but without any warranty; without even the implied warranty of
3 # merchantability or fitness for a particular purpose.
4 #
5 # Author contact information:
6 # [email protected]
7 # http://www.hwaci.com/drh/
8 #
9 ######################################}
10 }
11
12 # Use a sequence number for file content that is not important for the test.
13 set UPDATE_SEQ_NO 0
14 proc write_seq_to_file {fname} {
15 global UPDATE_SEQ_NO
16 incr UPDATE_SEQ_NO
17 write_file $fname "$UPDATE_SEQ_NO\n"
18 }
19
20 # Make sure we are not in an open repository and initialize new repository
21 test_setup
22
23 ###############################################################################
24
25 fossil update --verbose
26 test update-already-up-to-date {
27 [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
28 }
29
30 # Remaining tests are carried out in the order update_cmd() performs checks.
31 #
32 # Common approach for tests below:
33 # 1. Set the testname
34 # 2. Set the file name, done by calling update_setup
35 # 3. Set message and changes, the expected message message and subsequent changes
36 # 3. Optionally set up and commit a common base for the next steps
37 # 4. C} {e that it will be warninghe evious version
38 # 6. Make changes
39 # 7. Call test_update to attempt and update to tip
40
41
42 set testname "conflict-standard"
43 set fname [test_update_setup $testname]
44 set message "CONFLICT $fname"
45 set changes "EDITED $fname"
46 write_seq_to_file $fname
47 fossil add $fname
48 fossil commit -m "Add $fname"
49 fossil up previous
50 write_seq_to_file $fname
51 fossil add $fname
52 test_update $testname $message $changes -expectError
53
54 set testname "add-overwrites"
55 set fname [test_update_setup $testname]
56 set message "ADD $fname - overwrites an unmanaged file, original copy backe
57 fossil add $fname
58 fossil commit -m "Add $fname"
59 write_seq_to_file $fname
60 name"
61 fossil up previous
62
63 fossil changes
64 test "update-changes-$testname" {$changes == $::RESULT}
65 }
66
67 # Use a sequence number for file content that is not important for the test.
68 set UPDATE_SEQ_NO 0
69 proc write_seq_to_file {fname} {
70 global UPDATE_SEQ_NO
71 incr UPDATE_SEQ_NO
72 write_file $fname "$UPDATE_SEQ_NO\n"
73 }
74
75 # Make sure we are not in an open repository and initialize new repository
76 test_setup
77
78 ###############################################################################
79
80 fossil update --verbose
81 test update-already-up-to-date {
82 [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
83 }
84
85 # Remaining tests are carried out in the order update_cmd() performs checks.
86 #
87 # Common approaile $fname
88 warning, te set up in test_update_setup. This helps ensure
89 # that generated files are ordered in `fossil update --verbose` mode.
90 set UPDATE_TEST 0
91
92 proc test_update_setup {desc} {
93 global UPDATE_TEST
94 incr UPDATE_TEST
95 fossil revert
96 fossil eben Guldnerg <[email protected]>
97 #
98 # This program is free software; you can redistribute it and/or
99 # modify it under the terms of the Simplified BSD License (also
100 # known as the "2-Clause License" or "FreeBSD License".)
101 #
102 # This program is distributed in the hope that it will be useful,
103 # but without any warranty; without even the implied warranty of
104 # merchantability or fitness for a particular purpose.
105 #
106 # Author contact information:
107 # [email protected]
108 # http://www.hwaci.com/drh/
109 #
110 ############################################################################
111 #
112 # Tests for the "update
113 test "update-changes-$testname" {$changes == $::RESULT}
114 }
115
116 # Use a sequence number for file content that is not important for the test.
117 set UPDATE_SEQ_NO 0
118 proc write_seq_to_file {fname} {
119 global UPDATE_SEQ_NO
120 incr UPDATE_SEQ_NO
121 write_file $fname "$UPDATE_SEQ_NO\n"
122 }
123
124 # Make sure we are not in an open repository and initialize new repository
125 test_setup
126
127 ###############################################################################
128
129 fossil update --verbose
130 test update-already-up-to-date {
131 [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
132 }
133
134 # Remaining tests are carried out in the order update_cmd() performs checks.
135 #
136 # Common approach for tests below:
137 # 1. Set the testname
138 # 2. Set the file name, done by calling update_setup
139 # 3. Set message and changes, the expected message message and subsequent changes
140 # 3. Optionally set up and commit a common base for the next steps
141 # 4. Commit a change to the repository (new tip)
142 # 5. Update to the previous version
143 # 6. Make changes
144 # 7. Call test_update to attempt and update to tip
145
146
147 set testname "conflict-standard"
148 set fname [test_update_setup $testname]
149 set message "CONFLICT $fname"
150 set changes "EDITED $fname"
151 write_seq_to_file $fname
152 fossil add $fname
153 fossil commit -m "Add $fname"
154 fossil up previous
155 write_seq_to_file $fname
156 fossil add $fname
157 test_update $testname $message $changes -expectError
158
159 set testname "add-overwrites"
160 set fname [test_update_setup $testname]
161 set message "ADD $fname - overwrites an unmanaged file, original copy backe
162 fossil add $fname
163 fossil commit -m "Add $fname"
164 write

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button