racket-rash
racket-rash copied to clipboard
Capture failed pipeline
I am starting to have more and more scripts using rash but they are quite flaky in general. One thing I still haven't figured out the best way to achieve is grab a pipeline failure with the failing exit code. For example:
#lang rash
(define (my-false)
{true
echo "1"
false
echo "42"})
I get:
> (my-false)
1
; run-pipeline: unix pipeline-segment (#<path:/usr/bin/false>) terminated with code 1
;
; Context:
; /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:161:6 for-loop
; /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:257:0 unpack21
; /home/pmatos/Projects/igalia/jsc-utils/webkit.rkt:23:0 my-false
; /home/pmatos/installs/racket-7.3/collects/racket/repl.rkt:11:26
I see the error
call that terminates this in the rash source (https://github.com/willghatch/racket-rash/blob/master/shell-pipeline/private/mixed-pipeline.rkt) however this error call is less than ideal if I want to grab the error and the exit code. I could in principle catch the exception thrown by error
(exn:fail
) and parse the string, however this is less than ideal. Is there a good way to actually do this at the moment?
On Mon, Jun 24, 2019 at 06:16:49AM -0700, Paulo Matos wrote:
I am starting to have more and more scripts using rash but they are quite flaky in general.
Cool! Except for them being flaky...
One thing I still haven't figured out the best way to achieve is grab a pipeline failure with the failing exit code. For example:
#lang rash (define (my-false) {true echo "1" false echo "42"})
I get:
> (my-false) 1 ; run-pipeline: unix pipeline-segment (#<path:/usr/bin/false>) terminated with code 1 ; ; Context: ; /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:161:6 for-loop ; /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:257:0 unpack21 ; /home/pmatos/Projects/igalia/jsc-utils/webkit.rkt:23:0 my-false ; /home/pmatos/installs/racket-7.3/collects/racket/repl.rkt:11:26
I see the
error
call that terminates this in the rash source (https://github.com/willghatch/racket-rash/blob/master/shell-pipeline/private/mixed-pipeline.rkt) however this error call is less than ideal if I want to grab the error and the exit code. I could in principle catch the exception thrown byerror
(exn:fail
) and parse the string, however this is less than ideal. Is there a good way to actually do this at the moment?
Yeah, that's one of the many things that while implementing I decided
I would improve later. In this case I think it just needs a new
exception type, something like exn:unix-pipeline-member-failure
,
that stores the return value and stderr text. Or is there anything
else that you think would be better?
Feel free to send me a pull request. Or I'm also happy to just implement it.
What else is causing flakiness, or how is flakiness manifested in your scripts?
The flakiness comes exactly from this problem of not being able to properly catch failures. A new exception is exactly what I was thinking about. I will take a look at it later today and if I can put together something I will send a PR even if in draft mode. Glad you agree this can be improved. Thanks for rash - it's awesome - needs a marketing team!