Skip to content

Commit 918ab8f

Browse files
croakywarp-agent
andauthored
test: build binary automatically via TestMain
Removes the need to run 'go build' before 'go test' by building the binary in TestMain and cleaning it up after tests complete. This makes the test suite self-contained and simplifies both the README instructions and the GitHub Actions workflow. Also ensures Procfile.dev is cleaned up after integration tests and added to .gitignore as a fallback. #1 Co-authored-by: Warp <agent@warp.dev>
1 parent 3d0d2bb commit 918ab8f

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,5 @@ jobs:
1717
with:
1818
go-version: "1.25"
1919

20-
- name: build
21-
run: go build -v -o procman .
22-
2320
- name: test
2421
run: go test -v ./...

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
procman
2+
Procfile.dev

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ for a PTY interface.
6969
## Developing
7070

7171
```bash
72-
go build ./... # build
7372
go test ./... # run tests
7473
go vet ./... # static checks
7574
goimports -local "$(go list -m)" -w . # format imports

procman_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ import (
99
"time"
1010
)
1111

12+
func TestMain(m *testing.M) {
13+
cmd := exec.Command("go", "build", "-o", "procman", ".")
14+
if err := cmd.Run(); err != nil {
15+
fmt.Fprintf(os.Stderr, "failed to build: %v\n", err)
16+
os.Exit(1)
17+
}
18+
code := m.Run()
19+
os.Remove("procman")
20+
os.Remove("Procfile.dev")
21+
os.Exit(code)
22+
}
23+
1224
func TestSetupProcesses(t *testing.T) {
1325
tests := []struct {
1426
name string
@@ -134,7 +146,6 @@ func TestWriteErr(t *testing.T) {
134146
}
135147

136148
// TestProcmanIntegration tests the full procman workflow.
137-
// Requires `go build -o procman .` to be run first.
138149
func TestProcmanIntegration(t *testing.T) {
139150
content := "echo: echo 'hello'\nsleep: sleep 10"
140151
if err := os.WriteFile("Procfile.dev", []byte(content), 0644); err != nil {

0 commit comments

Comments
 (0)