various fixes

- removed experimental test lib
- fixed watch not outputting errors
- updated examples
- added TODOs for when standard is made public
This commit is contained in:
JOLIMAITRE Matthieu 2022-09-25 16:40:18 +02:00
parent 32acd5e888
commit e7433e42db
9 changed files with 16 additions and 18 deletions

View file

@ -1,9 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
void assert_eq_int(int left, int right) {
if (left != right) {
printf("assertion failed\n'%i' != '%i'\n", left, right);
exit(1);
}
}

View file

@ -1,8 +1,9 @@
#include <stdio.h>
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;

View file

@ -2,7 +2,8 @@
int main() {
int a;
printf("hello, world!! %d\n", a);
printf("hello, world!\n");
printf("a: %d\n", a);
}

View file

@ -1,10 +1,10 @@
#include <assert.h>
#include <stdio.h>
#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);
}

View file

@ -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;

View file

@ -27,6 +27,7 @@ impl Rule {
}
}
/// TODO: fill with appropriate rules
pub fn tests() -> Vec<Rule> {
vec![
// rules

View file

@ -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<String>, flags: Vec<String>) -> 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()

View file

@ -166,6 +166,7 @@ impl CmdTask {
Command::new("sh")
.arg("-c")
.arg(self.command)
.stderr(Stdio::inherit())
.stdout(Stdio::inherit())
.output()
.map(|_| ())

View file

@ -6,7 +6,7 @@ use crate::{
};
pub fn main(_capture: bool, files: Vec<String>, args: Vec<String>, _test: Option<Vec<String>>) {
log_process("running tests");
log_process("testing");
for path in files {
let content = fs::read_to_string(&path).unwrap();
let tests = find_tests(content);