|
2 | 2 |
|
3 | 3 | use crate::common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT};
|
4 | 4 | use crate::common::{output_base_dir, output_base_name, output_testname_unique};
|
5 |
| -use crate::common::{Assembly, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui}; |
| 5 | +use crate::common::{Assembly, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui, RMC}; |
6 | 6 | use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc};
|
7 | 7 | use crate::common::{CompareMode, FailMode, PassMode};
|
8 | 8 | use crate::common::{Config, TestPaths};
|
@@ -351,6 +351,7 @@ impl<'test> TestCx<'test> {
|
351 | 351 | MirOpt => self.run_mir_opt_test(),
|
352 | 352 | Assembly => self.run_assembly_test(),
|
353 | 353 | JsDocTest => self.run_js_doc_test(),
|
| 354 | + RMC => self.run_rmc_test(), |
354 | 355 | }
|
355 | 356 | }
|
356 | 357 |
|
@@ -2021,7 +2022,7 @@ impl<'test> TestCx<'test> {
|
2021 | 2022 | rustc.arg(dir_opt);
|
2022 | 2023 | }
|
2023 | 2024 | RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake
|
2024 |
| - | CodegenUnits | JsDocTest | Assembly => { |
| 2025 | + | CodegenUnits | JsDocTest | Assembly | RMC => { |
2025 | 2026 | // do not use JSON output
|
2026 | 2027 | }
|
2027 | 2028 | }
|
@@ -2385,6 +2386,34 @@ impl<'test> TestCx<'test> {
|
2385 | 2386 | }
|
2386 | 2387 | }
|
2387 | 2388 |
|
| 2389 | + /// Adds rmc scripts directory to the `PATH` environment variable. |
| 2390 | + fn add_rmc_dir_to_path(&self, rmc: &mut Command) { |
| 2391 | + // If the PATH enviornment variable is already defined, |
| 2392 | + if let Some((key, val)) = env::vars().find(|(key, _)| key == "PATH") { |
| 2393 | + // Add the RMC scripts directory to the PATH. |
| 2394 | + rmc.env(key, format!("{}:{}", self.config.rmc_dir_path.to_str().unwrap(), val)); |
| 2395 | + } else { |
| 2396 | + // Otherwise, insert PATH as a new enviornment variable and set its value to the RMC scripts directory. |
| 2397 | + rmc.env(String::from("PATH"), String::from(self.config.rmc_dir_path.to_str().unwrap())); |
| 2398 | + } |
| 2399 | + } |
| 2400 | + |
| 2401 | + /// Runs RMC on the test file specified by `self.testpaths.file`. |
| 2402 | + /// An error message is printed to stdout if verfication fails. |
| 2403 | + fn run_rmc_test(&self) { |
| 2404 | + // Other modes call self.compile_test(...). However, we cannot call it here for two reasons: |
| 2405 | + // 1. It calls rustc instead of RMC |
| 2406 | + // 2. It may pass some options that do not make sense for RMC |
| 2407 | + // So we create our own command to execute RMC and pass it to self.compose_and_run_compiler(...) directly. |
| 2408 | + let mut rmc = Command::new("rmc"); |
| 2409 | + self.add_rmc_dir_to_path(&mut rmc); |
| 2410 | + rmc.arg(&self.testpaths.file); |
| 2411 | + let proc_res = self.compose_and_run_compiler(rmc, None); |
| 2412 | + if !proc_res.status.success() { |
| 2413 | + self.fatal_proc_rec("verification failed!", &proc_res); |
| 2414 | + } |
| 2415 | + } |
| 2416 | + |
2388 | 2417 | fn charset() -> &'static str {
|
2389 | 2418 | // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset
|
2390 | 2419 | if cfg!(target_os = "freebsd") { "ISO-8859-1" } else { "UTF-8" }
|
|
0 commit comments