MCPcopy Create free account
hub / github.com/conforma/cli / theExitStatusIs

Function theExitStatusIs

acceptance/cli/cli.go:430–448  ·  view source on GitHub ↗

theExitStatusIs checks that the exit status of ec command line is 0 (success), and logs profusely in case of it being != 0

(ctx context.Context, expected int)

Source from the content-addressed store, hash-verified

428// theExitStatusIs checks that the exit status of ec command line is 0
429// (success), and logs profusely in case of it being != 0
430func theExitStatusIs(ctx context.Context, expected int) error {
431 status, err := ecStatusFrom(ctx)
432 if err != nil {
433 return err
434 }
435
436 // if the error is an exec.ExitError we need to assert the status to
437 // be expected below and not fail here
438 var exitErr *exec.ExitError
439 if status.err != nil && !errors.As(status.err, &exitErr) {
440 return fmt.Errorf("failed to invoke the ec command: %#v", status.err)
441 }
442
443 if status.Cmd.ProcessState.ExitCode() != expected {
444 return fmt.Errorf("ec exited with %d", status.ProcessState.ExitCode())
445 }
446
447 return nil
448}
449
450// theStandardOutputShouldContain looks at the standard output (stdout) of the last invoked ec
451// command and compares the expected output with the resulted output. Special handling is done

Callers

nothing calls this directly

Calls 2

ecStatusFromFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected