From e7433e42dba8afbb6b357e8aecd35350ee2985e1 Mon Sep 17 00:00:00 2001 From: JOLIMAITRE Matthieu Date: Sun, 25 Sep 2022 16:40:18 +0200 Subject: [PATCH] various fixes - removed experimental test lib - fixed watch not outputting errors - updated examples - added TODOs for when standard is made public --- clib/test.h | 9 --------- example/simple/main.c | 5 +++-- example/simple/main_check_failing.c | 3 ++- example/simple/test.c | 6 +++--- src/check.rs | 1 + src/check/testables.rs | 1 + src/run.rs | 6 ++++-- src/tasks.rs | 1 + src/test.rs | 2 +- 9 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 clib/test.h diff --git a/clib/test.h b/clib/test.h deleted file mode 100644 index b969cee..0000000 --- a/clib/test.h +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -void assert_eq_int(int left, int right) { - if (left != right) { - printf("assertion failed\n'%i' != '%i'\n", left, right); - exit(1); - } -} \ No newline at end of file diff --git a/example/simple/main.c b/example/simple/main.c index 2c0586d..051bbef 100644 --- a/example/simple/main.c +++ b/example/simple/main.c @@ -1,8 +1,9 @@ #include int main() { - int a; - printf("hello, world!! %d\n", a); + int a = 3; + printf("hello, world!\n"); + printf("a: %d\n", a); } int hello = 35; diff --git a/example/simple/main_check_failing.c b/example/simple/main_check_failing.c index 725d351..08f5b1b 100644 --- a/example/simple/main_check_failing.c +++ b/example/simple/main_check_failing.c @@ -2,7 +2,8 @@ int main() { int a; - printf("hello, world!! %d\n", a); + printf("hello, world!\n"); + printf("a: %d\n", a); } diff --git a/example/simple/test.c b/example/simple/test.c index 38f1f19..9c2a2ef 100644 --- a/example/simple/test.c +++ b/example/simple/test.c @@ -1,10 +1,10 @@ +#include #include -#include "../../clib/test.h" void test_it_works() { - assert_eq_int(2 + 2, 4); + assert(2 + 2 == 4); } void test_it_fails() { - assert_eq_int(2 + 2, 5); + assert(2 + 2 == 5); } diff --git a/src/check.rs b/src/check.rs index b65011c..00cd8c4 100644 --- a/src/check.rs +++ b/src/check.rs @@ -7,6 +7,7 @@ use crate::{ utils::{log_failure, log_process}, }; +/// TODO: fill with appropriate rules const FORMAT_CONFIG: &str = r#"{BasedOnStyle: llvm}"#; mod testables; diff --git a/src/check/testables.rs b/src/check/testables.rs index 322b26d..a696f19 100644 --- a/src/check/testables.rs +++ b/src/check/testables.rs @@ -27,6 +27,7 @@ impl Rule { } } +/// TODO: fill with appropriate rules pub fn tests() -> Vec { vec![ // rules diff --git a/src/run.rs b/src/run.rs index 1f9ae01..f6dc3c8 100644 --- a/src/run.rs +++ b/src/run.rs @@ -1,20 +1,22 @@ use crate::{ tasks::{CompileTask, RunTask}, - utils::{log_failure, log_process, log_success}, + utils::{log_failure, log_process}, }; pub fn main(files: Vec, flags: Vec) -> Option<()> { let source_file = files.into_iter().map(|f| f.into()).collect(); log_process("compiling"); let mut task = CompileTask::new(source_file); + for flag in flags { task = task.with_flag(flag); } + let compiled = task.run().map(Option::from).unwrap_or_else(|_| { log_failure("compilation failed"); None })?; - log_success("finished"); + log_process("running"); RunTask::new(compiled) .run() diff --git a/src/tasks.rs b/src/tasks.rs index 1e9f56b..86be5a4 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -166,6 +166,7 @@ impl CmdTask { Command::new("sh") .arg("-c") .arg(self.command) + .stderr(Stdio::inherit()) .stdout(Stdio::inherit()) .output() .map(|_| ()) diff --git a/src/test.rs b/src/test.rs index 930d58a..7b0e0ea 100644 --- a/src/test.rs +++ b/src/test.rs @@ -6,7 +6,7 @@ use crate::{ }; pub fn main(_capture: bool, files: Vec, args: Vec, _test: Option>) { - log_process("running tests"); + log_process("testing"); for path in files { let content = fs::read_to_string(&path).unwrap(); let tests = find_tests(content);