Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 38361c0

Browse files
committed
Make file_lines_to_json test deterministic
1 parent 4604f46 commit 38361c0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/config/file_lines.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl str::FromStr for FileLines {
293293
}
294294

295295
// For JSON decoding.
296-
#[derive(Clone, Debug, Deserialize, Serialize)]
296+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Deserialize, Serialize)]
297297
pub struct JsonSpan {
298298
file: FileName,
299299
range: (usize, usize),
@@ -401,11 +401,13 @@ mod test {
401401
])].iter().cloned().collect();
402402

403403
let file_lines = FileLines::from_ranges(ranges);
404-
let json = json::to_value(&file_lines.to_json_spans()).unwrap();
404+
let mut spans = file_lines.to_json_spans();
405+
spans.sort();
406+
let json = json::to_value(&spans).unwrap();
405407
assert_eq!(json, json! {[
408+
{"file": "src/lib.rs", "range": [1, 7]},
406409
{"file": "src/main.rs", "range": [1, 3]},
407410
{"file": "src/main.rs", "range": [5, 7]},
408-
{"file": "src/lib.rs", "range": [1, 7]},
409411
]});
410412
}
411413
}

0 commit comments

Comments
 (0)