Skip to content

Commit 5696e38

Browse files
ytmimicalebcartwright
authored andcommitted
Add test to verify tracking issue links
Now, tracking issue links are checked against the reference number listed in the link text to ensure they match.
1 parent 9c65db6 commit 5696e38

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/test/configuration_snippet.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,33 @@ fn get_code_blocks() -> Vec<ConfigCodeBlock> {
290290

291291
code_blocks
292292
}
293+
294+
#[test]
295+
fn check_unstable_option_tracking_issue_numbers() {
296+
// Ensure that tracking issue links point to the correct issue number
297+
let tracking_issue =
298+
regex::Regex::new(r"\(tracking issue: \[#(?P<number>\d+)\]\((?P<link>\S+)\)\)")
299+
.expect("failed creating configuration pattern");
300+
301+
let lines = BufReader::new(
302+
fs::File::open(Path::new(CONFIGURATIONS_FILE_NAME))
303+
.unwrap_or_else(|_| panic!("couldn't read file {}", CONFIGURATIONS_FILE_NAME)),
304+
)
305+
.lines()
306+
.map(Result::unwrap)
307+
.enumerate();
308+
309+
for (idx, line) in lines {
310+
if let Some(capture) = tracking_issue.captures(&line) {
311+
let number = capture.name("number").unwrap().as_str();
312+
let link = capture.name("link").unwrap().as_str();
313+
assert!(
314+
link.ends_with(number),
315+
"{} on line {} does not point to issue #{}",
316+
link,
317+
idx + 1,
318+
number,
319+
);
320+
}
321+
}
322+
}

0 commit comments

Comments
 (0)