summaryrefslogtreecommitdiff
path: root/cli/tools/test_runner.rs
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2021-08-14 18:33:58 +0800
committerGitHub <noreply@github.com>2021-08-14 12:33:58 +0200
commitf90231924d96130ec80b31e3589253a15e250896 (patch)
treedad74b1a8b9112ba6d55ae4fe6b3a3d7b2257a5e /cli/tools/test_runner.rs
parent1d1507384bca78027c9003b81465bd99a585cace (diff)
fix(cli): explicitly scan for ignore attribute in inline tests (#11647)
This commits adds "ignore" as a known attribute for Markdown codeblock which drops a code block early whenever it is seen in documentation tests.
Diffstat (limited to 'cli/tools/test_runner.rs')
-rw-r--r--cli/tools/test_runner.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs
index 4cc006ae1..304c61b11 100644
--- a/cli/tools/test_runner.rs
+++ b/cli/tools/test_runner.rs
@@ -300,17 +300,21 @@ fn extract_files_from_regex_blocks(
let files = blocks_regex
.captures_iter(source)
.filter_map(|block| {
- let maybe_attributes = block
+ let maybe_attributes: Option<Vec<_>> = block
.get(1)
- .map(|attributes| attributes.as_str().split(' '));
-
- let file_media_type = if let Some(mut attributes) = maybe_attributes {
- match attributes.next() {
- Some("js") => MediaType::JavaScript,
- Some("jsx") => MediaType::Jsx,
- Some("ts") => MediaType::TypeScript,
- Some("tsx") => MediaType::Tsx,
- Some("") => *media_type,
+ .map(|attributes| attributes.as_str().split(' ').collect());
+
+ let file_media_type = if let Some(attributes) = maybe_attributes {
+ if attributes.contains(&"ignore") {
+ return None;
+ }
+
+ match attributes.get(0) {
+ Some(&"js") => MediaType::JavaScript,
+ Some(&"jsx") => MediaType::Jsx,
+ Some(&"ts") => MediaType::TypeScript,
+ Some(&"tsx") => MediaType::Tsx,
+ Some(&"") => *media_type,
_ => MediaType::Unknown,
}
} else {