MCPcopy Create free account
hub / github.com/NV404/gova / TestRunBuildsAndReloads

Function TestRunBuildsAndReloads

internal/devserver/server_test.go:15–113  ·  view source on GitHub ↗

TestRunBuildsAndReloads is the end-to-end happy path: a tiny module that prints a version string, Run() watches it, we rewrite the version, and the child respawns with the new output.

(t *testing.T)

Source from the content-addressed store, hash-verified

13// prints a version string, Run() watches it, we rewrite the version, and the
14// child respawns with the new output.
15func TestRunBuildsAndReloads(t *testing.T) {
16 dir := t.TempDir()
17 writeModule(t, dir, `package main
18
19import (
20 "fmt"
21 "os/signal"
22 "syscall"
23)
24
25const version = "v1"
26
27func main() {
28 fmt.Println("started:" + version)
29 ch := make(chan struct{})
30 go func() {
31 c := make(chan any, 1)
32 _ = c
33 _ = signal.Ignore
34 _ = syscall.SIGTERM
35 }()
36 // Stay alive until killed.
37 sig := make(chan any)
38 go func() { <-sig }()
39 <-ch
40}
41`)
42 // Replace with a version that handles SIGTERM cleanly.
43 writeModule(t, dir, `package main
44
45import (
46 "fmt"
47 "os"
48 "os/signal"
49 "syscall"
50)
51
52const version = "v1"
53
54func main() {
55 fmt.Println("started:" + version)
56 ch := make(chan os.Signal, 1)
57 signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT)
58 <-ch
59}
60`)
61
62 ctx, cancel := context.WithCancel(context.Background())
63 defer cancel()
64
65 out := &safeBuf{}
66 errb := &safeBuf{}
67 done := make(chan error, 1)
68 go func() {
69 done <- Run(ctx, Options{
70 WorkDir: dir,
71 Package: ".",
72 Debounce: 80 * time.Millisecond,

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
writeModuleFunction · 0.85
waitForFunction · 0.85
BackgroundMethod · 0.80
RunFunction · 0.70

Tested by

no test coverage detected