mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:59:44 +08:00
change: clean code
This commit is contained in:
@@ -148,7 +148,7 @@ func Init(path string) (Plugin, error) {
|
||||
}
|
||||
var plugin Plugin
|
||||
|
||||
// priority: hashicorp plugin > go plugin > builtin functions
|
||||
// priority: hashicorp plugin > go plugin
|
||||
// locate hashicorp plugin file
|
||||
pluginPath, err := locateFile(path, hashicorpGoPluginFile)
|
||||
if err == nil {
|
||||
|
||||
45
runner.go
45
runner.go
@@ -193,41 +193,36 @@ func (r *caseRunner) run() error {
|
||||
}
|
||||
|
||||
func initPlugin(path string) (plugin common.Plugin, err error) {
|
||||
defer func() {
|
||||
if plugin == nil {
|
||||
return
|
||||
}
|
||||
|
||||
var pluginType string
|
||||
if _, ok := plugin.(*common.GoPlugin); ok {
|
||||
pluginType = "go"
|
||||
} else {
|
||||
pluginType = "hashicorp"
|
||||
}
|
||||
|
||||
// report event for initializing plugin
|
||||
event := ga.EventTracking{
|
||||
Category: "InitPlugin",
|
||||
Action: fmt.Sprintf("Init %s plugin", pluginType),
|
||||
}
|
||||
if err != nil {
|
||||
event.Value = 1 // failed
|
||||
}
|
||||
go ga.SendEvent(event)
|
||||
}()
|
||||
plugin, err = common.Init(path)
|
||||
if plugin == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// catch Interrupt and SIGTERM signals to ensure plugin quitted
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-c
|
||||
if plugin != nil {
|
||||
plugin.Quit()
|
||||
}
|
||||
plugin.Quit()
|
||||
os.Exit(1)
|
||||
}()
|
||||
|
||||
// report event for initializing plugin
|
||||
var pluginType string
|
||||
if _, ok := plugin.(*common.GoPlugin); ok {
|
||||
pluginType = "go"
|
||||
} else {
|
||||
pluginType = "hashicorp"
|
||||
}
|
||||
event := ga.EventTracking{
|
||||
Category: "InitPlugin",
|
||||
Action: fmt.Sprintf("Init %s plugin", pluginType),
|
||||
}
|
||||
if err != nil {
|
||||
event.Value = 1 // failed
|
||||
}
|
||||
go ga.SendEvent(event)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user