-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/updateGoMod
- Loading branch information
Showing
22 changed files
with
935 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package actor | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
"time" | ||
) | ||
|
||
// Test_CleanTrace tests that the stack trace is cleaned up correctly and that the function | ||
// which triggers the panic is at the top of the stack trace. | ||
func Test_CleanTrace(t *testing.T) { | ||
e, err := NewEngine(nil) | ||
require.NoError(t, err) | ||
type triggerPanic struct { | ||
data int | ||
} | ||
stopCh := make(chan struct{}) | ||
pid := e.SpawnFunc(func(c *Context) { | ||
fmt.Printf("Got message type %T\n", c.Message()) | ||
switch c.Message().(type) { | ||
case Started: | ||
c.Engine().Subscribe(c.pid) | ||
case triggerPanic: | ||
panicWrapper() | ||
case ActorRestartedEvent: | ||
m := c.Message().(ActorRestartedEvent) | ||
// split the panic into lines: | ||
lines := bytes.Split(m.Stacktrace, []byte("\n")) | ||
// check that the second line is the panicWrapper function: | ||
if bytes.Contains(lines[1], []byte("panicWrapper")) { | ||
fmt.Println("stack trace contains panicWrapper at the right line") | ||
stopCh <- struct{}{} | ||
} | ||
} | ||
}, "foo", WithMaxRestarts(1)) | ||
e.Send(pid, triggerPanic{1}) | ||
select { | ||
case <-stopCh: | ||
fmt.Println("test passed") | ||
case <-time.After(time.Second): | ||
t.Error("test timed out. stack trace likely did not contain panicWrapper at the right line") | ||
} | ||
} | ||
|
||
func panicWrapper() { | ||
panic("foo") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.