(project_dir: P, verbose: bool)
| 158 | } |
| 159 | |
| 160 | fn compile<P: AsRef<Path>>(project_dir: P, verbose: bool) -> Result<()> { |
| 161 | let mut command = Command::new("cargo"); |
| 162 | command.arg("build") |
| 163 | .arg("--release") |
| 164 | .current_dir(project_dir); |
| 165 | if verbose { |
| 166 | command.stdout(Stdio::inherit()).stderr(Stdio::inherit()); |
| 167 | } else { |
| 168 | command.stdout(Stdio::piped()).stderr(Stdio::piped()); |
| 169 | } |
| 170 | let mut child = command.spawn().chain_err(|| "Unable to start the compiler")?; |
| 171 | let rustc_result = child.wait().chain_err(|| "cargo crashed")?; |
| 172 | if !rustc_result.success() { |
| 173 | io::copy(&mut child.stdout.unwrap(), &mut io::stdout()) |
| 174 | .chain_err(|| "Unable to write compiler stdout")?; |
| 175 | io::copy(&mut child.stderr.unwrap(), &mut io::stderr()) |
| 176 | .chain_err(|| "Unable to write compiler stderr")?; |
| 177 | bail!("The script did not compile successfully") |
| 178 | } else { |
| 179 | Ok(()) |
| 180 | } |
| 181 | } |
no outgoing calls
no test coverage detected