Skip to content

Commit

Permalink
update DevPath test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
martianzhang committed Sep 25, 2019
1 parent 7d37fab commit f818c32
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions advisor/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

Expand All @@ -37,6 +39,10 @@ var rEnv *database.Connector

func TestMain(m *testing.M) {
// 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath
err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig")
Expand Down
6 changes: 6 additions & 0 deletions ast/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package ast
import (
"flag"
"fmt"
"path/filepath"
"runtime"
"testing"

"github.com/XiaoMi/soar/common"
Expand All @@ -31,6 +33,10 @@ var update = flag.Bool("update", false, "update .golden files")

func TestMain(m *testing.M) {
// 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath
err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig")
Expand Down
6 changes: 6 additions & 0 deletions cmd/soar/soar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/XiaoMi/soar/common"
Expand All @@ -29,6 +31,10 @@ var update = flag.Bool("update", false, "update .golden files")

func TestMain(m *testing.M) {
// 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath
err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig")
Expand Down
5 changes: 5 additions & 0 deletions common/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"flag"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/kr/pretty"
Expand All @@ -29,6 +30,10 @@ var update = flag.Bool("update", false, "update .golden files")

func TestMain(m *testing.M) {
// 初始化 init
if DevPath == "" {
_, file, _, _ := runtime.Caller(0)
DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
BaseDir = DevPath
err := ParseConfig("")
LogIfError(err, "init ParseConfig")
Expand Down
6 changes: 6 additions & 0 deletions database/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/XiaoMi/soar/common"
Expand All @@ -32,6 +34,10 @@ var update = flag.Bool("update", false, "update .golden files")

func TestMain(m *testing.M) {
// 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath
err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig")
Expand Down
6 changes: 6 additions & 0 deletions env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"flag"
"fmt"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/XiaoMi/soar/common"
Expand All @@ -35,6 +37,10 @@ var rEnv *database.Connector

func TestMain(m *testing.M) {
// 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath
err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig")
Expand Down

0 comments on commit f818c32

Please sign in to comment.