mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-25 01:59:52 +08:00
change: skip go plugin test for windows
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package hrp
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"plugin"
|
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -369,24 +368,6 @@ func TestCallBuiltinFunction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCallPluginFunction(t *testing.T) {
|
|
||||||
plugins, err := plugin.Open("examples/debugtalk.so")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf(err.Error())
|
|
||||||
}
|
|
||||||
pluginLoader := &pluginLoader{plugins}
|
|
||||||
|
|
||||||
// call function without arguments
|
|
||||||
f1, _ := getMappingFunction("Concatenate", pluginLoader)
|
|
||||||
result, err := callFunc(f1, 1, "2", 3.14)
|
|
||||||
if !assert.NoError(t, err) {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
if !assert.Equal(t, result, "1_2_3.14") {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLiteralEval(t *testing.T) {
|
func TestLiteralEval(t *testing.T) {
|
||||||
testData := []struct {
|
testData := []struct {
|
||||||
expr string
|
expr string
|
||||||
|
|||||||
40
plugin_test.go
Normal file
40
plugin_test.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// +build linux freebsd darwin
|
||||||
|
// go plugin doesn't support windows
|
||||||
|
package hrp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"plugin"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
fmt.Println("[TestMain] build go plugin")
|
||||||
|
cmd := exec.Command("go", "build", "-buildmode=plugin", "-o=examples/debugtalk.so", "examples/plugin/debugtalk.go")
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
os.Exit(m.Run())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCallPluginFunction(t *testing.T) {
|
||||||
|
plugins, err := plugin.Open("examples/debugtalk.so")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(err.Error())
|
||||||
|
}
|
||||||
|
pluginLoader := &pluginLoader{plugins}
|
||||||
|
|
||||||
|
// call function without arguments
|
||||||
|
f1, _ := getMappingFunction("Concatenate", pluginLoader)
|
||||||
|
result, err := callFunc(f1, 1, "2", 3.14)
|
||||||
|
if !assert.NoError(t, err) {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
if !assert.Equal(t, result, "1_2_3.14") {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
10
runner.go
10
runner.go
@@ -12,6 +12,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"plugin"
|
"plugin"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -519,6 +520,11 @@ type pluginLoader struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *caseRunner) loadPlugin(path string) error {
|
func (r *caseRunner) loadPlugin(path string) error {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
log.Warn().Msg("go plugin does not support windows")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -551,8 +557,8 @@ func (r *hrpRunner) getSummary() *testCaseSummary {
|
|||||||
return &testCaseSummary{}
|
return &testCaseSummary{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// locatePlugin
|
// locatePlugin searches debugtalk.so upward recursively until current
|
||||||
// searching will be recursive upward until current working directory or system root dir.
|
// working directory or system root dir.
|
||||||
func locatePlugin(startPath string) (string, error) {
|
func locatePlugin(startPath string) (string, error) {
|
||||||
stat, err := os.Stat(startPath)
|
stat, err := os.Stat(startPath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
|||||||
@@ -1,23 +1,12 @@
|
|||||||
package hrp
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
fmt.Println("[TestMain] build go plugin")
|
|
||||||
cmd := exec.Command("go", "build", "-buildmode=plugin", "-o=examples/debugtalk.so", "examples/plugin/debugtalk.go")
|
|
||||||
if err := cmd.Run(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
os.Exit(m.Run())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLocatePlugin(t *testing.T) {
|
func TestLocatePlugin(t *testing.T) {
|
||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
_, err := locatePlugin(cwd)
|
_, err := locatePlugin(cwd)
|
||||||
|
|||||||
Reference in New Issue
Block a user