mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(repl): recover from invalid input (#8759)
This commit is contained in:
parent
8f8749095c
commit
ce6b738ac0
2 changed files with 47 additions and 1 deletions
|
@ -1656,6 +1656,31 @@ fn repl_test_pty_unpaired_braces() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn repl_test_pty_bad_input() {
|
||||||
|
use std::io::Read;
|
||||||
|
use util::pty::fork::*;
|
||||||
|
let deno_exe = util::deno_exe_path();
|
||||||
|
let fork = Fork::from_ptmx().unwrap();
|
||||||
|
if let Ok(mut master) = fork.is_parent() {
|
||||||
|
master.write_all(b"'\\u{1f3b5}'[0]\n").unwrap();
|
||||||
|
master.write_all(b"close();\n").unwrap();
|
||||||
|
|
||||||
|
let mut output = String::new();
|
||||||
|
master.read_to_string(&mut output).unwrap();
|
||||||
|
|
||||||
|
assert!(output.contains("Unterminated string literal"));
|
||||||
|
|
||||||
|
fork.wait().unwrap();
|
||||||
|
} else {
|
||||||
|
std::env::set_var("NO_COLOR", "1");
|
||||||
|
let err = exec::Command::new(deno_exe).arg("repl").exec();
|
||||||
|
println!("err {}", err);
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn run_watch_with_importmap_and_relative_paths() {
|
fn run_watch_with_importmap_and_relative_paths() {
|
||||||
|
|
|
@ -859,7 +859,28 @@ impl v8::inspector::ChannelImpl for InspectorSession {
|
||||||
message: v8::UniquePtr<v8::inspector::StringBuffer>,
|
message: v8::UniquePtr<v8::inspector::StringBuffer>,
|
||||||
) {
|
) {
|
||||||
let raw_message = message.unwrap().string().to_string();
|
let raw_message = message.unwrap().string().to_string();
|
||||||
let message = serde_json::from_str(&raw_message).unwrap();
|
let message: serde_json::Value = match serde_json::from_str(&raw_message) {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(error) => match error.classify() {
|
||||||
|
serde_json::error::Category::Syntax => json!({
|
||||||
|
"id": call_id,
|
||||||
|
"result": {
|
||||||
|
"result": {
|
||||||
|
"type": "error",
|
||||||
|
"description": "Unterminated string literal",
|
||||||
|
"value": "Unterminated string literal",
|
||||||
|
},
|
||||||
|
"exceptionDetails": {
|
||||||
|
"exceptionId": 0,
|
||||||
|
"text": "Unterminated string literal",
|
||||||
|
"lineNumber": 0,
|
||||||
|
"columnNumber": 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
_ => panic!("Could not parse inspector message"),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
self
|
self
|
||||||
.response_tx_map
|
.response_tx_map
|
||||||
|
|
Loading…
Add table
Reference in a new issue