Skip to content

Commit

Permalink
Save coverage file in build_base path, not /tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
phansch committed Mar 25, 2019
1 parent 98d7c54 commit d808bd4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" => {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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)
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit d808bd4

Please sign in to comment.