diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-02-18 21:51:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 04:51:06 +0000 |
commit | 7e6b94231290020b55f1d08fb03ea8132781abc5 (patch) | |
tree | 3767f12db7180b13175c5a7f33c731b192f891a5 /tests/integration/run_tests.rs | |
parent | 9a43a2b4959be288034ef0c43f638542de2028b8 (diff) |
feat(core): highlight unprintable chars in permission prompts (#22468)
If we strip out unprintable chars, we don't see the full filename being
requested by permission prompts. Instead, we highlight and escape them
to make them visible.
Diffstat (limited to 'tests/integration/run_tests.rs')
-rw-r--r-- | tests/integration/run_tests.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 02fb915b5..a4bfc6345 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -4725,19 +4725,19 @@ fn stdio_streams_are_locked_in_permission_prompt() { } #[test] -fn permission_prompt_strips_ansi_codes_and_control_chars() { +fn permission_prompt_escapes_ansi_codes_and_control_chars() { util::with_pty(&["repl"], |mut console| { console.write_line( r#"Deno.permissions.request({ name: "env", variable: "\rDo you like ice cream? y/n" });"# ); // will be uppercase on windows let env_name = if cfg!(windows) { - "DO YOU LIKE ICE CREAM? Y/N" + "\\rDO YOU LIKE ICE CREAM? Y/N" } else { - "Do you like ice cream? y/n" + "\\rDo you like ice cream? y/n" }; console.expect(format!( - "┌ ⚠️ Deno requests env access to \"{}\".", + "\u{250c} \u{26a0}\u{fe0f} Deno requests env access to \"{}\".", env_name )) }); @@ -4747,14 +4747,10 @@ fn permission_prompt_strips_ansi_codes_and_control_chars() { console.expect("undefined"); console.write_line_raw(r#"const unboldANSI = "\u001b[22m";"#); console.expect("undefined"); - console.write_line_raw(r#"const prompt = `┌ ⚠️ ${boldANSI}Deno requests run access to "echo"${unboldANSI}\n ├ Requested by \`Deno.Command().output()`"#); - console.expect("undefined"); - console.write_line_raw(r#"const moveANSIUp = "\u001b[1A";"#); - console.expect("undefined"); - console.write_line_raw(r#"const clearANSI = "\u001b[2K";"#); - console.expect("undefined"); - console.write_line_raw(r#"const moveANSIStart = "\u001b[1000D";"#); - console.expect("undefined"); + console.write_line_raw( + r#"new Deno.Command(`${boldANSI}cat${unboldANSI}`).spawn();"#, + ); + console.expect("\u{250c} \u{26a0}\u{fe0f} Deno requests run access to \"\\u{1b}[1mcat\\u{1b}[22m\"."); }); } |