Skip to content

Make the test suite use this repo's compiled helpers - #38

Merged
davidliwei merged 3 commits into
mainfrom
test/conftest-repo-helpers
Aug 31, 2026
Merged

Make the test suite use this repo's compiled helpers#38
davidliwei merged 3 commits into
mainfrom
test/conftest-repo-helpers

Conversation

@davidliwei

@davidliwei davidliwei commented Aug 31, 2026

Copy link
Copy Markdown
Owner

The suite invokes the bundled C++ helpers by bare name (RRA, mageckGSEA), so it exercises whichever build comes first on PATH. That is the right binary after pip install ., which compiles them and installs them alongside the package — but not during ordinary local development. An editable install never runs that build step, and a MAGeCK v1 package in the same environment ships commands with the same names.

The result is that the suite silently tests v1's binaries and reports failures against fixes that are present in this checkout. Nothing in the output points at the binary being the wrong one.

Measured

Same environment, same PATH, only the conftest differing:

without tests/conftest.py   ->  4 failed, 45 passed
with tests/conftest.py      ->  49 passed

The four are all mageckGSEA tests — test_pathway_gsea_end_to_end, test_gsea_skips_genes_absent_from_rank_file, test_gsea_degenerate_pathway_is_not_maximally_significant, test_gsea_skip_header_matches_headerless. They assert fixes this repo has and v1 does not; the -H one fails on a usage error, because v1 has no --skip_header flag at all.

The change

pytest_configure prepends rra/bin and gsea/bin to PATH, but only for helpers that actually exist there.

Verified the fallback explicitly: with both bin directories renamed away, the suite still collects and runs, falling back to the installed binaries. No crash, no collection error.

Preserving installed-helper coverage

The override applies in CI too, not just locally — pip install . runs make in the source tree, so the build outputs sit in rra/bin and gsea/bin alongside the copies data_files installs. (An earlier revision of this description claimed CI takes the fallback path; that was wrong, and Codex caught it.)

Left alone, that would mean the installed copies are never exercised, so a regression in helper installation could pass CI even though an installed MAGeCK2 cannot find its helpers — the exact failure 0.2.0 fixed. Measured, with the installed helpers removed and the source tree intact:

conftest without this guard  ->  49 passed   (broken install ships green)
no conftest at all           ->   8 failed
with the guard               ->   2 failed

So conftest publishes the pre-override PATH as MAGECK2_INSTALLED_PATH, and the two tests asserting the helpers are installed resolve against it. The rest of the suite still tests this checkout's build. This also names the failure better than the pre-conftest baseline: a broken install used to surface as eight GSEA assertion failures naming nothing relevant, and now says compiled RRA binary not installed onto PATH.

Why now

This is a release blocker for 0.3.0 in practice: anyone verifying the tag from a fresh clone under an editable install sees four failures that have nothing to do with the code. I have hit it in every session on this repo.

The commit is unchanged from the one authored on Aug 4; it was branched off an older main and never pushed, so this is a cherry-pick onto current main rather than a merge of the stale branch — merging that branch as-is would have deleted ~800 lines of tests added since.

davidliwei and others added 2 commits August 31, 2026 11:35
The suite shells out to the bundled C++ helpers by bare name (RRA,
mageckGSEA), so it exercises whichever build comes first on PATH. That is the
right binary after `pip install .`, which compiles them via BuildWithHelpers and
installs them alongside the package -- but not during ordinary local
development. An editable install never runs that build step, and a MAGeCK v1
package in the same environment ships commands with the *same names*.

The result is that the suite silently tests v1's binaries. Locally that surfaced
as four mageckGSEA failures asserting fixes that are present in this checkout:
the absent-gene and degenerate-pathway tests got v1's answers, and the -H test
failed on a usage error because v1 has no --skip_header flag at all. Nothing in
the output points at the binary being the wrong one.

Add a conftest that puts rra/bin and gsea/bin first on PATH when the helpers
have been built there, so the tests always describe this checkout. When they
have not been built it changes nothing and the installed binaries are used, so
CI behaviour is unaffected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T16:32:45.085712Z 6aba9ff Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a82118e57

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/conftest.py
Comment on lines +37 to +38
if prefix:
os.environ["PATH"] = os.pathsep.join(prefix + [os.environ.get("PATH", "")])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve installed-helper coverage in CI

In the CI workflow, pip install .[test] runs BuildWithHelpers, whose make calls leave both executables in these source-tree directories; this hook therefore always prepends those build outputs before pytest -v. Consequently the smoke tests no longer exercise the copies installed through data_files, so a regression in helper installation, destination, or permissions can pass CI even though an installed MAGeCK2 cannot find or execute its helpers. Limit this override to the editable/local-development case or retain a CI test that uses the unmodified installation PATH.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 6aba9ff. You were right on both the mechanism and the consequence.

Verified the mechanism first — pip install .[test] into a fresh venv leaves the binaries in both places:

source tree:  rra/bin/RRA, gsea/bin/mageckGSEA   (make output)
venv:         .venv/bin/RRA, .venv/bin/mageckGSEA (data_files copy)

So the fallback my PR description claimed CI relies on never fires. That description was wrong; I've corrected it.

Then measured the coverage loss by simulating a data_files regression — installed helpers removed, source tree intact, venv built the way CI builds one:

with the conftest as submitted   ->  49 passed   (a broken release ships green)
with no conftest at all          ->   8 failed
after this fix                   ->   2 failed

The 49-passed row is exactly your point, and it would have masked a regression of the bug 0.2.0 fixed.

The fix keeps both coverages rather than dropping the override. conftest now publishes the pre-override PATH as MAGECK2_INSTALLED_PATH, and the two tests that assert the helpers are installedtest_rra_binary_on_path, test_mageckgsea_binary_on_path — resolve against it. The rest of the suite still tests the checkout's own build, which is the point of the override.

I preferred this to limiting the override to editable installs: "am I editable?" is awkward to detect reliably, and the installation contract deserves an explicit assertion rather than being implied by whichever binary happened to be found.

A side benefit — this reports the failure better than the pre-conftest baseline did. A broken install used to surface as eight GSEA assertion failures naming nothing relevant; it now says compiled RRA binary not installed onto PATH.

Verified across all three scenarios: good install 49 pass, broken install 2 fail (named), local editable install with v1 helpers in the environment 49 pass.

The PATH override applies in CI as well as locally: pip install . runs
make in the source tree, so the build outputs sit in rra/bin and
gsea/bin alongside the copies data_files installs. Prepending them meant
the installed copies were never exercised, and a regression in helper
installation could pass CI even though an installed MAGeCK2 could not
find its helpers -- the exact failure 0.2.0 fixed.

Measured on a venv built the way CI builds one, with the installed
helpers removed and the source tree left intact:

  before this commit   49 passed   (broken install ships green)
  after                2 failed    test_rra_binary_on_path,
                                   test_mageckgsea_binary_on_path

conftest now publishes the pre-override PATH as MAGECK2_INSTALLED_PATH,
and the two tests that assert the helpers are installed look there. The
rest of the suite still tests this checkout's own build, which is the
point of the override.

This also reports the failure better than before the conftest existed: a
broken install used to surface as eight GSEA assertion failures that
named nothing relevant, and now names the missing binary directly.

Reported by Codex review on #38.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidliwei

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 6aba9ff720

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@davidliwei
davidliwei merged commit 3616dd1 into main Aug 31, 2026
6 checks passed
@davidliwei
davidliwei deleted the test/conftest-repo-helpers branch August 31, 2026 22:00
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