From 1b6c7c9a93d8a086fdffd23179c3392fc79c15b0 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 22 Apr 2022 20:45:19 +0800 Subject: [PATCH] change: update GA events --- hrp/convert.go | 12 ++++++++++++ hrp/internal/pytest/main.go | 6 ++++++ httprunner/cli.py | 28 ++++++++++++++++++++++++++++ pyproject.toml | 2 ++ 4 files changed, 48 insertions(+) diff --git a/hrp/convert.go b/hrp/convert.go index 828d3794..fd30ac1e 100644 --- a/hrp/convert.go +++ b/hrp/convert.go @@ -5,6 +5,7 @@ import ( "github.com/rs/zerolog/log" "github.com/httprunner/httprunner/hrp/internal/builtin" + "github.com/httprunner/httprunner/hrp/internal/sdk" ) func Convert2TestScripts(destType string, paths ...string) error { @@ -16,6 +17,11 @@ func Convert2TestScripts(destType string, paths ...string) error { } func convert2PyTestScripts(paths ...string) error { + sdk.SendEvent(sdk.EventTracking{ + Category: "ConvertTests", + Action: "hrp convert --pytest", + }) + python3, err := builtin.EnsurePython3Venv("httprunner") if err != nil { return errors.Wrap(err, "ensure python venv failed") @@ -27,6 +33,12 @@ func convert2PyTestScripts(paths ...string) error { func convert2GoTestScripts(paths ...string) error { log.Warn().Msg("convert to gotest scripts is not supported yet") + + sdk.SendEvent(sdk.EventTracking{ + Category: "ConvertTests", + Action: "hrp convert --gotest", + }) + // report event // sdk.SendEvent(sdk.EventTracking{ // Category: "Convert", diff --git a/hrp/internal/pytest/main.go b/hrp/internal/pytest/main.go index 5b77eeef..5bbc0555 100644 --- a/hrp/internal/pytest/main.go +++ b/hrp/internal/pytest/main.go @@ -4,9 +4,15 @@ import ( "github.com/pkg/errors" "github.com/httprunner/httprunner/hrp/internal/builtin" + "github.com/httprunner/httprunner/hrp/internal/sdk" ) func RunPytest(args []string) error { + sdk.SendEvent(sdk.EventTracking{ + Category: "RunAPITests", + Action: "hrp pytest", + }) + python3, err := builtin.EnsurePython3Venv("httprunner") if err != nil { return errors.Wrap(err, "ensure python venv failed") diff --git a/httprunner/cli.py b/httprunner/cli.py index 87b16229..1aa29eac 100644 --- a/httprunner/cli.py +++ b/httprunner/cli.py @@ -108,5 +108,33 @@ def main(): main_make(args.testcase_path) +def main_hrun_alias(): + """ command alias + hrun = httprunner run + """ + if len(sys.argv) == 2: + if sys.argv[1] in ["-V", "--version"]: + # hrun -V + sys.argv = ["httprunner", "-V"] + elif sys.argv[1] in ["-h", "--help"]: + pytest.main(["-h"]) + sys.exit(0) + else: + # hrun /path/to/testcase + sys.argv.insert(1, "run") + else: + sys.argv.insert(1, "run") + + main() + + +def main_make_alias(): + """ command alias + hmake = httprunner make + """ + sys.argv.insert(1, "make") + main() + + if __name__ == "__main__": main() diff --git a/pyproject.toml b/pyproject.toml index 9f3f74a7..0f7c8e75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,8 @@ coverage = "^4.5.4" [tool.poetry.scripts] httprunner = "httprunner.cli:main" +hrun = "httprunner.cli:main_hrun_alias" +hmake = "httprunner.cli:main_make_alias" [build-system] requires = ["poetry>=1.0.0"]