lint: convert submodule linter test to Python #24803
pull Eunoia1729 wants to merge 1 commits into bitcoin:master from Eunoia1729:lint-submodule-py changing 2 files +23 −20-
Eunoia1729 commented at 8:27 pm on April 7, 2022: contributorRefs #24783
-
Eunoia1729 renamed this:
linnt: convert submodule linter test to Python
lint: convert submodule linter test to Python
on Apr 7, 2022 -
Eunoia1729 force-pushed on Apr 7, 2022
-
Eunoia1729 force-pushed on Apr 7, 2022
-
DrahtBot added the label Tests on Apr 7, 2022
-
in test/lint/lint-submodule.py:18 in 1b324cf20a outdated
13+def main(): 14+ submodule_check_args = ['git', 'submodule', 'status', '--recursive',] 15+ try: 16+ submodules_list = subprocess.check_output(submodule_check_args, stderr = subprocess.STDOUT) 17+ except subprocess.CalledProcessError: 18+ exit(1)
KevinMusgrave commented at 10:50 am on April 8, 2022:I think python already returns an exit code of 1 when it raises an exception
laanwj commented at 11:40 am on April 8, 2022:I do think it’s neater not to have a Python exception in the output, especially if the subprocess already prints its own self-evident errors.
MarcoFalke commented at 11:46 am on April 8, 2022:This should never happen, and when it happens, the process won’t print it’s own errors, so the exception seems better?
laanwj commented at 11:48 am on April 8, 2022:I’m pretty sure thatgit
prints its own error when it fails. But ok, no strong opinion here.
MarcoFalke commented at 11:58 am on April 8, 2022:check_output
will eat the output. Withstderr = subprocess.STDOUT
it will also eat the error.
laanwj commented at 5:49 pm on April 13, 2022:I hadn’t noticed thestderr = subprocess.STDOUT
. Pretty sure we don’t need it. The original script doesn’t redirect the stderr either.
Eunoia1729 commented at 5:53 pm on April 13, 2022:Thank you @laanwj , @KevinMusgrave and @MarcoFalke for your review and points which led me to dig further.
I second @MarcoFalke .
From my understanding, 2 cases are:- Without
stderr = subprocess.STDOUT
, the error is printed onto the console and is not piped to Python. - With
stderr = subprocess.STDOUT
, if we want to access the error message, we can access it usinge.output
in the exception block (wheree
is CalledProcessError object). Without explicit printing, error is not printed onto console.
I’ll update the PR to print errors to keep the behaviour consistent with older version. Additionally, I don’t see any cases where this command will return exit code = 1. Should I remove try exception block ?
Kindly let me know your views too.
Edit: I removed try exception block.
KevinMusgrave commented at 11:12 am on April 8, 2022: contributorConcept/approach ACKin test/lint/lint-submodule.py:27 in 1b324cf20a outdated
22+ if submodules_list: 23+ print("These submodules were found, delete them:") 24+ for submodule in submodules_list: 25+ print(submodule) 26+ exit(1) 27+ exit(0)
laanwj commented at 11:51 am on April 8, 2022:
Eunoia1729 commented at 7:47 pm on April 13, 2022:Thanks again @laanwj for the review! I’ve updated the PR.Eunoia1729 force-pushed on Apr 13, 2022Eunoia1729 commented at 7:46 pm on April 13, 2022: contributorBefore change:
After change:
KevinMusgrave commented at 7:48 pm on April 13, 2022: contributorTested ACK 3289688f7e4642f0790d205dfe257cc929001b3cEunoia1729 requested review from laanwj on Apr 13, 2022in test/lint/lint-submodule.py:24 in 3289688f7e outdated
19+ '--recursive', 20+ ] 21+ return subprocess.check_output(command).decode('utf-8').splitlines() 22+ 23+def main(): 24+ submodules_list = get_submodules_list()
MarcoFalke commented at 11:15 am on April 15, 2022:0 submodules_list = subprocess.check_output(
no need for a function, you can call the stdlib directly
Eunoia1729 commented at 5:25 am on April 20, 2022:Sure, done !in test/lint/lint-submodule.py:27 in 3289688f7e outdated
22+ 23+def main(): 24+ submodules_list = get_submodules_list() 25+ if submodules_list: 26+ print("These submodules were found, delete them:") 27+ for submodule in submodules_list:
MarcoFalke commented at 11:16 am on April 15, 2022:what is the point of first splitting by newline and then joining the array by newline again when printing? Just leave it as string?
Eunoia1729 commented at 5:24 am on April 20, 2022:I agree, that was unnecessary. Updated the PR. Thanks for pointing it out !lint: convert submodule linter test to Python 4a9e36dbafEunoia1729 force-pushed on Apr 20, 2022laanwj commented at 3:09 pm on April 21, 2022: memberTested ACK 4a9e36dbaf96f83d0829f8442114a2fa36641776
0$ git submodule add https://github.com/bitcoin-core/HWI.git HWI 1$ test/lint/lint-submodule.py 2These submodules were found, delete them: 3 2c757c8306be929714760ddba01d8ab6b0457d99 HWI (2.1.0-rc.1-4-g2c757c8306be929714760ddba01d8ab6b0457d99)
laanwj merged this on Apr 21, 2022laanwj closed this on Apr 21, 2022
Eunoia1729 deleted the branch on Apr 21, 2022sidhujag referenced this in commit 57d8585eac on Apr 22, 2022DrahtBot locked this on Apr 21, 2023
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 21:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me - Without