test: add a mock test for the REPL server

This commit is contained in:
Shunsuke Shibayama 2023-04-27 00:25:53 +09:00
parent 03a30a450a
commit 5536858363
3 changed files with 52 additions and 4 deletions

View file

@ -738,15 +738,14 @@ pub fn _eval_pyc<S: Into<String>>(file: S, py_command: Option<&str>) -> String {
String::from_utf8_lossy(&out.stdout).to_string()
}
pub fn _exec_py(code: &str) -> Option<i32> {
pub fn exec_py(file: &str) -> Option<i32> {
let mut child = if cfg!(windows) {
Command::new(which_python())
.arg("-c")
.arg(code)
.arg(file)
.spawn()
.expect("cannot execute python")
} else {
let exec_command = format!("{} -c \"{}\"", which_python(), code);
let exec_command = format!("{} {file}", which_python());
Command::new("sh")
.arg("-c")
.arg(exec_command)