(source: &str)
| 17 | use terminal_size::{terminal_size, Width as TerminalWidth}; |
| 18 | |
| 19 | fn parse_python_source(source: &str) -> Result<Value> { |
| 20 | let mut process = spawn_python_script_command( |
| 21 | "compat/ast_python.py", |
| 22 | vec!["--stdin"], |
| 23 | default_python_path()?, |
| 24 | )?; |
| 25 | |
| 26 | // Get process stdin and write the input string. |
| 27 | if let Some(mut stdin) = process.stdin.take() { |
| 28 | stdin.write_all(source.as_bytes()).into_diagnostic()?; |
| 29 | } else { |
| 30 | bail!("Failed to open stdin when running `compat/ast_python.py`"); |
| 31 | } |
| 32 | // Get process stdout and parse result. |
| 33 | let output = process.wait_with_output().into_diagnostic()?; |
| 34 | let mut ast = |
| 35 | serde_json::from_str(String::from_utf8_lossy(&output.stdout).as_ref()).into_diagnostic()?; |
| 36 | remove_unimplemented_attributes(&mut ast); |
| 37 | Ok(ast) |
| 38 | } |
| 39 | pub fn python_parser_test_ast(inputs: &[&str]) { |
| 40 | for test_input in inputs.iter() { |
| 41 | let enderpy_ast = parse_enderpy_source(test_input).unwrap(); |
no test coverage detected