Skip to content

Commit f830c76

Browse files
committed
test: with interspersed lines
1 parent d553b81 commit f830c76

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

helix-vcs/src/git/blame.rs

+26-6
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,22 @@ mod test {
214214
};
215215
($any:tt, $commit_msg:literal) => {
216216
compile_error!(concat!(
217-
"expected no_commit or nothing for commit ",
217+
"expected `no_commit` or nothing for commit ",
218218
$commit_msg
219219
))
220220
};
221221
}
222222

223-
macro_rules! add_flag {
224-
(add, $commit_msg:literal, $line:expr) => {
223+
macro_rules! insert_flag {
224+
(insert, $commit_msg:literal, $line:expr) => {
225225
true
226226
};
227227
(, $commit_msg:literal, $line:expr) => {
228228
false
229229
};
230230
($any:tt, $commit_msg:literal, $line:expr) => {
231231
compile_error!(concat!(
232-
"expected no_commit or nothing for commit ",
232+
"expected `insert` or nothing for commit ",
233233
$commit_msg,
234234
" line ",
235235
$line
@@ -244,6 +244,8 @@ mod test {
244244
/// which then becomes the new contents of the $file
245245
///
246246
/// 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
247249
macro_rules! assert_line_blame_progress {
248250
($($commit_msg:literal $($no_commit:ident)? => $($line:literal $($expected:literal)? $($added:ident)? ),+);+ $(;)?) => {{
249251
use std::fs::OpenOptions;
@@ -279,7 +281,7 @@ mod test {
279281

280282
$(
281283
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);
283285
if has_add_flag {
284286
added_lines += 1;
285287
}
@@ -311,24 +313,42 @@ mod test {
311313
"fn main() {" 1,
312314
"" 1,
313315
"}" 1;
316+
// modifying a line works
314317
2 =>
315318
"fn main() {" 1,
316319
" one" 2,
317320
"}" 1;
321+
// inserting a line works
318322
3 =>
319323
"fn main() {" 1,
320324
" one" 2,
321325
" two" 3,
322326
"}" 1;
327+
// deleting a line works
323328
4 =>
324329
"fn main() {" 1,
325330
" two" 3,
326331
"}" 1;
332+
// when a line is inserted in-between the blame order is preserved
327333
5 no_commit =>
328334
"fn main() {" 1,
329-
" hello world" add,
335+
" hello world" insert,
330336
" two" 3,
331337
"}" 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;
332352
};
333353
}
334354

0 commit comments

Comments
 (0)