test: narrow check_soldb except clause in lit.cfg.py#145
Open
mazurroman wants to merge 1 commit into
Open
Conversation
The previous 'except:' caught everything — including KeyboardInterrupt and SystemExit — so hitting Ctrl-C during lit startup could be silently swallowed and the function would still report 'soldb not available'. Narrow the handler to OSError (binary missing, permission denied) and subprocess.SubprocessError (non-zero exit from --help). Lift the soldb_path check above the try so we don't run a subprocess with an empty argv when soldb_path is None, and keep the behavior the same: return False when soldb can't be invoked, True when --help succeeds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
check_soldbintest/lit.cfg.pyused a bareexcept:which caught everything — includingKeyboardInterruptandSystemExit. Hitting Ctrl-C during lit startup could be silently swallowed, and any unexpected exception would also be hidden.Narrow the handler to the exceptions that are actually expected from
subprocess.run:OSError— binary missing, permission denied, etc.subprocess.SubprocessError— non-zero exit from--help(viacheck=True)Also lifted the
soldb_pathtruthiness check above the try so we don't end up running a subprocess withargv = ['', '--help']whensoldb_pathis None.Test plan
python3 -c "import ast; ast.parse(open('test/lit.cfg.py').read())"— parses clean.Falsewhen soldb can't be invoked,Truewhen--helpsucceeds.