From d808bd46515e4de5d21a62b2c1557ac9d2751846 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 25 Mar 2019 22:48:35 +0100 Subject: [PATCH] Save coverage file in build_base path, not /tmp --- src/bootstrap/flags.rs | 2 +- src/tools/compiletest/src/common.rs | 2 +- src/tools/compiletest/src/main.rs | 7 ++++--- src/tools/compiletest/src/runtest.rs | 7 +++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 23719378c84..a1f89d6c86f 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -193,7 +193,7 @@ To learn more about a subcommand, run `./x.py -h`" "", "rustfix-coverage", "enable this to generate a Rustfix coverage file, which is saved in \ - `/tmp/rustfix_missing_coverage.txt`", + `//rustfix_missing_coverage.txt`", ); } "bench" => { diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 7a15d753e2d..9d4effb4f58 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -247,7 +247,7 @@ pub struct Config { /// If true, this will generate a coverage file with UI test files that run `MachineApplicable` /// diagnostics but are missing `run-rustfix` annotations. The generated coverage file is - /// created in `/tmp/rustfix_missing_coverage.txt` + /// created in `//rustfix_missing_coverage.txt` pub rustfix_coverage: bool, // Configuration for various run-make tests frobbing things like C compilers diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 1045ea1bf0c..b9ddf04fad9 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -237,7 +237,7 @@ pub fn parse_config(args: Vec) -> Config { "", "rustfix-coverage", "enable this to generate a Rustfix coverage file, which is saved in \ - `/tmp/rustfix_missing_coverage.txt`", + `.//rustfix_missing_coverage.txt`", ) .optflag("h", "help", "show this message"); @@ -486,9 +486,10 @@ pub fn run_tests(config: &Config) { // we first make sure that the coverage file does not exist. // It will be created later on. if config.rustfix_coverage { - let coverage_file_path = Path::new("/tmp/rustfix_missing_coverage.txt"); + let mut coverage_file_path = config.build_base.clone(); + coverage_file_path.push("rustfix_missing_coverage.txt"); if coverage_file_path.exists() { - if let Err(e) = fs::remove_file(coverage_file_path) { + if let Err(e) = fs::remove_file(&coverage_file_path) { panic!("Could not delete {} due to {}", coverage_file_path.display(), e) } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 0ca656bb133..c18b6db9a01 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2829,11 +2829,14 @@ impl<'test> TestCx<'test> { if suggestions.len() > 0 && !self.props.run_rustfix && !self.props.rustfix_only_machine_applicable { - let coverage_file_path = Path::new("/tmp/rustfix_missing_coverage.txt"); + let mut coverage_file_path = self.config.build_base.clone(); + coverage_file_path.push("rustfix_missing_coverage.txt"); + debug!("coverage_file_path: {}", coverage_file_path.display()); + let mut file = OpenOptions::new() .create(true) .append(true) - .open(coverage_file_path) + .open(coverage_file_path.as_path()) .expect("could not create or open file"); if let Err(_) = writeln!(file, "{}", self.testpaths.file.display()) {