diff options
-rw-r--r-- | cli/tests/testdata/test/markdown.md | 6 | ||||
-rw-r--r-- | cli/tests/testdata/test/markdown.out | 4 | ||||
-rw-r--r-- | cli/tools/test_runner.rs | 24 |
3 files changed, 22 insertions, 12 deletions
diff --git a/cli/tests/testdata/test/markdown.md b/cli/tests/testdata/test/markdown.md index e5afb841b..d18dbd108 100644 --- a/cli/tests/testdata/test/markdown.md +++ b/cli/tests/testdata/test/markdown.md @@ -18,6 +18,12 @@ The following block should be given a ts extension on extraction: console.log("ts"); ``` +The following example contains the ignore attribute and will be ignored: + +```ts ignore +const value: Invalid = "ignored"; +``` + The following example will trigger the type-checker to fail: ```ts diff --git a/cli/tests/testdata/test/markdown.out b/cli/tests/testdata/test/markdown.out index 3f7bc7366..38c9f0349 100644 --- a/cli/tests/testdata/test/markdown.out +++ b/cli/tests/testdata/test/markdown.out @@ -1,7 +1,7 @@ Check [WILDCARD]/test/markdown.md$11-14.js Check [WILDCARD]/test/markdown.md$17-20.ts -Check [WILDCARD]/test/markdown.md$23-26.ts +Check [WILDCARD]/test/markdown.md$29-32.ts error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. const a: string = 42; ^ - at [WILDCARD]/test/markdown.md$23-26.ts:1:7 + at [WILDCARD]/test/markdown.md$29-32.ts:1:7 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 { |