Skip to content

Commit

Permalink
add xgo tool test-explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
xhd2015 committed May 21, 2024
1 parent b1fa6d6 commit 1c42800
Show file tree
Hide file tree
Showing 20 changed files with 1,468 additions and 21 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Verify the installation:
xgo version
# output:
# 1.0.x

xgo help
# output: help messages
```

If `xgo` is not found, you may need to check if `$GOPATH/bin` is added to your `PATH` variable.
Expand Down
3 changes: 3 additions & 0 deletions README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ go install github.com/xhd2015/xgo/cmd/xgo@latest
xgo version
# 输出:
# 1.0.x

xgo help
# 输出: xgo使用帮助
```
如果未找到`xgo`, 你可能需要查看`$GOPATH/bin`是否已经添加到你的`PATH`变量中。

Expand Down
16 changes: 16 additions & 0 deletions cmd/go-tool-test-explorer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
"os"

test_explorer "github.com/xhd2015/xgo/cmd/xgo/test-explorer"
)

func main() {
err := test_explorer.Main(os.Args[1:], nil)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
4 changes: 2 additions & 2 deletions cmd/xgo/runtime_gen/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

const VERSION = "1.0.36"
const REVISION = "e44373cb3c83b85599797e1f0cb302f81a95d598+1"
const NUMBER = 225
const REVISION = "b1fa6d6f3a19df8888bf2c0eb103ddff88257582+1"
const NUMBER = 226

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
87 changes: 87 additions & 0 deletions cmd/xgo/test-explorer/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package test_explorer

import (
"encoding/json"
"fmt"
)

type TestConfig struct {
Go *GoConfig
GoCmd string
Exclude []string
Env map[string]interface{}
}

type GoConfig struct {
Min string `json:"min"`
Max string `json:"max"`
}

func parseTestConfig(config string) (*TestConfig, error) {
if config == "" {
return &TestConfig{}, nil
}
var m map[string]interface{}
err := json.Unmarshal([]byte(config), &m)
if err != nil {
return nil, err
}

conf := &TestConfig{}

e, ok := m["env"]
if ok {
e, ok := e.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("env type err, expect map[string]interface{}, actual: %T", e)
}
conf.Env = e
}

e, ok = m["go"]
if ok {
goConf := &GoConfig{}
if s, ok := e.(string); ok {
goConf.Min = s
} else {
edata, err := json.Marshal(e)
if err != nil {
return nil, err
}
err = json.Unmarshal(edata, &goConf)
if err != nil {
return nil, err
}
}
conf.Go = goConf
}
e, ok = m["go_cmd"]
if ok {
if s, ok := e.(string); ok {
conf.GoCmd = s
} else {
return nil, fmt.Errorf("go_cmd requires string, actual: %T", e)
}
}
e, ok = m["exclude"]
if ok {
switch e := e.(type) {
case string:
if e != "" {
conf.Exclude = []string{e}
}
case []interface{}:
for _, x := range e {
s, ok := x.(string)
if !ok {
return nil, fmt.Errorf("exclude requires string, actual: %T", x)
}
conf.Exclude = append(conf.Exclude, s)
}
default:
return nil, fmt.Errorf("exclude requires string or list, actual: %T", e)
}
}

return conf, nil
}
25 changes: 25 additions & 0 deletions cmd/xgo/test-explorer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en" style="height: 100%;">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Xgo Test Explorer</title>
<style>
</style>
<script>
window.onload = function(){
const {renderReact,UrlXgoTestingExplorer} = Open
renderReact(root,UrlXgoTestingExplorer,{
apiPrefix:"http://localhost:8080"
})
}
</script>
</head>
<body style="height: 100%;">
<div id="root" style="height: 100%;"></div>
</body>
<!--after body because document.body may be null-->
<!--available in CN and Global-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.js"></script>
<!-- <script src="http://127.0.0.1:8080/npm-publish/index.js"></script> -->
</html>
Loading

0 comments on commit 1c42800

Please sign in to comment.