aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-01-30 02:18:57 -0500
committerMustafa Quraish <[email protected]>2022-01-30 18:04:13 -0500
commitfe1febfc4b68c0494790d915c6247d98ed2205e9 (patch)
tree3aa68d57f7a9df9963aadcda351fb41a1b08162e /tests
parentRename `cup` directory to `src` (diff)
downloadcup-fe1febfc4b68c0494790d915c6247d98ed2205e9.tar.xz
cup-fe1febfc4b68c0494790d915c6247d98ed2205e9.zip
Update build system to use Makefile
`make` to compile the compiler `make XXX.out` to assemble/link `XXX.nasm` into an executable `make test` to run all tests `make tests/XXX` to run `tests/XXX.sh` test file `./run.sh <cupcc args>` to build, compile, run and show exit code
Diffstat (limited to 'tests')
-rw-r--r--tests/common.sh25
1 files changed, 4 insertions, 21 deletions
diff --git a/tests/common.sh b/tests/common.sh
index f863826..575443c 100644
--- a/tests/common.sh
+++ b/tests/common.sh
@@ -1,28 +1,11 @@
#!/bin/bash
-function assemble() {
- case "$(uname -s)" in
- Darwin)
- set -e
- nasm -f macho64 -o output.nasm.o output.nasm
- ld -lSystem output.nasm.o
- set +e
- ;;
- Linux)
- set -e
- nasm -f elf64 -o output.nasm.o output.nasm
- ld output.nasm.o
- set +e
- ;;
- esac
-}
-
function assert_exit_status() {
- ./cupcc -c "$1"
- assemble
+ build/cupcc -c "$1" -o build/test.nasm
+ make build/test.out -s
set +e
- ./a.out
+ build/test.out
res=$?
set -e
if [ $res -ne $2 ]
@@ -45,7 +28,7 @@ function assert_exit_status_stdin() {
function assert_compile_failure_stdin() {
code=$(</dev/stdin)
set +e
- ./cupcc -c "$code" >/dev/null 2>&1
+ build/cupcc -c "$code" -o build/test.nasm >/dev/null 2>&1
res=$?
set -e
if [ $res -eq 0 ]