fix(parsers/c): codeql build-mode-none, optional-stage success, exclude orchestrators from pytest#91
Open
gadievron wants to merge 1 commit into
Open
Conversation
…de orchestrators from pytest Three defects surfaced via parsers/c/test_pipeline.py (the C pipeline orchestrator): 1. CodeQL build mode: `codeql database create` for cpp omitted --build-mode=none, so CodeQL defaulted to autobuild and silently degraded (dropping findings) on the no-build / extracted-source repos this pipeline runs on. Pass --build-mode=none. 2. Optional-stage success: overall success ANDed over ALL recorded stages, but the optional stages (CodeQL analysis/filter, reachability filter, context enhancer, exploitable filter) write success=False when they fail or are skipped -- so an optional-stage failure forced a spurious pipeline failure (exit 1). Introduce OPTIONAL_STAGES + a _compute_success() that requires only the non-optional stages. (Cross-parser family: the same all_success conjunction exists in the go/php/ruby/javascript pipelines -- separate units, not widened here.) 3. pytest collection collision: the six parsers/<lang>/test_pipeline.py files are CLI pipeline ORCHESTRATORS, not pytest tests, but share a basename, so `pytest parsers/` fails with import-file-mismatch. __init__.py does not fix it (their bare local imports -- `from repository_scanner import ...` -- make them un-importable as package modules; adding __init__.py merely moves the collision). Add a root conftest.py that excludes them from collection (collect_ignore_glob), which is correct since they are not tests. The canonical suite is unaffected (pytest.ini already scopes testpaths = tests). Scope: c-specific for #1 (go's codeql create may need its own --build-mode -- separate unit) and #2 (the all_success family is fixed per-parser); #3 is repo-wide (the conftest excludes all six orchestrators). function_extractor / other parsers unchanged. Tests: tests/test_c_pipeline.py -- (1) source-read that the C codeql create cmd passes --build-mode=none; (2) behavioral _compute_success() ignores optional-stage failures but fails on a required-stage failure (loaded via a CONTAINED importlib import that pops the polluting sibling-parser modules in a finally, since c/test_pipeline.py does bare local imports); (3) the root conftest excludes the orchestrators. RED 3 failed (pre-fix) -> GREEN; ruff clean; full suite 179 passed, 63 skipped, 0 failed; `pytest parsers/ --co` now collects cleanly (was import-file-mismatch). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Three defects surfaced via parsers/c/test_pipeline.py (the C pipeline orchestrator):
CodeQL build mode:
codeql database createfor cpp omitted --build-mode=none, so CodeQL defaultedto autobuild and silently degraded (dropping findings) on the no-build / extracted-source repos this
pipeline runs on. Pass --build-mode=none.
Optional-stage success: overall success ANDed over ALL recorded stages, but the optional stages
(CodeQL analysis/filter, reachability filter, context enhancer, exploitable filter) write
success=False when they fail or are skipped -- so an optional-stage failure forced a spurious
pipeline failure (exit 1). Introduce OPTIONAL_STAGES + a _compute_success() that requires only the
non-optional stages. (Cross-parser family: the same all_success conjunction exists in the
go/php/ruby/javascript pipelines -- separate units, not widened here.)
pytest collection collision: the six parsers//test_pipeline.py files are CLI pipeline
ORCHESTRATORS, not pytest tests, but share a basename, so
pytest parsers/fails withimport-file-mismatch. init.py does not fix it (their bare local imports --
from repository_scanner import ...-- make them un-importable as package modules; adding init.pymerely moves the collision). Add a root conftest.py that excludes them from collection
(collect_ignore_glob), which is correct since they are not tests. The canonical suite is unaffected
(pytest.ini already scopes testpaths = tests).
Scope: c-specific for #1 (go's codeql create may need its own --build-mode -- separate unit) and #2 (the
all_success family is fixed per-parser); #3 is repo-wide (the conftest excludes all six orchestrators).
function_extractor / other parsers unchanged.
Tests: tests/test_c_pipeline.py -- (1) source-read that the C codeql create cmd passes --build-mode=none;
(2) behavioral _compute_success() ignores optional-stage failures but fails on a required-stage failure
(loaded via a CONTAINED importlib import that pops the polluting sibling-parser modules in a finally,
since c/test_pipeline.py does bare local imports); (3) the root conftest excludes the orchestrators.
RED 3 failed (pre-fix) -> GREEN; ruff clean; full suite 179 passed, 63 skipped, 0 failed;
pytest parsers/ --conow collects cleanly (was import-file-mismatch).Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com