mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 15:31:23 +08:00
refactor: rename debugtalk_gen.py to .debugtalk_gen.py
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-empty-project",
|
"project_name": "demo-empty-project",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-empty-project",
|
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-empty-project",
|
||||||
"create_time": "2022-05-29T00:19:34.824392+08:00",
|
"create_time": "2022-05-29T00:38:43.685282+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.0"
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-with-go-plugin",
|
"project_name": "demo-with-go-plugin",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-go-plugin",
|
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-go-plugin",
|
||||||
"create_time": "2022-05-29T00:19:33.056663+08:00",
|
"create_time": "2022-05-29T00:38:42.384694+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.0"
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-with-py-plugin",
|
"project_name": "demo-with-py-plugin",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-py-plugin",
|
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-py-plugin",
|
||||||
"create_time": "2022-05-29T00:19:33.203339+08:00",
|
"create_time": "2022-05-29T00:38:42.523325+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.0"
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-without-plugin",
|
"project_name": "demo-without-plugin",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-without-plugin",
|
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-without-plugin",
|
||||||
"create_time": "2022-05-29T00:19:34.698757+08:00",
|
"create_time": "2022-05-29T00:38:43.556711+08:00",
|
||||||
"hrp_version": "v4.1.0"
|
"hrp_version": "v4.1.0"
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
genDebugTalkGo = "debugtalk_gen.go"
|
genDebugTalkGo = "debugtalk_gen.go"
|
||||||
genDebugTalkPy = "debugtalk_gen.py"
|
genDebugTalkPy = ".debugtalk_gen.py"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates/debugtalkPythonTemplate
|
//go:embed templates/debugtalkPythonTemplate
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ func TestRun(t *testing.T) {
|
|||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
genDebugTalkPy := "../scaffold/templates/plugin/debugtalk_gen.py"
|
genDebugTalkPyPath := "../scaffold/templates/plugin/" + genDebugTalkPy
|
||||||
err = Run("../scaffold/templates/plugin/debugtalk.py", genDebugTalkPy)
|
err = Run("../scaffold/templates/plugin/debugtalk.py", genDebugTalkPyPath)
|
||||||
if !assert.Nil(t, err) {
|
if !assert.Nil(t, err) {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
contentBytes, err := builtin.ReadFile(genDebugTalkPy)
|
contentBytes, err := builtin.ReadFile(genDebugTalkPyPath)
|
||||||
if !assert.Nil(t, err) {
|
if !assert.Nil(t, err) {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|||||||
75
hrp/internal/scaffold/templates/plugin/.debugtalk_gen.py
Normal file
75
hrp/internal/scaffold/templates/plugin/.debugtalk_gen.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# NOTE: Generated By hrp v4.1.0, DO NOT EDIT!
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
import funppy
|
||||||
|
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
|
def get_user_agent():
|
||||||
|
return "hrp/funppy"
|
||||||
|
|
||||||
|
|
||||||
|
def sleep(n_secs):
|
||||||
|
time.sleep(n_secs)
|
||||||
|
|
||||||
|
|
||||||
|
def sum(*args):
|
||||||
|
result = 0
|
||||||
|
for arg in args:
|
||||||
|
result += arg
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def sum_ints(*args: List[int]) -> int:
|
||||||
|
result = 0
|
||||||
|
for arg in args:
|
||||||
|
result += arg
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def sum_two_int(a: int, b: int) -> int:
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
|
||||||
|
def sum_two_string(a: str, b: str) -> str:
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
|
||||||
|
def sum_strings(*args: List[str]) -> str:
|
||||||
|
result = ""
|
||||||
|
for arg in args:
|
||||||
|
result += arg
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def concatenate(*args: List[str]) -> str:
|
||||||
|
result = ""
|
||||||
|
for arg in args:
|
||||||
|
result += str(arg)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def setup_hook_example(name):
|
||||||
|
logging.warning("setup_hook_example")
|
||||||
|
return f"setup_hook_example: {name}"
|
||||||
|
|
||||||
|
|
||||||
|
def teardown_hook_example(name):
|
||||||
|
logging.warning("teardown_hook_example")
|
||||||
|
return f"teardown_hook_example: {name}"
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
funppy.register("get_user_agent", get_user_agent)
|
||||||
|
funppy.register("sleep", sleep)
|
||||||
|
funppy.register("sum", sum)
|
||||||
|
funppy.register("sum_ints", sum_ints)
|
||||||
|
funppy.register("sum_two_int", sum_two_int)
|
||||||
|
funppy.register("sum_two_string", sum_two_string)
|
||||||
|
funppy.register("sum_strings", sum_strings)
|
||||||
|
funppy.register("concatenate", concatenate)
|
||||||
|
funppy.register("setup_hook_example", setup_hook_example)
|
||||||
|
funppy.register("teardown_hook_example", teardown_hook_example)
|
||||||
|
funppy.serve()
|
||||||
@@ -15,11 +15,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
goPluginFile = "debugtalk.so" // built from go plugin
|
goPluginFile = "debugtalk.so" // built from go plugin
|
||||||
hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin
|
hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin
|
||||||
hashicorpPyPluginFile = "debugtalk_gen.py" // used for hashicorp python plugin, automatically generated by HRP
|
hashicorpPyPluginFile = ".debugtalk_gen.py" // used for hashicorp python plugin, automatically generated by HRP
|
||||||
debugtalkPyFile = "debugtalk.py" // write by user
|
debugtalkPyFile = "debugtalk.py" // write by user
|
||||||
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, pluginDir string, err error) {
|
||||||
@@ -73,7 +73,6 @@ func locatePlugin(path string) (pluginPath string, err error) {
|
|||||||
|
|
||||||
pluginPath, err = locateFile(path, debugtalkPyFile)
|
pluginPath, err = locateFile(path, debugtalkPyFile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// convert debugtalk.py to debugtalk_gen.py
|
|
||||||
// register funppy plugin
|
// register funppy plugin
|
||||||
genPyPluginPath := filepath.Join(filepath.Dir(pluginPath), hashicorpPyPluginFile)
|
genPyPluginPath := filepath.Join(filepath.Dir(pluginPath), hashicorpPyPluginFile)
|
||||||
err = build.Run(pluginPath, genPyPluginPath)
|
err = build.Run(pluginPath, genPyPluginPath)
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ func buildHashicorpPyPlugin() {
|
|||||||
|
|
||||||
func removeHashicorpPyPlugin() {
|
func removeHashicorpPyPlugin() {
|
||||||
log.Info().Msg("[teardown] remove hashicorp python plugin")
|
log.Info().Msg("[teardown] remove hashicorp python plugin")
|
||||||
// on v4.1^, running case will generate debugtalk_gen.py used by python plugin
|
// on v4.1^, running case will generate .debugtalk_gen.py used by python plugin
|
||||||
os.Remove(templatesDir + "debugtalk_gen.py")
|
os.Remove(templatesDir + hashicorpPyPluginFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunCaseWithGoPlugin(t *testing.T) {
|
func TestRunCaseWithGoPlugin(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user