forked from alex-eg/sex
leave none of an output a failure stopped writing
A failed -C -o left the file truncated, which make would take for done.
This commit is contained in:
8
sexc.scm
8
sexc.scm
@@ -164,8 +164,12 @@
|
||||
(define (write-to-file-or-stdout output what)
|
||||
(if (stdout-output? output)
|
||||
(what)
|
||||
(with-output-to-file output
|
||||
(fn (what)))))
|
||||
;; a failure part way through leaves none of the file, which make
|
||||
;; would take for done
|
||||
(handle-exceptions exn
|
||||
(begin (delete-file* output) (abort exn))
|
||||
(with-output-to-file output
|
||||
(fn (what))))))
|
||||
|
||||
(define (emit-c-or-sex sex-forms output args)
|
||||
(write-to-file-or-stdout output
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
;;; Each needs a process to show itself, so none 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 -- it has to
|
||||
;;; clean up its temporary .c when its own emission throws, and it has to
|
||||
;;; clean up its temporary .c, and any output it began, when its own
|
||||
;;; emission throws, and it has to
|
||||
;;; refuse `-o -' for an executable, which cc would write to a file named
|
||||
;;; `-'.
|
||||
;;;
|
||||
@@ -61,6 +62,12 @@
|
||||
(sexc-succeeds? "nested-pointer.sex" "-o" out)
|
||||
(glob (make-pathname scratch "*.c"))))
|
||||
|
||||
;; and none of a file it was writing out, which make would take for done
|
||||
(test "a failed emission leaves no part of its output" #f
|
||||
(begin
|
||||
(sexc-succeeds? "nested-pointer.sex" "-C" "-o" (make-pathname scratch "out.c"))
|
||||
(file-exists? (make-pathname scratch "out.c"))))
|
||||
|
||||
(test "a failed cc fails sexc" #f
|
||||
(sexc-succeeds? "hello.sex" "-o" out "--" "-no-such-cc-flag"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user