Skip to contentSkip to conversation

python3-parse-type: Modify ptest output format

PATCH zangrc 2 participants 2 messages May 21, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

zangrc

author
#1 lore raw

Ping

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of zangrc
Sent: Monday, May 18, 2020 2:12 PM
To: Richard Purdie <[email protected]>; [email protected]
Cc: Tim Orling <[email protected]>
Subject: Re: [oe] [meta-python] [PATCH] python3-parse-type: Modify ptest output format

Is this solution feasible, and if it is feasible, which mailing list should I submit the patch to?

-----邮件原件-----
发件人: [email protected] <[email protected]> 代表 zangrc 发送时间: 2020年5月18日 14:09
收件人: Richard Purdie <[email protected]>; [email protected] 抄送: Tim Orling <[email protected]>
主题: 答复: [oe] [meta-python] [PATCH] python3-parse-type: Modify ptest output format

Now I have modified the output of pytest by modifying ptest-runner. My solution is that if OSS uses pytest testing, name its ptest file run-ptest-pytest.

The content of run-ptest-pytest is as follows:
pytest -o log_cli = true -o log_cli_level = INFO

The test output is as follows:
START: ptest-runner
2020-05-18T05:42
BEGIN: /usr/lib/python3-parse-type/ptest ============================= test session starts ============================== platform linux -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /usr/lib/python3-parse-type/ptest collected 192 items

PASS: tests/test_builder.py::TestTypeBuilder4Enum::test_make_enum_with_dict
PASS: tests/test_builder.py::TestTypeBuilder4Enum::test_make_enum_with_enum_class
PASS: tests/test_builder.py::TestTypeBuilder4Enum::test_parse_enum_yesno
...
PASS: tests/test_parse_util.py::TestFieldParser::test_extract_types
PASS: tests/test_parse_util.py::TestFieldParser::test_parse__raises_error_with_missing_or_partial_br
PASS: tests/test_parse_util.py::TestFieldParser::test_parse__with_valid_fields

============================= 192 passed in 18.41s =============================
STOP: ptest-runner
DURATION: 32
END: /usr/lib/python3-parse-type/ptest
2020-05-18T05:42
STOP: ptest-runner

-----邮件原件-----
发件人: Richard Purdie <[email protected]>
发送时间: 2020年5月13日 5:23
收件人: Zang, Ruochen/臧 若尘 <[email protected]>; [email protected] 抄送: Tim Orling <[email protected]>
主题: Re: [oe] [meta-python] [PATCH] python3-parse-type: Modify ptest output format

Quoted 12 lines · zangrc
---
 .../recipes-devtools/python/python3-parse-type/run-ptest        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta-python/recipes-devtools/python/python3-parse-type/run-ptest b/meta-python/recipes-devtools/python/python3-parse-type/run-ptest index 5cec71169..b63c4de0d 100644

meta-python/recipes-devtools/python/python3-parse-type/run-ptest line 3

Quoted 4 lines
meta-python/recipes-devtools/python/python3-parse-type/run-ptest +1 -1
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-pytest
+pytest -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'|sed -e 's/SKIPPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'

Rather than doing this for every python module, it may be an idea to consider:

a) teaching ptest runner how to handle the alternate output format (triggered by run-ptest-XXX instead of run-ptest)

or

b) adding a common python script which could avoid all this sed/awk magic and the extra dependencies

or

c) patch in a parameter to pytest which outputs the data in the format we need.

Cheers,

Richard

#2 lore raw

check master, I think its already applied via
https://git.openembedded.org/meta-openembedded/commit/?id=86d1c32a818abba71c5a52d21249759cf601ab2e

if not, please send a followup.

Quoted 98 lines · zangrc

Ping

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of zangrc
Sent: Monday, May 18, 2020 2:12 PM
To: Richard Purdie <[email protected]>; [email protected]
Cc: Tim Orling <[email protected]>
Subject: Re: [oe] [meta-python] [PATCH] python3-parse-type: Modify ptest output format

Is this solution feasible, and if it is feasible, which mailing list should I submit the patch to?

-----邮件原件-----
发件人: [email protected] <[email protected]> 代表 zangrc 发送时间: 2020年5月18日 14:09
收件人: Richard Purdie <[email protected]>; [email protected] 抄送: Tim Orling <[email protected]>
主题: 答复: [oe] [meta-python] [PATCH] python3-parse-type: Modify ptest output format

Now I have modified the output of pytest by modifying ptest-runner. My solution is that if OSS uses pytest testing, name its ptest file run-ptest-pytest.

The content of run-ptest-pytest is as follows:
pytest -o log_cli = true -o log_cli_level = INFO

The test output is as follows:
START: ptest-runner
2020-05-18T05:42
BEGIN: /usr/lib/python3-parse-type/ptest ============================= test session starts ============================== platform linux -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /usr/lib/python3-parse-type/ptest collected 192 items

PASS: tests/test_builder.py::TestTypeBuilder4Enum::test_make_enum_with_dict
PASS: tests/test_builder.py::TestTypeBuilder4Enum::test_make_enum_with_enum_class
PASS: tests/test_builder.py::TestTypeBuilder4Enum::test_parse_enum_yesno
...
PASS: tests/test_parse_util.py::TestFieldParser::test_extract_types
PASS: tests/test_parse_util.py::TestFieldParser::test_parse__raises_error_with_missing_or_partial_br
PASS: tests/test_parse_util.py::TestFieldParser::test_parse__with_valid_fields

============================= 192 passed in 18.41s =============================
STOP: ptest-runner
DURATION: 32
END: /usr/lib/python3-parse-type/ptest
2020-05-18T05:42
STOP: ptest-runner

-----邮件原件-----
发件人: Richard Purdie <[email protected]>
发送时间: 2020年5月13日 5:23
收件人: Zang, Ruochen/臧 若尘 <[email protected]>; [email protected] 抄送: Tim Orling <[email protected]>
主题: Re: [oe] [meta-python] [PATCH] python3-parse-type: Modify ptest output format

Quoted 12 lines · zangrc
---
  .../recipes-devtools/python/python3-parse-type/run-ptest        | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta-python/recipes-devtools/python/python3-parse-type/run-ptest b/meta-python/recipes-devtools/python/python3-parse-type/run-ptest index 5cec71169..b63c4de0d 100644

meta-python/recipes-devtools/python/python3-parse-type/run-ptest line 3

Quoted 4 lines
meta-python/recipes-devtools/python/python3-parse-type/run-ptest +1 -1
@@ -1,3 +1,3 @@
  #!/bin/sh
 
-pytest
+pytest -o log_cli=true -o log_cli_level=INFO | sed -e 's/\[...%\]//g'| sed -e 's/PASSED/PASS/g'| sed -e 's/FAILED/FAIL/g'|sed -e 's/SKIPPED/SKIP/g'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS"){printf "%s: %s\n", $NF, $0}else{print}}'| awk '{if ($NF=="PASS" || $NF=="FAIL" || $NF=="SKIP" || $NF=="XFAIL" || $NF=="XPASS") {$NF="";print $0}else{print}}'

Rather than doing this for every python module, it may be an idea to consider:

a) teaching ptest runner how to handle the alternate output format (triggered by run-ptest-XXX instead of run-ptest)

or

b) adding a common python script which could avoid all this sed/awk magic and the extra dependencies

or

c) patch in a parameter to pytest which outputs the data in the format we need.

Cheers,

Richard