@@ -214,22 +214,22 @@ mod test {
214
214
} ;
215
215
( $any: tt, $commit_msg: literal) => {
216
216
compile_error!( concat!(
217
- "expected no_commit or nothing for commit " ,
217
+ "expected ` no_commit` or nothing for commit " ,
218
218
$commit_msg
219
219
) )
220
220
} ;
221
221
}
222
222
223
- macro_rules! add_flag {
224
- ( add , $commit_msg: literal, $line: expr) => {
223
+ macro_rules! insert_flag {
224
+ ( insert , $commit_msg: literal, $line: expr) => {
225
225
true
226
226
} ;
227
227
( , $commit_msg: literal, $line: expr) => {
228
228
false
229
229
} ;
230
230
( $any: tt, $commit_msg: literal, $line: expr) => {
231
231
compile_error!( concat!(
232
- "expected no_commit or nothing for commit " ,
232
+ "expected `insert` or nothing for commit " ,
233
233
$commit_msg,
234
234
" line " ,
235
235
$line
@@ -244,6 +244,8 @@ mod test {
244
244
/// which then becomes the new contents of the $file
245
245
///
246
246
/// Each $line gets blamed using blame_line. The $expected is the commit identifier that we are expecting for that line.
247
+ ///
248
+ /// $commit_msg can also have a `no_commit` ident next to it, in which case this block won't be committed
247
249
macro_rules! assert_line_blame_progress {
248
250
( $( $commit_msg: literal $( $no_commit: ident) ? => $( $line: literal $( $expected: literal) ? $( $added: ident) ? ) ,+) ;+ $( ; ) ?) => { {
249
251
use std:: fs:: OpenOptions ;
@@ -279,7 +281,7 @@ mod test {
279
281
280
282
$(
281
283
line_number += 1 ;
282
- let has_add_flag = add_flag !( $( $added) ?, $commit_msg, $line) ;
284
+ let has_add_flag = insert_flag !( $( $added) ?, $commit_msg, $line) ;
283
285
if has_add_flag {
284
286
added_lines += 1 ;
285
287
}
@@ -311,24 +313,42 @@ mod test {
311
313
"fn main() {" 1 ,
312
314
"" 1 ,
313
315
"}" 1 ;
316
+ // modifying a line works
314
317
2 =>
315
318
"fn main() {" 1 ,
316
319
" one" 2 ,
317
320
"}" 1 ;
321
+ // inserting a line works
318
322
3 =>
319
323
"fn main() {" 1 ,
320
324
" one" 2 ,
321
325
" two" 3 ,
322
326
"}" 1 ;
327
+ // deleting a line works
323
328
4 =>
324
329
"fn main() {" 1 ,
325
330
" two" 3 ,
326
331
"}" 1 ;
332
+ // when a line is inserted in-between the blame order is preserved
327
333
5 no_commit =>
328
334
"fn main() {" 1 ,
329
- " hello world" add ,
335
+ " hello world" insert ,
330
336
" two" 3 ,
331
337
"}" 1 ;
338
+ // Having a bunch of random lines interspersed should not change which lines
339
+ // have blame for which commits
340
+ 6 no_commit =>
341
+ " six" insert,
342
+ " three" insert,
343
+ "fn main() {" 1 ,
344
+ " five" insert,
345
+ " four" insert,
346
+ " two" 3 ,
347
+ " five" insert,
348
+ " four" insert,
349
+ "}" 1 ,
350
+ " five" insert,
351
+ " four" insert;
332
352
} ;
333
353
}
334
354
0 commit comments