Skip to content

test: narrow check_soldb except clause in lit.cfg.py#145

Open
mazurroman wants to merge 1 commit into
mainfrom
rm/lit-cfg-narrow-except
Open

test: narrow check_soldb except clause in lit.cfg.py#145
mazurroman wants to merge 1 commit into
mainfrom
rm/lit-cfg-narrow-except

Conversation

@mazurroman

Copy link
Copy Markdown
Member

Summary

check_soldb in test/lit.cfg.py used a bare except: which caught everything — including KeyboardInterrupt and SystemExit. 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 (via check=True)

Also lifted the soldb_path truthiness check above the try so we don't end up running a subprocess with argv = ['', '--help'] when soldb_path is None.

Test plan

  • python3 -c "import ast; ast.parse(open('test/lit.cfg.py').read())" — parses clean.
  • Behavior preserved: False when soldb can't be invoked, True when --help succeeds.
  • Ctrl-C and other interpreter-shutdown signals now propagate as intended.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant