mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
change: get plugin path from funplugin
This commit is contained in:
+3
-5
@@ -22,17 +22,15 @@ const (
|
|||||||
projectInfoFile = "proj.json" // used for ensuring root project
|
projectInfoFile = "proj.json" // used for ensuring root project
|
||||||
)
|
)
|
||||||
|
|
||||||
func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, pluginDir string, err error) {
|
func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
||||||
// plugin file not found
|
// plugin file not found
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return nil, "", nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
pluginPath, err := locatePlugin(path)
|
pluginPath, err := locatePlugin(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
// TODO: move pluginDir to funplugin
|
|
||||||
pluginDir = filepath.Dir(pluginPath)
|
|
||||||
|
|
||||||
// found plugin file
|
// found plugin file
|
||||||
plugin, err = funplugin.Init(pluginPath, funplugin.WithLogOn(logOn))
|
plugin, err = funplugin.Init(pluginPath, funplugin.WithLogOn(logOn))
|
||||||
|
|||||||
+3
-2
@@ -5,6 +5,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -231,12 +232,12 @@ func (r *HRPRunner) newCaseRunner(testcase *TestCase) (*testCaseRunner, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init parser plugin
|
// init parser plugin
|
||||||
plugin, pluginDir, err := initPlugin(testcase.Config.Path, r.pluginLogOn)
|
plugin, err := initPlugin(testcase.Config.Path, r.pluginLogOn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "init plugin failed")
|
return nil, errors.Wrap(err, "init plugin failed")
|
||||||
}
|
}
|
||||||
runner.parser.plugin = plugin
|
runner.parser.plugin = plugin
|
||||||
runner.rootDir = pluginDir
|
runner.rootDir = filepath.Dir(plugin.Path())
|
||||||
|
|
||||||
// parse testcase config
|
// parse testcase config
|
||||||
if err := runner.parseConfig(); err != nil {
|
if err := runner.parseConfig(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user