mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-06-13 20:52:21 +00:00
3c877c504b
This commit enables cpu, mem, block, and mutex profling of the FZF executable. To support flushing the profiles at program exit it adds util.AtExit to register "at exit" functions and mandates that util.Exit is used instead of os.Exit to stop the program. Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
25 lines
452 B
Go
25 lines
452 B
Go
package util
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestAtExit(t *testing.T) {
|
|
want := []int{3, 2, 1, 0}
|
|
var called []int
|
|
for i := 0; i < 4; i++ {
|
|
n := i
|
|
AtExit(func() { called = append(called, n) })
|
|
}
|
|
RunAtExitFuncs()
|
|
if !reflect.DeepEqual(called, want) {
|
|
t.Errorf("AtExit: want call order: %v got: %v", want, called)
|
|
}
|
|
|
|
RunAtExitFuncs()
|
|
if !reflect.DeepEqual(called, want) {
|
|
t.Error("AtExit: should only call exit funcs once")
|
|
}
|
|
}
|