mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
change: skip go plugin test for windows
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package hrp
|
||||
|
||||
import (
|
||||
"plugin"
|
||||
"sort"
|
||||
"testing"
|
||||
"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) {
|
||||
testData := []struct {
|
||||
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"
|
||||
"path/filepath"
|
||||
"plugin"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -519,6 +520,11 @@ type pluginLoader struct {
|
||||
}
|
||||
|
||||
func (r *caseRunner) loadPlugin(path string) error {
|
||||
if runtime.GOOS == "windows" {
|
||||
log.Warn().Msg("go plugin does not support windows")
|
||||
return nil
|
||||
}
|
||||
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
@@ -551,8 +557,8 @@ func (r *hrpRunner) getSummary() *testCaseSummary {
|
||||
return &testCaseSummary{}
|
||||
}
|
||||
|
||||
// locatePlugin
|
||||
// searching will be recursive upward until current working directory or system root dir.
|
||||
// locatePlugin searches debugtalk.so upward recursively until current
|
||||
// working directory or system root dir.
|
||||
func locatePlugin(startPath string) (string, error) {
|
||||
stat, err := os.Stat(startPath)
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
package hrp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"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 TestLocatePlugin(t *testing.T) {
|
||||
cwd, _ := os.Getwd()
|
||||
_, err := locatePlugin(cwd)
|
||||
|
||||
Reference in New Issue
Block a user