summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorliv <liv@fastmail.com>2019-02-15 12:06:05 +0100
committerliv <liv@fastmail.com>2019-02-15 12:06:05 +0100
commit02ceb0ba8c0f82cefaaa531aec06c12dc0400525 (patch)
treea1150109d27905fc3f397fbf348d192fab7cfb62 /src
parent17fa037a164134f7b8da097aec8d795f8549b236 (diff)
fix test command execution
seems like i forgot that you actually need to run executables created with `rustc --test`! this also reworks the "test1" exercise a bit closes #108
Diffstat (limited to 'src')
-rw-r--r--src/verify.rs31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/verify.rs b/src/verify.rs
index eb609ab..f0c749a 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -14,7 +14,7 @@ pub fn verify() -> Result<(), ()> {
compile_only("exercises/functions/functions3.rs")?;
compile_only("exercises/functions/functions4.rs")?;
compile_only("exercises/functions/functions5.rs")?;
- compile_only("exercises/test1.rs")?;
+ test("exercises/test1.rs")?;
compile_only("exercises/primitive_types/primitive_types1.rs")?;
compile_only("exercises/primitive_types/primitive_types2.rs")?;
compile_only("exercises/primitive_types/primitive_types3.rs")?;
@@ -87,19 +87,36 @@ pub fn test(filename: &str) -> Result<(), ()> {
.args(&["--test", filename, "-o", "temp", "--color", "always"])
.output()
.expect("fail");
- bar.finish_and_clear();
if testcmd.status.success() {
- let formatstr = format!("{} Successfully tested {}!", Emoji("✅", "✓"), filename);
- println!("{}", style(formatstr).green());
- clean();
- Ok(())
+ bar.set_message(format!("Running {}...", filename).as_str());
+ let runcmd = Command::new("./temp").output().expect("fail");
+ bar.finish_and_clear();
+
+ if runcmd.status.success() {
+ let formatstr = format!("{} Successfully tested {}!", Emoji("✅", "✓"), filename);
+ println!("{}", style(formatstr).green());
+ clean();
+ Ok(())
+ } else {
+ let formatstr = format!(
+ "{} Testing of {} failed! Please try again. Here's the output:",
+ Emoji("⚠️ ", "!"),
+ filename
+ );
+ println!("{}", style(formatstr).red());
+ println!("{}", String::from_utf8_lossy(&runcmd.stdout));
+ clean();
+ Err(())
+ }
} else {
+ bar.finish_and_clear();
let formatstr = format!(
- "{} Testing of {} failed! Please try again.",
+ "{} Compiling of {} failed! Please try again. Here's the output:",
Emoji("⚠️ ", "!"),
filename
);
println!("{}", style(formatstr).red());
+ println!("{}", String::from_utf8_lossy(&testcmd.stderr));
clean();
Err(())
}