Save coverage file in build_base path, not /tmp

This commit is contained in:
Philipp Hansch 2019-03-25 22:48:35 +01:00
parent 98d7c5463b
commit d808bd4651
No known key found for this signature in database
GPG Key ID: B6FA06A6E0E2665B
4 changed files with 11 additions and 7 deletions

View File

@ -193,7 +193,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
"",
"rustfix-coverage",
"enable this to generate a Rustfix coverage file, which is saved in \
`/tmp/rustfix_missing_coverage.txt`",
`/<build_base>/rustfix_missing_coverage.txt`",
);
}
"bench" => {

View File

@ -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 `/<build_base>/rustfix_missing_coverage.txt`
pub rustfix_coverage: bool,
// Configuration for various run-make tests frobbing things like C compilers

View File

@ -237,7 +237,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
"",
"rustfix-coverage",
"enable this to generate a Rustfix coverage file, which is saved in \
`/tmp/rustfix_missing_coverage.txt`",
`./<build_base>/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)
}
}

View File

@ -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()) {