mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
change: add EnablePlugin, default to disable plugin
This commit is contained in:
+10
-3
@@ -180,9 +180,16 @@ func (c *TConfig) SetAndroid(options ...uixt.AndroidDeviceOption) *TConfig {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TConfig) DisableAutoPopupHandler() *TConfig {
|
// EnablePlugin enables plugin for current testcase.
|
||||||
s.IgnorePopup = true
|
// default to disable plugin
|
||||||
return s
|
func (c *TConfig) EnablePlugin() *TConfig {
|
||||||
|
c.PluginSetting = &PluginConfig{}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *TConfig) DisableAutoPopupHandler() *TConfig {
|
||||||
|
c.IgnorePopup = true
|
||||||
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
type ThinkTimeConfig struct {
|
type ThinkTimeConfig struct {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v5.0.0+2411141441
|
v5.0.0+2411141550
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
||||||
|
log.Info().Str("path", path).Str("venv", venv).
|
||||||
|
Bool("logOn", logOn).Msg("init plugin")
|
||||||
// plugin file not found
|
// plugin file not found
|
||||||
if path == "" {
|
if path == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -99,6 +101,7 @@ func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func locatePlugin(path string) (pluginPath string, err error) {
|
func locatePlugin(path string) (pluginPath string, err error) {
|
||||||
|
log.Info().Str("path", path).Msg("locate plugin")
|
||||||
// priority: hashicorp plugin (debugtalk.bin > debugtalk.py) > go plugin (debugtalk.so)
|
// priority: hashicorp plugin (debugtalk.bin > debugtalk.py) > go plugin (debugtalk.so)
|
||||||
|
|
||||||
pluginPath, err = locateFile(path, PluginHashicorpGoBuiltFile)
|
pluginPath, err = locateFile(path, PluginHashicorpGoBuiltFile)
|
||||||
|
|||||||
+19
-22
@@ -286,12 +286,26 @@ func (r *HRPRunner) NewCaseRunner(testcase TestCase) (*CaseRunner, error) {
|
|||||||
config := testcase.Config.Get()
|
config := testcase.Config.Get()
|
||||||
|
|
||||||
// init parser plugin
|
// init parser plugin
|
||||||
plugin, err := initPlugin(config.Path, r.venv, r.pluginLogOn)
|
if config.PluginSetting != nil {
|
||||||
if err != nil {
|
plugin, err := initPlugin(config.Path, r.venv, r.pluginLogOn)
|
||||||
return nil, errors.Wrap(err, "init plugin failed")
|
if err != nil {
|
||||||
}
|
return nil, errors.Wrap(err, "init plugin failed")
|
||||||
if plugin != nil {
|
}
|
||||||
caseRunner.parser.plugin = plugin
|
caseRunner.parser.plugin = plugin
|
||||||
|
|
||||||
|
// load plugin info to testcase config
|
||||||
|
pluginPath := plugin.Path()
|
||||||
|
pluginContent, err := readFile(pluginPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config.PluginSetting.Path = pluginPath
|
||||||
|
config.PluginSetting.Content = pluginContent
|
||||||
|
tp := strings.Split(pluginPath, ".")
|
||||||
|
config.PluginSetting.Type = tp[len(tp)-1]
|
||||||
|
log.Info().Str("pluginPath", pluginPath).
|
||||||
|
Str("pluginType", config.PluginSetting.Type).
|
||||||
|
Msg("plugin info loaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse testcase config
|
// parse testcase config
|
||||||
@@ -309,23 +323,6 @@ func (r *HRPRunner) NewCaseRunner(testcase TestCase) (*CaseRunner, error) {
|
|||||||
r.SetCaseTimeout(config.CaseTimeout)
|
r.SetCaseTimeout(config.CaseTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// load plugin info to testcase config
|
|
||||||
if plugin != nil {
|
|
||||||
pluginPath, _ := locatePlugin(config.Path)
|
|
||||||
if parsedConfig.PluginSetting == nil {
|
|
||||||
pluginContent, err := readFile(pluginPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
tp := strings.Split(plugin.Path(), ".")
|
|
||||||
parsedConfig.PluginSetting = &PluginConfig{
|
|
||||||
Path: pluginPath,
|
|
||||||
Content: pluginContent,
|
|
||||||
Type: tp[len(tp)-1],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
caseRunner.TestCase.Config = parsedConfig
|
caseRunner.TestCase.Config = parsedConfig
|
||||||
return caseRunner, nil
|
return caseRunner, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user