diff options
| author | liv <mokou@fastmail.com> | 2023-09-28 11:01:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-28 11:01:33 +0200 |
| commit | 579735b1c36d24ff108caf339c43fb39e543dedc (patch) | |
| tree | 2d230e7ed80205f51b70ac0def0f586e2aba6a11 | |
| parent | da3d55ba03d310a937a2795116a669e274859655 (diff) | |
| parent | 511e3343650a880435f8fb3e96eecbc674d6ebfa (diff) | |
Merge pull request #1697 from docwilco/docwilco/stop-littering-pdb-files-on-windows
fix(cli): stop littering .pdb files on windows
| -rw-r--r-- | src/exercise.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/exercise.rs b/src/exercise.rs index 2c740fb..c7b5672 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -9,6 +9,7 @@ use std::process::{self, Command}; const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"]; const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"]; +const RUSTC_NO_DEBUG_ARGS: &[&str] = &["-C", "strip=debuginfo"]; const I_AM_DONE_REGEX: &str = r"(?m)^\s*///?\s*I\s+AM\s+NOT\s+DONE"; const CONTEXT: usize = 2; const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/clippy/Cargo.toml"; @@ -113,11 +114,13 @@ impl Exercise { .args([self.path.to_str().unwrap(), "-o", &temp_file()]) .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) + .args(RUSTC_NO_DEBUG_ARGS) .output(), Mode::Test => Command::new("rustc") .args(["--test", self.path.to_str().unwrap(), "-o", &temp_file()]) .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) + .args(RUSTC_NO_DEBUG_ARGS) .output(), Mode::Clippy => { let cargo_toml = format!( @@ -144,6 +147,7 @@ path = "{}.rs""#, .args([self.path.to_str().unwrap(), "-o", &temp_file()]) .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) + .args(RUSTC_NO_DEBUG_ARGS) .output() .expect("Failed to compile!"); // Due to an issue with Clippy, a cargo clean is required to catch all lints. @@ -290,6 +294,24 @@ mod test { } #[test] + #[cfg(target_os = "windows")] + fn test_no_pdb_file() { + [Mode::Compile, Mode::Test] // Clippy doesn't like to test + .iter() + .for_each(|mode| { + let exercise = Exercise { + name: String::from("example"), + // We want a file that does actually compile + path: PathBuf::from("tests/fixture/state/pending_exercise.rs"), + mode: *mode, + hint: String::from(""), + }; + let _ = exercise.compile().unwrap(); + assert!(!Path::new(&format!("{}.pdb", temp_file())).exists()); + }); + } + + #[test] fn test_pending_state() { let exercise = Exercise { name: "pending_exercise".into(), |
