| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package web_test |
| 6 |
|
| 7 |
import ( |
| 8 |
"encoding/json" |
| 9 |
"runtime" |
| 10 |
"testing" |
| 11 |
|
| 12 |
"golang.org/x/tools/gopls/internal/debug" |
| 13 |
"golang.org/x/tools/gopls/internal/protocol" |
| 14 |
"golang.org/x/tools/gopls/internal/protocol/command" |
| 15 |
. "golang.org/x/tools/gopls/internal/test/integration" |
| 16 |
) |
| 17 |
|
| 18 |
|
| 19 |
func TestFlightRecorder(t *testing.T) { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
if runtime.GOOS == "windows" { |
| 27 |
t.Skip("not reliable on windows") |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
t.Cleanup(debug.KillTraceViewers) |
| 33 |
|
| 34 |
const files = ` |
| 35 |
-- go.mod -- |
| 36 |
module example.com |
| 37 |
|
| 38 |
-- a/a.go -- |
| 39 |
package a |
| 40 |
|
| 41 |
const A = 1 |
| 42 |
` |
| 43 |
|
| 44 |
Run(t, files, func(t *testing.T, env *Env) { |
| 45 |
env.OpenFile("a/a.go") |
| 46 |
|
| 47 |
|
| 48 |
var result command.DebuggingResult |
| 49 |
env.ExecuteCommand(&protocol.ExecuteCommandParams{ |
| 50 |
Command: command.StartDebugging.String(), |
| 51 |
Arguments: []json.RawMessage{json.RawMessage("{}")}, |
| 52 |
}, &result) |
| 53 |
uri := result.URLs[0] |
| 54 |
t.Logf("StartDebugging: URLs[0] = %s", uri) |
| 55 |
|
| 56 |
|
| 57 |
doc1 := get(t, uri) |
| 58 |
checkMatch(t, true, doc1, "Gopls server information") |
| 59 |
checkMatch(t, true, doc1, `<a href="/flightrecorder">Flight recorder</a>`) |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
doc2 := get(t, uri+"/flightrecorder") |
| 67 |
checkMatch(t, true, doc2, `onTraceViewerImportFail`) |
| 68 |
}) |
| 69 |
} |