Expose eval.HasFailure

This commit is contained in:
Cheer Xiao 2015-07-08 00:13:50 +02:00
parent f68b0eb1f9
commit 6dfa18bf4c
4 changed files with 5 additions and 5 deletions

View File

@ -43,7 +43,7 @@ type evalCtx struct {
ports []*port
}
func hasFailure(vs []Value) bool {
func HasFailure(vs []Value) bool {
for _, v := range vs {
v, ok := v.(exitus)
if !ok {
@ -95,7 +95,7 @@ func printExitus(e exitus) {
}
func PrintExituses(vs []Value) {
if !hasFailure(vs) {
if !HasFailure(vs) {
return
}
fmt.Print("Status: ")

View File

@ -159,7 +159,7 @@ func (c *closure) Exec(ec *evalCtx, args []Value) <-chan *stateUpdate {
}
// Ports are closed after executaion of closure is complete.
ec.closePorts()
if hasFailure(vs) {
if HasFailure(vs) {
// TODO(xiaq): Wrap the original failure
update <- newExitedStateUpdate(newFailure("chunk failure"))
} else {

View File

@ -33,7 +33,7 @@ func combineChunk(ops []valuesOp) valuesOp {
f := func(ec *evalCtx) []Value {
for _, op := range ops {
s := op.f(ec)
if hasFailure(s) {
if HasFailure(s) {
return s
}
}

View File

@ -118,7 +118,7 @@ func script(fname string) {
vs, err := ev.Source(fname)
printError(err)
eval.PrintExituses(vs)
if err != nil {
if err != nil || eval.HasFailure(vs) {
os.Exit(1)
}
}