mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
refactor: relocate build plugin
This commit is contained in:
+13
-11
@@ -10,18 +10,20 @@ import (
|
||||
"github.com/httprunner/funplugin"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/build"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||
)
|
||||
|
||||
const (
|
||||
goPluginFile = "debugtalk.so" // built from go plugin
|
||||
hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin
|
||||
hashicorpPyPluginFile = ".debugtalk_gen.py" // used for hashicorp python plugin, automatically generated by HRP
|
||||
debugtalkPyFile = "debugtalk.py" // write by user
|
||||
projectInfoFile = "proj.json" // used for ensuring root project
|
||||
PluginGoBuiltFile = "debugtalk.so" // built from go official plugin
|
||||
PluginHashicorpGoBuiltFile = "debugtalk.bin" // built from hashicorp go plugin
|
||||
PluginGoSourceFile = "debugtalk.go" // golang function plugin source file
|
||||
PluginGoSourceGenFile = "debugtalk_gen.go" // generated for hashicorp go plugin
|
||||
PluginPySourceFile = "debugtalk.py" // python function plugin source file
|
||||
PluginPySourceGenFile = ".debugtalk_gen.py" // generated for hashicorp python plugin
|
||||
)
|
||||
|
||||
const projectInfoFile = "proj.json" // used for ensuring root project
|
||||
|
||||
func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
||||
// plugin file not found
|
||||
if path == "" {
|
||||
@@ -64,16 +66,16 @@ func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
||||
func locatePlugin(path string) (pluginPath string, err error) {
|
||||
// priority: hashicorp plugin (debugtalk.bin > debugtalk.py) > go plugin (debugtalk.so)
|
||||
|
||||
pluginPath, err = locateFile(path, hashicorpGoPluginFile)
|
||||
pluginPath, err = locateFile(path, PluginHashicorpGoBuiltFile)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
pluginPath, err = locateFile(path, debugtalkPyFile)
|
||||
pluginPath, err = locateFile(path, PluginPySourceFile)
|
||||
if err == nil {
|
||||
// register funppy plugin
|
||||
genPyPluginPath := filepath.Join(filepath.Dir(pluginPath), hashicorpPyPluginFile)
|
||||
err = build.Run(pluginPath, genPyPluginPath)
|
||||
genPyPluginPath := filepath.Join(filepath.Dir(pluginPath), PluginPySourceGenFile)
|
||||
err = BuildPlugin(pluginPath, genPyPluginPath)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Str("path", pluginPath).Msg("build plugin failed")
|
||||
return
|
||||
@@ -81,7 +83,7 @@ func locatePlugin(path string) (pluginPath string, err error) {
|
||||
return genPyPluginPath, nil
|
||||
}
|
||||
|
||||
pluginPath, err = locateFile(path, goPluginFile)
|
||||
pluginPath, err = locateFile(path, PluginGoBuiltFile)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user