diff options
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | tests/051.sh | 10 | ||||
| -rw-r--r-- | tests/test_compile_error.sh | 9 | ||||
| -rw-r--r-- | tests/test_diff.sh | 1 | ||||
| -rw-r--r-- | tests/test_exit_code.sh | 1 | ||||
| -rw-r--r-- | tests/test_output.sh | 1 |
6 files changed, 21 insertions, 4 deletions
@@ -11,6 +11,7 @@ int atoi(const char*); void* calloc(size_t, size_t); void exit(int); int fclose(FILE*); +int fprintf(FILE*, const char*, ...); char* fgets(char*, int, FILE*); FILE* fopen(const char*, const char*); int getchar(void); @@ -29,7 +30,7 @@ char* strstr(const char*, const char*); #define NULL 0 void fatal_error(const char* msg) { - printf("%s\n", msg); + fprintf(stderr, "%s\n", msg); exit(1); } diff --git a/tests/051.sh b/tests/051.sh new file mode 100644 index 0000000..74a7327 --- /dev/null +++ b/tests/051.sh @@ -0,0 +1,10 @@ +set -e + +cat <<'EOF' > expected +undefined function: f +EOF +bash ../../test_compile_error.sh <<'EOF' +int main() { + f(); +} +EOF diff --git a/tests/test_compile_error.sh b/tests/test_compile_error.sh new file mode 100644 index 0000000..2e3c207 --- /dev/null +++ b/tests/test_compile_error.sh @@ -0,0 +1,9 @@ +cat > main.c + +"$ducc" main.c > /dev/null 2> output +if [[ $? -eq 0 ]]; then + "expected to fail" + exit 1 +fi + +diff -u expected output diff --git a/tests/test_diff.sh b/tests/test_diff.sh index 6520b42..14e5200 100644 --- a/tests/test_diff.sh +++ b/tests/test_diff.sh @@ -2,7 +2,6 @@ cat > main.c "$ducc" main.c > main.s if [[ $? -ne 0 ]]; then - cat main.s >&2 exit 1 fi gcc -Wl,-z,noexecstack -o a.out main.s diff --git a/tests/test_exit_code.sh b/tests/test_exit_code.sh index 44d1e06..7119b1d 100644 --- a/tests/test_exit_code.sh +++ b/tests/test_exit_code.sh @@ -2,7 +2,6 @@ cat > main.c "$ducc" main.c > main.s if [[ $? -ne 0 ]]; then - cat main.s >&2 exit 1 fi gcc -Wl,-z,noexecstack -o a.out main.s diff --git a/tests/test_output.sh b/tests/test_output.sh index 575e399..a286a4a 100644 --- a/tests/test_output.sh +++ b/tests/test_output.sh @@ -2,7 +2,6 @@ cat > main.c "$ducc" main.c > main.s if [[ $? -ne 0 ]]; then - cat main.s >&2 exit 1 fi gcc -Wl,-z,noexecstack -o a.out main.s |
