Skip to content

Commit 93adcee

Browse files
committed
try to do report generation with tempdir, still room for improvement though
1 parent 04ca4d5 commit 93adcee

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/ice.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clap::Parser;
44
use colored::Colorize;
55
use once_cell::sync::Lazy;
66
use serde::{Deserialize, Serialize};
7+
use tempdir::TempDir;
78

89
use crate::{library::Args, run_commands::prlimit_run_command};
910

@@ -97,7 +98,7 @@ pub(crate) type ICEDisplay = String;
9798

9899
impl ICE {
99100
// print a ICE to stdout or something
100-
pub(crate) fn to_printable(&self) -> ICEDisplay {
101+
pub(crate) fn to_printable(&self, global_tempdir: &PathBuf) -> ICEDisplay {
101102
let kind = match self.kind {
102103
ICEKind::Ice(Interestingness::Interesting) => "ICE".red(),
103104
ICEKind::Ice(Interestingness::Boring) => "ice".normal(),
@@ -115,7 +116,7 @@ impl ICE {
115116

116117
// HACK
117118
// also log the ICE to disk here since its probably most convenient at this place in time/code
118-
let report: Report = self.into();
119+
let report: Report = self.clone().into_report(global_tempdir);
119120
report.to_disk();
120121

121122
format!(
@@ -131,7 +132,7 @@ impl ICE {
131132
/*
132133
fn _run_treereduce(ice: &ICE) {
133134
let file = ice.file;
134-
let original_code = std::fs::read_to_string(&original_path).unwrap_or("<error>".into());
135+
let original_code = std::fs::read_to_strinaggregateg(&original_path).unwrap_or("<error>".into());
135136
let flags = self.args.clone().join(" ");
136137
let executable_bin = &self.executable.path();
137138
let prl_output = prlimit_run_command(&mut cmd).expect("prlimit process failed");
@@ -143,9 +144,13 @@ pub(crate) struct Report {
143144
data: String,
144145
}
145146

146-
impl From<&ICE> for Report {
147-
fn from(ice: &ICE) -> Self {
147+
impl ICE {
148+
fn into_report(self, global_tempdir_path: &PathBuf) -> Report {
149+
let ice = &self;
148150
//unreachable!("DO USE TMPDIR HERE!");
151+
let tempdir =
152+
TempDir::new_in(global_tempdir_path, "rustc_testrunner_tmpdir_reporting").unwrap();
153+
let tempdir_path = tempdir.path().display();
149154

150155
let original_path = ice.file.clone();
151156
let original_path_display = original_path.display();
@@ -157,6 +162,7 @@ impl From<&ICE> for Report {
157162
let mut cmd = std::process::Command::new(executable_bin);
158163
cmd.args(&ice.args);
159164
cmd.arg(&ice.file);
165+
cmd.current_dir(tempdir_path.to_string());
160166

161167
let prl_output = prlimit_run_command(&mut cmd).expect("prlimit process failed");
162168
// let output_stderr = String::from_utf8(prl_output.stdout).unwrap();

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ impl ICE {
11081108

11091109
// we know this is an ICE
11101110
PRINTER.log(PrintMessage::IceFound {
1111-
ice: ice.to_printable(),
1111+
ice: ice.to_printable(&global_tempdir_path),
11121112
});
11131113

11141114
return Some(ice);
@@ -1173,7 +1173,7 @@ impl ICE {
11731173
kind: icekind,
11741174
};
11751175
PRINTER.log(PrintMessage::IceFound {
1176-
ice: ice.to_printable(),
1176+
ice: ice.to_printable(&global_tempdir_path),
11771177
});
11781178

11791179
return Some(ice);
@@ -1346,7 +1346,7 @@ impl ICE {
13461346
kind: ICEKind::Hang(seconds_elapsed),
13471347
};
13481348
PRINTER.log(PrintMessage::IceFound {
1349-
ice: hang.to_printable(),
1349+
ice: hang.to_printable(&global_tempdir_path),
13501350
});
13511351

13521352
return Some(hang);
@@ -1433,7 +1433,7 @@ impl ICE {
14331433

14341434
if let Some(ice) = ret.clone() {
14351435
PRINTER.log(PrintMessage::IceFound {
1436-
ice: ice.to_printable(),
1436+
ice: ice.to_printable(&global_tempdir_path),
14371437
});
14381438
}
14391439
ret

0 commit comments

Comments
 (0)