Skip to content

Commit 70fe59f

Browse files
committed
Parse the output while parsing the baseline file.
1 parent 535e967 commit 70fe59f

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

git-date/tests/fixtures/generate_git_date_baseline.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,3 @@ baseline '123456789'
3939
# raw
4040
baseline '1660874655 +0800'
4141

42-
# failing
43-
44-
# empty_input
45-
baseline ""
46-
Binary file not shown.

git-date/tests/time/parse.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use once_cell::sync::Lazy;
66

77
type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>;
88

9-
static BASELINE: Lazy<HashMap<BString, (usize, BString)>> = Lazy::new(|| {
9+
static BASELINE: Lazy<HashMap<BString, (usize, u32)>> = Lazy::new(|| {
1010
let base = git_testtools::scripted_fixture_repo_read_only("generate_git_date_baseline.sh").unwrap();
1111

1212
(|| -> Result<_> {
@@ -15,7 +15,14 @@ static BASELINE: Lazy<HashMap<BString, (usize, BString)>> = Lazy::new(|| {
1515
let mut lines = baseline.lines();
1616
while let Some(date_str) = lines.next() {
1717
let exit_code = lines.next().expect("three lines per baseline").to_str()?.parse()?;
18-
let output = lines.next().expect("three lines per baseline").into();
18+
let output = u32::from_str(
19+
lines
20+
.next()
21+
.expect("three lines per baseline")
22+
.to_str()
23+
.expect("valid utf"),
24+
)
25+
.expect("valid epoch value");
1926
map.insert(date_str.into(), (exit_code, output));
2027
}
2128
Ok(map)
@@ -34,8 +41,7 @@ fn baseline() {
3441
);
3542
if *exit_code == 0 {
3643
let actual = res.unwrap().seconds_since_unix_epoch;
37-
let expected = u32::from_str(output.to_str().expect("valid utf")).expect("valid epoch value");
38-
assert_eq!(actual, expected, "{pattern:?} disagrees with baseline: {actual:?}")
44+
assert_eq!(actual, *output, "{pattern:?} disagrees with baseline: {actual:?}")
3945
}
4046
}
4147
}

0 commit comments

Comments
 (0)