Пример #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()
	}()
}
Пример #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
}
Пример #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)
	}()
}