refactor: rename debugtalk_gen.py to .debugtalk_gen.py

This commit is contained in:
debugtalk
2022-05-29 00:50:20 +08:00
parent da608db9bb
commit 3d17bcecdf
11 changed files with 90 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
{
"project_name": "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"
}

View File

@@ -1,6 +1,6 @@
{
"project_name": "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"
}

View File

@@ -1,6 +1,6 @@
{
"project_name": "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"
}

View File

@@ -1,6 +1,6 @@
{
"project_name": "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"
}

View File

@@ -32,7 +32,7 @@ const (
const (
genDebugTalkGo = "debugtalk_gen.go"
genDebugTalkPy = "debugtalk_gen.py"
genDebugTalkPy = ".debugtalk_gen.py"
)
//go:embed templates/debugtalkPythonTemplate

View File

@@ -15,13 +15,13 @@ func TestRun(t *testing.T) {
t.Fatal()
}
genDebugTalkPy := "../scaffold/templates/plugin/debugtalk_gen.py"
err = Run("../scaffold/templates/plugin/debugtalk.py", genDebugTalkPy)
genDebugTalkPyPath := "../scaffold/templates/plugin/" + genDebugTalkPy
err = Run("../scaffold/templates/plugin/debugtalk.py", genDebugTalkPyPath)
if !assert.Nil(t, err) {
t.Fatal()
}
contentBytes, err := builtin.ReadFile(genDebugTalkPy)
contentBytes, err := builtin.ReadFile(genDebugTalkPyPath)
if !assert.Nil(t, err) {
t.Fatal()
}

View 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()

View File

@@ -15,11 +15,11 @@ import (
)
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
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
)
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)
if err == nil {
// convert debugtalk.py to debugtalk_gen.py
// register funppy plugin
genPyPluginPath := filepath.Join(filepath.Dir(pluginPath), hashicorpPyPluginFile)
err = build.Run(pluginPath, genPyPluginPath)

View File

@@ -38,8 +38,8 @@ func buildHashicorpPyPlugin() {
func removeHashicorpPyPlugin() {
log.Info().Msg("[teardown] remove hashicorp python plugin")
// on v4.1^, running case will generate debugtalk_gen.py used by python plugin
os.Remove(templatesDir + "debugtalk_gen.py")
// on v4.1^, running case will generate .debugtalk_gen.py used by python plugin
os.Remove(templatesDir + hashicorpPyPluginFile)
}
func TestRunCaseWithGoPlugin(t *testing.T) {