From 1af9f9bd95283544b068dbbe33e923ab9e836243 Mon Sep 17 00:00:00 2001 From: Suyashtnt Date: Mon, 8 Jul 2024 18:11:06 +0200 Subject: niri-config: update wiki parses test to test all codeblocks This makes sure the failing codeblocks do fail. This also optimizes the algorithm a bit by removing a `.collect()` Signed-off-by: Suyashtnt --- niri-config/tests/wiki-parses.rs | 42 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/niri-config/tests/wiki-parses.rs b/niri-config/tests/wiki-parses.rs index 9c03b471..ca7e9b75 100644 --- a/niri-config/tests/wiki-parses.rs +++ b/niri-config/tests/wiki-parses.rs @@ -1,19 +1,18 @@ use std::fs; use std::path::PathBuf; -const NO_TEST_COMMENT: &str = ""; - struct KdlCodeBlock { filename: String, code: String, line_number: usize, + must_fail: bool, } fn extract_kdl_from_file(file_contents: &str, filename: &str) -> Vec { - // Removes the > from callouts that might contain ```kdl``` - let lines: Vec<_> = file_contents + let mut lines = file_contents .lines() .map(|line| { + // Removes the > from callouts that might contain ```kdl``` let line = line.trim(); if line.starts_with(">") { if line.len() == 1 { @@ -25,22 +24,18 @@ fn extract_kdl_from_file(file_contents: &str, filename: &str) -> Vec Vec