fail when the C compiler fails, and clean up when we do
compile-to-file returned process-wait's values and main dropped them, so cc errors were printed, but then main compiler exited 0. Also cleanup tmp C files when compilation failed.
This commit is contained in:
26
tests/exit-code/Makefile
Normal file
26
tests/exit-code/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
# The failure paths.
|
||||
#
|
||||
# Both need a process to show themselves, so neither fits the unit
|
||||
# suite: sexc has to fail when cc fails -- exiting 0 after a failed
|
||||
# compile makes every driver, sextest included, read it as success --
|
||||
# and it has to clean up its temporary .c when its own emission throws.
|
||||
#
|
||||
# Everything is built inside a scratch TMPDIR, so nothing is left here
|
||||
# to clean up.
|
||||
|
||||
SEXC ?= ../../sexc
|
||||
|
||||
check:
|
||||
@d=`mktemp -d`; \
|
||||
TMPDIR=$$d $(SEXC) nested-pointer.sex -o $$d/out >/dev/null 2>&1; \
|
||||
if [ -n "`find $$d -name '*.c'`" ]; then \
|
||||
echo "exit code FAILED: the temporary .c survived a failed emission"; \
|
||||
rm -rf $$d; exit 1; \
|
||||
fi; \
|
||||
if $(SEXC) hello.sex -o $$d/out -- -no-such-cc-flag >/dev/null 2>&1; then \
|
||||
echo "exit code FAILED: sexc reported success after cc failed"; \
|
||||
rm -rf $$d; exit 1; \
|
||||
fi; \
|
||||
rm -rf $$d; echo "exit code ok"
|
||||
|
||||
.PHONY: check
|
||||
4
tests/exit-code/hello.sex
Normal file
4
tests/exit-code/hello.sex
Normal file
@@ -0,0 +1,4 @@
|
||||
;;; Compiles cleanly, so the only way the build can fail is the bogus
|
||||
;;; flag handed to cc -- which is the point.
|
||||
(pub fn main () int
|
||||
(return 0))
|
||||
4
tests/exit-code/nested-pointer.sex
Normal file
4
tests/exit-code/nested-pointer.sex
Normal file
@@ -0,0 +1,4 @@
|
||||
;;; Rejected by the writer, so emit-c throws: there is a temporary .c
|
||||
;;; by then, and it must not survive.
|
||||
(fn f () void
|
||||
(var p (* (* char))))
|
||||
Reference in New Issue
Block a user