Ejemplo n.º 1
0
// Tests that Shell.Cleanup panics under various conditions.
func TestCleanupPanics(t *testing.T) {
	func() { // errDidNotCallNewShell
		sh := gosh.Shell{}
		defer func() { neq(t, recover(), nil) }()
		sh.Cleanup()
	}()
}
Ejemplo n.º 2
0
func setsErr(t *testing.T, sh *gosh.Shell, f func()) {
	continueOnError := sh.ContinueOnError
	sh.ContinueOnError = true
	f()
	nok(t, sh.Err)
	sh.Err = nil
	sh.ContinueOnError = continueOnError
}
Ejemplo n.º 3
0
// Tests that Shell.HandleError panics under various conditions.
func TestHandleErrorPanics(t *testing.T) {
	func() { // errDidNotCallNewShell
		sh := gosh.Shell{}
		defer func() { neq(t, recover(), nil) }()
		sh.HandleError(fakeError)
	}()
	func() { // errShellErrIsNotNil
		sh := gosh.NewShell(t)
		sh.ContinueOnError = true
		defer sh.Cleanup()
		sh.Err = fakeError
		defer func() { neq(t, recover(), nil) }()
		sh.HandleError(fakeError)
	}()
	func() { // errAlreadyCalledCleanup
		sh := gosh.NewShell(t)
		sh.ContinueOnError = true
		sh.Cleanup()
		defer func() { neq(t, recover(), nil) }()
		sh.HandleError(fakeError)
	}()
}