mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-28 11:01:30 +08:00
change: add EnablePlugin, default to disable plugin
This commit is contained in:
@@ -180,9 +180,16 @@ func (c *TConfig) SetAndroid(options ...uixt.AndroidDeviceOption) *TConfig {
|
||||
return c
|
||||
}
|
||||
|
||||
func (s *TConfig) DisableAutoPopupHandler() *TConfig {
|
||||
s.IgnorePopup = true
|
||||
return s
|
||||
// EnablePlugin enables plugin for current testcase.
|
||||
// default to disable plugin
|
||||
func (c *TConfig) EnablePlugin() *TConfig {
|
||||
c.PluginSetting = &PluginConfig{}
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *TConfig) DisableAutoPopupHandler() *TConfig {
|
||||
c.IgnorePopup = true
|
||||
return c
|
||||
}
|
||||
|
||||
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) {
|
||||
log.Info().Str("path", path).Str("venv", venv).
|
||||
Bool("logOn", logOn).Msg("init plugin")
|
||||
// plugin file not found
|
||||
if path == "" {
|
||||
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) {
|
||||
log.Info().Str("path", path).Msg("locate plugin")
|
||||
// priority: hashicorp plugin (debugtalk.bin > debugtalk.py) > go plugin (debugtalk.so)
|
||||
|
||||
pluginPath, err = locateFile(path, PluginHashicorpGoBuiltFile)
|
||||
|
||||
@@ -286,12 +286,26 @@ func (r *HRPRunner) NewCaseRunner(testcase TestCase) (*CaseRunner, error) {
|
||||
config := testcase.Config.Get()
|
||||
|
||||
// init parser plugin
|
||||
plugin, err := initPlugin(config.Path, r.venv, r.pluginLogOn)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init plugin failed")
|
||||
}
|
||||
if plugin != nil {
|
||||
if config.PluginSetting != nil {
|
||||
plugin, err := initPlugin(config.Path, r.venv, r.pluginLogOn)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init plugin failed")
|
||||
}
|
||||
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
|
||||
@@ -309,23 +323,6 @@ func (r *HRPRunner) NewCaseRunner(testcase TestCase) (*CaseRunner, error) {
|
||||
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
|
||||
return caseRunner, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user