-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,468 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.