Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: support cross-platform config file #291

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions air_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
19 changes: 19 additions & 0 deletions runner/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,27 @@ 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()
f()
t.Logf("port: %d", port)

tmpDir := initTestEnv(t, port)
defer removePath(tmpDir)
// change dir to tmpDir
err := os.Chdir(tmpDir)
if err != nil {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions runner/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down