Skip to content

Commit

Permalink
Update checkRunEnv to create nested tmp subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
sviripa committed Apr 30, 2024
1 parent 23bee95 commit a87381a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions runner/_testdata/nested/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp_dir = "./tmp/nested"
2 changes: 1 addition & 1 deletion runner/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (e *Engine) checkRunEnv() error {
p := e.config.tmpPath()
if _, err := os.Stat(p); os.IsNotExist(err) {
e.runnerLog("mkdir %s", p)
if err := os.Mkdir(p, 0o755); err != nil {
if err := os.MkdirAll(p, 0o755); err != nil {
e.runnerLog("failed to mkdir, error: %s", err.Error())
return err
}
Expand Down
17 changes: 17 additions & 0 deletions runner/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ func TestCheckRunEnv(t *testing.T) {
}
}

func TestCheckRunEnvNestedTmp(t *testing.T) {
_ = os.Unsetenv(airWd)
engine, err := NewEngine("_testdata/nested/.air.toml", true)
if err != nil {
t.Fatalf("Should not be fail: %s.", err)
}

err = engine.checkRunEnv()
if err != nil {
t.Fatal("Should not return an err")
}

if _, err := os.Stat("./tmp/nested"); os.IsNotExist(err) {
t.Fatal("Should create a nested tmp folder")
}
}

func TestWatching(t *testing.T) {
engine, err := NewEngine("", true)
if err != nil {
Expand Down

0 comments on commit a87381a

Please sign in to comment.