summaryrefslogtreecommitdiff
path: root/src/exercise.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/exercise.rs')
-rw-r--r--src/exercise.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/exercise.rs b/src/exercise.rs
index 2ec8d97..eb7b725 100644
--- a/src/exercise.rs
+++ b/src/exercise.rs
@@ -3,13 +3,11 @@ use crossterm::style::{style, StyledContent, Stylize};
use std::{
fmt::{self, Display, Formatter},
fs,
+ path::Path,
process::{Command, Output},
};
-use crate::{
- embedded::{WriteStrategy, EMBEDDED_FILES},
- info_file::Mode,
-};
+use crate::{info_file::Mode, DEVELOPING_OFFICIAL_RUSTLINGS};
pub struct TerminalFileLink<'a> {
path: &'a str,
@@ -50,9 +48,7 @@ impl Exercise {
cmd.arg(command);
// A hack to make `cargo run` work when developing Rustlings.
- // Use `dev/Cargo.toml` when in the directory of the repository.
- #[cfg(debug_assertions)]
- if std::path::Path::new("tests").exists() {
+ if DEVELOPING_OFFICIAL_RUSTLINGS && Path::new("tests").exists() {
cmd.arg("--manifest-path").arg("dev/Cargo.toml");
}
@@ -69,7 +65,17 @@ impl Exercise {
pub fn run(&self) -> Result<Output> {
match self.mode {
Mode::Run => self.cargo_cmd("run", &[]),
- Mode::Test => self.cargo_cmd("test", &["--", "--nocapture", "--format", "pretty"]),
+ Mode::Test => self.cargo_cmd(
+ "test",
+ &[
+ "--",
+ "--color",
+ "always",
+ "--nocapture",
+ "--format",
+ "pretty",
+ ],
+ ),
Mode::Clippy => self.cargo_cmd(
"clippy",
&["--", "-D", "warnings", "-D", "clippy::float_cmp"],
@@ -77,12 +83,6 @@ impl Exercise {
}
}
- pub fn reset(&self) -> Result<()> {
- EMBEDDED_FILES
- .write_exercise_to_disk(self.path, WriteStrategy::Overwrite)
- .with_context(|| format!("Failed to reset the exercise {self}"))
- }
-
pub fn terminal_link(&self) -> StyledContent<TerminalFileLink<'_>> {
style(TerminalFileLink { path: self.path })
.underlined()