git: a28a4cb5e909 - stable/13 - atf_pytest_wrapper: fix pytest output truncation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Feb 2023 16:11:22 UTC
The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=a28a4cb5e9090806b6a7f8912f3ddcc1dfc57217 commit a28a4cb5e9090806b6a7f8912f3ddcc1dfc57217 Author: Jose Luis Duran <jlduran@gmail.com> AuthorDate: 2022-12-28 17:28:59 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-02-09 15:45:28 +0000 atf_pytest_wrapper: fix pytest output truncation Pass `-vv` to pytest in order to always get the full output. While here, enforce the modeline. Differential Revision: https://reviews.freebsd.org/D37894 MFC after: 2 weeks (cherry picked from commit 058ac3e8063366dafa634d9107642e12b038bf09) --- .../atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp | 55 +++++++++++----------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp b/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp index 7f6e886a16d9..78b045b9775f 100644 --- a/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp +++ b/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp @@ -65,7 +65,7 @@ class Handler { // * without schebang args // atf_wrap /path/to/script -l // Running test: - // atf_wrap '-P /path' /path/to/script -r /path1 -s /path2 -vk1=v1 testname + // atf_wrap '-P /path' /path/to/script -r /path1 -s /path2 -vk1=v1 testname void Parse(int argc, char **argv) { if (flag_debug) { PrintVector("IN", ToVector(argc, argv)); @@ -89,34 +89,34 @@ class Handler { // The next argument is a script name. Copy and keep argc/argv the same // Show usage for empty args if (argc == 0) { - Usage("Must provide a test case name", true); + Usage("Must provide a test case name", true); } script_path = std::string(argv[0]); int c; while ((c = getopt(argc, argv, "lr:s:v:")) != -1) { switch (c) { - case 'l': - flag_list = true; - break; - case 's': - src_dir = std::string(optarg); - break; - case 'r': - dst_file = std::string(optarg); - break; - case 'v': - { - std::string kv = std::string(optarg); - size_t splitter = kv.find("="); - if (splitter == std::string::npos) { - Usage("Unknown variable: " + kv, true); - } - kv_map[kv.substr(0, splitter)] = kv.substr(splitter + 1); - } - break; - default: - Usage("Unknown option -" + std::string(1, static_cast<char>(c)), true); + case 'l': + flag_list = true; + break; + case 's': + src_dir = std::string(optarg); + break; + case 'r': + dst_file = std::string(optarg); + break; + case 'v': + { + std::string kv = std::string(optarg); + size_t splitter = kv.find("="); + if (splitter == std::string::npos) { + Usage("Unknown variable: " + kv, true); + } + kv_map[kv.substr(0, splitter)] = kv.substr(splitter + 1); + } + break; + default: + Usage("Unknown option -" + std::string(1, static_cast<char>(c)), true); } } argc -= optind; @@ -138,7 +138,8 @@ class Handler { } std::vector<std::string> BuildArgs() { - std::vector<std::string> args = {"pytest", "-p", "no:cacheprovider", "-s", "--atf"}; + std::vector<std::string> args = {"pytest", "-vv", "-p", + "no:cacheprovider", "-s", "--atf"}; if (flag_list) { args.push_back("--co"); @@ -179,7 +180,7 @@ class Handler { // Pass ATF kv pairs as env variables to avoid dealing with // pytest parser for (auto [k, v]: kv_map) { - setenv((kAtfVar + k).c_str(), v.c_str(), 1); + setenv((kAtfVar + k).c_str(), v.c_str(), 1); } } @@ -190,7 +191,7 @@ class Handler { // allocate array with final NULL char **arr = new char*[args.size() + 1](); for (unsigned long i = 0; i < args.size(); i++) { - // work around 'char *const *' + // work around 'char *const *' arr[i] = strdup(args[i].c_str()); } return execvp(binary.c_str(), arr) == 0; @@ -204,7 +205,7 @@ class Handler { "not_found__" << std::endl; } else { std::cout << "execvp(" << kPytestName << ") failed: " << - std::strerror(errno) << std::endl; + std::strerror(errno) << std::endl; } }