MCPcopy
hub / github.com/air-verse/air / TestRunPostCmd

Function TestRunPostCmd

runner/engine_test.go:179–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

177}
178
179func TestRunPostCmd(t *testing.T) {
180 // generate a random port
181 port, f := GetPort()
182 f()
183 t.Logf("port: %d", port)
184 tmpDir := initTestEnv(t, port)
185 // change dir to tmpDir
186 chdir(t, tmpDir)
187
188 engine, err := NewEngine("", nil, true)
189 if err != nil {
190 t.Fatalf("Should not be fail: %s.", err)
191 }
192 if runtime.GOOS == "windows" {
193 engine.config.Build.PostCmd = []string{`cmd.exe /c "echo hello air > post_cmd.txt"`}
194 } else {
195 engine.config.Build.PostCmd = []string{"echo 'hello air' > post_cmd.txt"}
196 }
197 err = engine.runPostCmd()
198 if err != nil {
199 t.Fatalf("Should not be fail: %s.", err)
200 }
201
202 if _, err := os.Stat("./post_cmd.txt"); err != nil {
203 if os.IsNotExist(err) {
204 t.Fatalf("Should not be fail: %s.", err)
205 }
206 }
207}
208
209func TestRunBin(t *testing.T) {
210 engine, err := NewEngine("", nil, true)

Callers

nothing calls this directly

Calls 5

runPostCmdMethod · 0.95
GetPortFunction · 0.85
initTestEnvFunction · 0.85
chdirFunction · 0.85
NewEngineFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…