-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathreload_test.go
65 lines (57 loc) · 1.71 KB
/
reload_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"os"
"path/filepath"
"testing"
"github.com/ktock/buildg/pkg/testutil"
)
func TestReload(t *testing.T) {
t.Parallel()
dt := fmt.Sprintf(`FROM %s
RUN echo -n a > /a
RUN echo -n b > /b
RUN echo -n c > /c`, testutil.Mirror("busybox:1.32.0"))
fmt.Println(dt)
tmpCtx, doneTmpCtx := testutil.NewTempContext(t, dt)
defer doneTmpCtx()
sh := testutil.NewDebugShell(t, tmpCtx)
defer sh.Close(t)
sh.Do("n")
sh.Do("n")
sh.Do(execNoTTY("cat /a")).OutEqual("a")
sh.Do(execNoTTY("cat /b")).OutEqual("b")
sh.Do(execNoTTY("cat /c")).OutContains("process execution failed")
sh.Do("reload")
sh.Do(execNoTTY("cat /a")).OutContains("process execution failed")
sh.Do(execNoTTY("cat /b")).OutContains("process execution failed")
sh.Do(execNoTTY("cat /c")).OutContains("process execution failed")
sh.Do("b 3") // breakpoint 0
sh.Do("c")
sh.Do(execNoTTY("cat /a")).OutEqual("a")
sh.Do(execNoTTY("cat /b")).OutEqual("b")
sh.Do(execNoTTY("cat /c")).OutContains("process execution failed")
sh.Do("reload")
sh.Do("breakpoints").OutContains("line: Dockerfile:3")
sh.Do("c")
sh.Do(execNoTTY("cat /a")).OutEqual("a")
sh.Do(execNoTTY("cat /b")).OutEqual("b")
sh.Do(execNoTTY("cat /c")).OutContains("process execution failed")
dt = fmt.Sprintf(`FROM %s
RUN echo -n a2 > /a2
RUN echo -n b2 > /b2
RUN echo -n c2 > /c2`, testutil.Mirror("busybox:1.32.0"))
if err := os.WriteFile(filepath.Join(tmpCtx, "Dockerfile"), []byte(dt), 0600); err != nil {
t.Fatal(err)
return
}
sh.Do("reload")
sh.Do("breakpoints").OutContains("line: Dockerfile:3")
sh.Do("c")
sh.Do(execNoTTY("cat /a2")).OutEqual("a2")
sh.Do(execNoTTY("cat /b2")).OutEqual("b2")
sh.Do("c")
if err := sh.Wait(); err != nil {
t.Fatal(err)
}
}