Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli/test): decoding percent-encoding(non-ASCII) file path correctly #23200

Merged
merged 13 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cli/tools/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::graph_util::ModuleGraphBuilder;
use crate::npm::CliNpmResolver;
use crate::tsc;
use crate::tsc::Diagnostics;
use crate::util::path::to_percent_decoded_str;
use crate::version;

/// Options for performing a check of a module graph. Note that the decision to
Expand Down Expand Up @@ -154,7 +155,11 @@ impl TypeChecker {

for root in &graph.roots {
let root_str = root.as_str();
log::info!("{} {}", colors::green("Check"), root_str);
log::info!(
"{} {}",
colors::green("Check"),
to_percent_decoded_str(root_str)
);
}

let check_js = ts_config.get_check_js();
Expand Down
4 changes: 3 additions & 1 deletion cli/tools/test/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use phf::phf_map;
use std::borrow::Cow;
use std::ops::AddAssign;

use crate::util::path::to_percent_decoded_str;

use super::*;

pub fn to_relative_path_or_remote_url(cwd: &Url, path_or_url: &str) -> String {
Expand All @@ -19,7 +21,7 @@ pub fn to_relative_path_or_remote_url(cwd: &Url, path_or_url: &str) -> String {
if !r.starts_with("../") {
r = format!("./{r}");
}
return r;
return to_percent_decoded_str(&r);
}
}
path_or_url.to_string()
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/test_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ itest!(fail {
output: "test/fail.out",
});

itest!(fail_with_contain_unicode_filename {
args: "test test/fail_with_contain_unicode_filename🦕.ts",
exit_code: 1,
output: "test/fail_with_contain_unicode_filename🦕.out",
});

itest!(collect {
args: "test --ignore=test/collect/ignore test/collect",
exit_code: 0,
Expand Down
19 changes: 19 additions & 0 deletions tests/testdata/test/fail_with_contain_unicode_filename🦕.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Check [WILDCARD]/test/fail_with_contain_unicode_filename🦕.ts
running 1 test from ./test/fail_with_contain_unicode_filename🦕.ts
test 0 ... FAILED ([WILDCARD])

ERRORS

test 0 => ./test/fail_with_contain_unicode_filename🦕.ts:1:6
error: Error
throw new Error();
^
at [WILDCARD]/test/fail_with_contain_unicode_filename%F0%9F%A6%95.ts:2:9

FAILURES

test 0 => ./test/fail_with_contain_unicode_filename🦕.ts:1:6

FAILED | 0 passed | 1 failed ([WILDCARD])

error: Test failed
3 changes: 3 additions & 0 deletions tests/testdata/test/fail_with_contain_unicode_filename🦕.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Deno.test("test 0", () => {
throw new Error();
});
Loading