html_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2018 Marc-Antoine Ruel. All rights reserved.
  2. // Use of this source code is governed under the Apache License, Version 2.0
  3. // that can be found in the LICENSE file.
  4. package internal
  5. import (
  6. "io/ioutil"
  7. "os"
  8. "testing"
  9. "notabug.org/themusicgod1/panicparse/stack"
  10. )
  11. func TestWriteToHTML(t *testing.T) {
  12. f, err := ioutil.TempFile("", "panicparse")
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. n := f.Name()
  17. f.Close()
  18. defer func() {
  19. if err := os.Remove(n); err != nil {
  20. t.Fatal(err)
  21. }
  22. }()
  23. buckets := []*stack.Bucket{
  24. {
  25. Signature: stack.Signature{
  26. State: "chan receive",
  27. Stack: stack.Stack{
  28. Calls: []stack.Call{
  29. {
  30. SrcPath: "/gopath/src/notabug.org/themusicgod1/panicparse/stack/stack.go",
  31. Line: 72,
  32. Func: stack.Func{Raw: "main.func·001"},
  33. Args: stack.Args{Values: []stack.Arg{{Value: 0x11000000, Name: ""}, {Value: 2}}},
  34. },
  35. },
  36. },
  37. },
  38. IDs: []int{1, 2},
  39. First: true,
  40. },
  41. {
  42. IDs: []int{3},
  43. },
  44. }
  45. if err := writeToHTML(n, buckets, true); err != nil {
  46. t.Fatal(err)
  47. }
  48. }