diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a23528a4..3fd44969 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,17 +9,17 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] name: build runs-on: ${{ matrix.os }} steps: - name: check out code uses: actions/checkout@v2 - - name: setup Go 1.17 + - name: setup Go 1.18 id: go uses: actions/setup-go@v2 with: - go-version: ^1.17 + go-version: ^1.18 - name: build run: make build - name: run Unit tests. diff --git a/air_example.toml b/air_example.toml index 8fbe7b05..fcdd06d6 100644 --- a/air_example.toml +++ b/air_example.toml @@ -12,6 +12,16 @@ cmd = "go build -o ./tmp/main ." bin = "tmp/main" # Customize binary, can setup environment variables when run your app. full_bin = "APP_ENV=dev APP_USER=air ./tmp/main" +# Add additional arguments when running binary (bin/full_bin). Will run './tmp/main hello world'. +args_bin = ["hello", "world"] +# Bin for different os, when you define this field, it will be used instead of bin. +#[bin_os] +# linux= "tmp/main" +# darwin= "tmp/main" +# windows= "tmp/main" + + + # Watch these filename extensions. include_ext = ["go", "tpl", "tmpl", "html"] # Ignore these filename extensions or directories. @@ -36,8 +46,6 @@ stop_on_error = true send_interrupt = false # Delay after sending Interrupt signal kill_delay = 500 # ms -# Add additional arguments when running binary (bin/full_bin). Will run './tmp/main hello world'. -args_bin = ["hello", "world"] [log] # Show log time diff --git a/runner/engine_test.go b/runner/engine_test.go index b521e6ba..8f65a83f 100644 --- a/runner/engine_test.go +++ b/runner/engine_test.go @@ -115,6 +115,19 @@ func GetPort() (int, func()) { } } +func removePath(tmpDir string) { + removed := false + for !removed { + os.RemoveAll(tmpDir) + // check if the dir is removed + _, err := os.Stat(tmpDir) + if err != nil { + removed = true + } + } + +} + func TestRebuild(t *testing.T) { // generate a random port port, f := GetPort() @@ -122,6 +135,7 @@ func TestRebuild(t *testing.T) { t.Logf("port: %d", port) tmpDir := initTestEnv(t, port) + defer removePath(tmpDir) // change dir to tmpDir err := os.Chdir(tmpDir) if err != nil { @@ -210,6 +224,7 @@ func TestCtrlCWhenHaveKillDelay(t *testing.T) { t.Logf("port: %d", port) tmpDir := initTestEnv(t, port) + defer removePath(tmpDir) // change dir to tmpDir err := os.Chdir(tmpDir) if err != nil { @@ -254,6 +269,7 @@ func TestCtrlCWhenREngineIsRunning(t *testing.T) { t.Logf("port: %d", port) tmpDir := initTestEnv(t, port) + defer removePath(tmpDir) // change dir to tmpDir err := os.Chdir(tmpDir) if err != nil { @@ -313,6 +329,7 @@ func TestRun(t *testing.T) { t.Logf("port: %d", port) tmpDir := initTestEnv(t, port) + defer removePath(tmpDir) // change dir to tmpDir err := os.Chdir(tmpDir) if err != nil { @@ -410,6 +427,7 @@ func TestRebuildWhenRunCmdUsingDLV(t *testing.T) { f() t.Logf("port: %d", port) tmpDir := initTestEnv(t, port) + defer removePath(tmpDir) // change dir to tmpDir err := os.Chdir(tmpDir) if err != nil { @@ -469,6 +487,7 @@ func TestWriteDefaultConfig(t *testing.T) { t.Logf("port: %d", port) tmpDir := initTestEnv(t, port) + defer removePath(tmpDir) // change dir to tmpDir if err := os.Chdir(tmpDir); err != nil { t.Fatal(err) diff --git a/runner/util_test.go b/runner/util_test.go index bb7e8c3b..b02d10b5 100644 --- a/runner/util_test.go +++ b/runner/util_test.go @@ -146,6 +146,11 @@ func TestAdaptToVariousPlatforms(t *testing.T) { } func Test_killCmd_no_process(t *testing.T) { + // skip windows + if runtime.GOOS == "windows" { + t.Skip("windows") + return + } e := Engine{ config: &config{ Build: cfgBuild{