check whether the c program is syntactically and semantically correct.
(&self, program_path: &Path)
| 20 | impl Executor { |
| 21 | /// check whether the c program is syntactically and semantically correct. |
| 22 | fn is_program_syntax_correct(&self, program_path: &Path) -> Result<Option<ProgramError>> { |
| 23 | let time_logger = TimeUsage::new(get_file_dirname(program_path)); |
| 24 | let output: std::process::Output = Command::new("clang++") |
| 25 | .stdout(Stdio::null()) |
| 26 | .arg("-fsyntax-only") |
| 27 | .arg(&self.header_cmd) |
| 28 | .arg(program_path.as_os_str()) |
| 29 | .output() |
| 30 | .expect("failed to execute the syntax check process"); |
| 31 | time_logger.log("syntax")?; |
| 32 | let success = output.status.success(); |
| 33 | if success { |
| 34 | return Ok(None); |
| 35 | } |
| 36 | let err_msg = String::from_utf8_lossy(&output.stderr).to_string(); |
| 37 | Ok(Some(ProgramError::Syntax(err_msg))) |
| 38 | } |
| 39 | |
| 40 | /// check whether the program is correct in compilation and linkage. |
| 41 | fn is_program_link_correct(&self, program_path: &Path) -> Result<Option<ProgramError>> { |
no test coverage detected