提交 f818c326 编写于 作者: martianzhang's avatar martianzhang

update DevPath test cases

上级 7d37fab7
...@@ -20,6 +20,8 @@ import ( ...@@ -20,6 +20,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"path/filepath"
"runtime"
"strings" "strings"
"testing" "testing"
...@@ -37,6 +39,10 @@ var rEnv *database.Connector ...@@ -37,6 +39,10 @@ var rEnv *database.Connector
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// 初始化 init // 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath common.BaseDir = common.DevPath
err := common.ParseConfig("") err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig") common.LogIfError(err, "init ParseConfig")
......
...@@ -19,6 +19,8 @@ package ast ...@@ -19,6 +19,8 @@ package ast
import ( import (
"flag" "flag"
"fmt" "fmt"
"path/filepath"
"runtime"
"testing" "testing"
"github.com/XiaoMi/soar/common" "github.com/XiaoMi/soar/common"
...@@ -31,6 +33,10 @@ var update = flag.Bool("update", false, "update .golden files") ...@@ -31,6 +33,10 @@ var update = flag.Bool("update", false, "update .golden files")
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// 初始化 init // 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath common.BaseDir = common.DevPath
err := common.ParseConfig("") err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig") common.LogIfError(err, "init ParseConfig")
......
...@@ -20,6 +20,8 @@ import ( ...@@ -20,6 +20,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"path/filepath"
"runtime"
"testing" "testing"
"github.com/XiaoMi/soar/common" "github.com/XiaoMi/soar/common"
...@@ -29,6 +31,10 @@ var update = flag.Bool("update", false, "update .golden files") ...@@ -29,6 +31,10 @@ var update = flag.Bool("update", false, "update .golden files")
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// 初始化 init // 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath common.BaseDir = common.DevPath
err := common.ParseConfig("") err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig") common.LogIfError(err, "init ParseConfig")
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"flag" "flag"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"testing" "testing"
"github.com/kr/pretty" "github.com/kr/pretty"
...@@ -29,6 +30,10 @@ var update = flag.Bool("update", false, "update .golden files") ...@@ -29,6 +30,10 @@ var update = flag.Bool("update", false, "update .golden files")
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// 初始化 init // 初始化 init
if DevPath == "" {
_, file, _, _ := runtime.Caller(0)
DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
BaseDir = DevPath BaseDir = DevPath
err := ParseConfig("") err := ParseConfig("")
LogIfError(err, "init ParseConfig") LogIfError(err, "init ParseConfig")
......
...@@ -20,6 +20,8 @@ import ( ...@@ -20,6 +20,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"path/filepath"
"runtime"
"testing" "testing"
"github.com/XiaoMi/soar/common" "github.com/XiaoMi/soar/common"
...@@ -32,6 +34,10 @@ var update = flag.Bool("update", false, "update .golden files") ...@@ -32,6 +34,10 @@ var update = flag.Bool("update", false, "update .golden files")
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// 初始化 init // 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath common.BaseDir = common.DevPath
err := common.ParseConfig("") err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig") common.LogIfError(err, "init ParseConfig")
......
...@@ -20,6 +20,8 @@ import ( ...@@ -20,6 +20,8 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"path/filepath"
"runtime"
"testing" "testing"
"github.com/XiaoMi/soar/common" "github.com/XiaoMi/soar/common"
...@@ -35,6 +37,10 @@ var rEnv *database.Connector ...@@ -35,6 +37,10 @@ var rEnv *database.Connector
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// 初始化 init // 初始化 init
if common.DevPath == "" {
_, file, _, _ := runtime.Caller(0)
common.DevPath, _ = filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
}
common.BaseDir = common.DevPath common.BaseDir = common.DevPath
err := common.ParseConfig("") err := common.ParseConfig("")
common.LogIfError(err, "init ParseConfig") common.LogIfError(err, "init ParseConfig")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册