diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 829e84e0..70cc0059 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,5 +17,6 @@ jobs: - name: Set up environment run: | cp panel-example.conf .env + go run . artisan key:generate - name: Run tests run: go test ./... diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03c85ae9..4350b054 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,6 +44,7 @@ unit_test: - apt-get update - apt-get install -y curl jq - cp panel-example.conf .env + - go run . artisan key:generate - go test -v -coverprofile=coverage.txt -covermode=atomic ./... build: diff --git a/pkg/tools/system.go b/pkg/tools/system.go index 10564ad1..80d47e74 100644 --- a/pkg/tools/system.go +++ b/pkg/tools/system.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/goravel/framework/facades" + "github.com/goravel/framework/support" ) // Write 写入文件 @@ -52,7 +53,11 @@ func Exec(shell string) string { output, err := cmd.CombinedOutput() if err != nil { - facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error()) + if support.Env == support.EnvTest { + panic(err) + } else { + facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error()) + } return "" } @@ -65,13 +70,21 @@ func ExecAsync(shell string) { err := cmd.Start() if err != nil { - facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error()) + if support.Env == support.EnvTest { + panic(err) + } else { + facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error()) + } } go func() { err := cmd.Wait() if err != nil { - facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error()) + if support.Env == support.EnvTest { + panic(err) + } else { + facades.Log().Errorf("[面板][Helpers] 执行命令 %s 失败: %s", shell, err.Error()) + } } }() }