mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(test): support typechecking docs with CRLF line endings (#12748)
This commit is contained in:
parent
dd91ecef50
commit
58e7b290dc
7 changed files with 51 additions and 3 deletions
|
@ -25,6 +25,7 @@
|
||||||
"cli/tests/testdata/badly_formatted.json",
|
"cli/tests/testdata/badly_formatted.json",
|
||||||
"cli/tests/testdata/byte_order_mark.ts",
|
"cli/tests/testdata/byte_order_mark.ts",
|
||||||
"cli/tests/testdata/fmt/*",
|
"cli/tests/testdata/fmt/*",
|
||||||
|
"cli/tests/testdata/test/markdown_windows.md",
|
||||||
"cli/tsc/*typescript.js",
|
"cli/tsc/*typescript.js",
|
||||||
"test_util/std",
|
"test_util/std",
|
||||||
"test_util/wpt",
|
"test_util/wpt",
|
||||||
|
|
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -12,3 +12,6 @@
|
||||||
# Doesn't include them in the language statistics.
|
# Doesn't include them in the language statistics.
|
||||||
/cli/tsc/00_typescript.js linguist-vendored
|
/cli/tsc/00_typescript.js linguist-vendored
|
||||||
/cli/dts/* linguist-vendored
|
/cli/dts/* linguist-vendored
|
||||||
|
|
||||||
|
# Keep Windows line endings in cross-platform doc check test file
|
||||||
|
/cli/tests/testdata/test/markdown_windows.md eol=crlf
|
||||||
|
|
|
@ -129,7 +129,7 @@ fn fmt_ignore_unexplicit_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
itest!(fmt_check_tests_dir {
|
itest!(fmt_check_tests_dir {
|
||||||
args: "fmt --check ./ --ignore=.test_coverage,fmt/fmt_with_config/",
|
args: "fmt --check ./ --ignore=.test_coverage,fmt/fmt_with_config/,test/markdown_windows.md",
|
||||||
output: "fmt/expected_fmt_check_tests_dir.out",
|
output: "fmt/expected_fmt_check_tests_dir.out",
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,6 +85,12 @@ itest!(markdown {
|
||||||
output: "test/markdown.out",
|
output: "test/markdown.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(markdown_windows {
|
||||||
|
args: "test --doc --allow-all test/markdown_windows.md",
|
||||||
|
exit_code: 1,
|
||||||
|
output: "test/markdown_windows.out",
|
||||||
|
});
|
||||||
|
|
||||||
itest!(text {
|
itest!(text {
|
||||||
args: "test --doc --allow-all test/text.md",
|
args: "test --doc --allow-all test/text.md",
|
||||||
exit_code: 0,
|
exit_code: 0,
|
||||||
|
|
31
cli/tests/testdata/test/markdown_windows.md
vendored
Normal file
31
cli/tests/testdata/test/markdown_windows.md
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# Documentation
|
||||||
|
|
||||||
|
The following block does not have a language attribute and should be ignored:
|
||||||
|
|
||||||
|
```
|
||||||
|
This is a fenced block without attributes, it's invalid and it should be ignored.
|
||||||
|
```
|
||||||
|
|
||||||
|
The following block should be given a js extension on extraction:
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log("js");
|
||||||
|
```
|
||||||
|
|
||||||
|
The following block should be given a ts extension on extraction:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
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
|
||||||
|
const a: string = 42;
|
||||||
|
```
|
7
cli/tests/testdata/test/markdown_windows.out
vendored
Normal file
7
cli/tests/testdata/test/markdown_windows.out
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
Check [WILDCARD]/test/markdown_windows.md$11-14.js
|
||||||
|
Check [WILDCARD]/test/markdown_windows.md$17-20.ts
|
||||||
|
Check [WILDCARD]/test/markdown_windows.md$29-32.ts
|
||||||
|
error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
|
||||||
|
const a: string = 42;
|
||||||
|
^
|
||||||
|
at [WILDCARD]/test/markdown_windows.md$29-32.ts:1:7
|
|
@ -590,7 +590,7 @@ fn extract_files_from_source_comments(
|
||||||
scope_analysis: false,
|
scope_analysis: false,
|
||||||
})?;
|
})?;
|
||||||
let comments = parsed_source.comments().get_vec();
|
let comments = parsed_source.comments().get_vec();
|
||||||
let blocks_regex = Regex::new(r"```([^\n]*)\n([\S\s]*?)```")?;
|
let blocks_regex = Regex::new(r"```([^\r\n]*)\r?\n([\S\s]*?)```")?;
|
||||||
let lines_regex = Regex::new(r"(?:\* ?)(?:\# ?)?(.*)")?;
|
let lines_regex = Regex::new(r"(?:\* ?)(?:\# ?)?(.*)")?;
|
||||||
|
|
||||||
let files = comments
|
let files = comments
|
||||||
|
@ -630,7 +630,7 @@ fn extract_files_from_fenced_blocks(
|
||||||
col: 0,
|
col: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let blocks_regex = Regex::new(r"```([^\n]*)\n([\S\s]*?)```")?;
|
let blocks_regex = Regex::new(r"```([^\r\n]*)\r?\n([\S\s]*?)```")?;
|
||||||
let lines_regex = Regex::new(r"(?:\# ?)?(.*)")?;
|
let lines_regex = Regex::new(r"(?:\# ?)?(.*)")?;
|
||||||
|
|
||||||
extract_files_from_regex_blocks(
|
extract_files_from_regex_blocks(
|
||||||
|
|
Loading…
Reference in a new issue