ct: fix -dir and ERL_LIBS for app-provider compiled_suites#7
Open
sebastiw wants to merge 1 commit into
Open
Conversation
Two regressions in `private/ct.bzl::_impl`, both surfacing only when an `ErlangAppInfo`-providing target (e.g. a `:test_erlang_app` produced by `extract_app(test = True)`) is passed as `compiled_suites` rather than the bare `erlang_bytecode` outputs the `ct_suite` macro produces. ## 1. `-dir test` is bogus when the suite beam is not in `test/` 8faae61 ("Resurrect CI: ... -dir ebin -> -dir test") fixed the `ct_suite` macro path (its `erlang_bytecode("..._beam_files", dest = "test")` puts the suite at `test/<suite>.beam`) but hardcoded the arg. When `compiled_suites` is an `extract_app` target, the suite beam post-e70ed5a lives at `<target>/ebin/<suite>.beam` — no `test/` exists in the runfiles tree. `ct_run` aborts with Directory .../test is invalid Test run failed! Reason: {make_failed, [...]} Compute `-dir` from the package-relative dirnames of the `_SUITE.beam` entries in `compiled_suites`; fall back to `"test"` when none are found (defensive — `ct_run` would error on an empty `-dir` arg). Drop the now-redundant `-pa <dir>` for any path already covered by `-dir`. ## 2. ERL_LIBS missing the app under test and its prod deps 228b062 originally built ERL_LIBS via `flat_deps(ctx.attr.deps + ctx.attr.compiled_suites)`. 8faae61 narrowed that to `flat_deps(ctx.attr.deps)` because `compiled_suites` under the `ct_suite` macro are `erlang_bytecode` outputs and don't provide `ErlangAppInfo`, so `flat_deps`'s `dep[ErlangAppInfo]` access fails at analysis. That's correct for the macro path, but it stripped the transitive app closure that an `extract_app(test = True)` target contributes. Suites that rely on `application:ensure_all_started/1` of the app under test then fail `init_per_suite` because the app's prod deps are not in ERL_LIBS, e.g. {badmatch,{error,{some_dep,{"no such file or directory" ... Re-include only the `ErlangAppInfo`-providing entries of `compiled_suites` in the `flat_deps` call, leaving plain `.beam` targets alone. ## Validation - `cd test && bazelisk test //...` -> 13/13 PASS - `cd examples/umbrella && bazelisk test //...` -> 9/9 PASS (covers the `ct_suite` macro path via `umbrella_smoke_SUITE`). - Reproduced and fixed against a downstream consumer with `ct_test` targets of the form `ct_test(compiled_suites = [":test_erlang_app"], ...)`: before, every such target failed with the `Directory ... is invalid` error above (or, with #1 alone applied, `init_per_suite` crashed on the missing prod dep); after, they pass.
lixen-wg2
approved these changes
Jun 26, 2026
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.
Two regressions in
private/ct.bzl::_impl, both surfacing only when anErlangAppInfo-providing target (e.g. a:test_erlang_appproduced byextract_app(test = True)) is passed ascompiled_suitesrather than the bareerlang_bytecodeoutputs thect_suitemacro produces.1.
-dir testis bogus when the suite beam is not intest/8faae61 ("Resurrect CI: ... -dir ebin -> -dir test") fixed the
ct_suitemacro path (itserlang_bytecode("..._beam_files", dest = "test")puts the suite attest/<suite>.beam) but hardcoded the arg. Whencompiled_suitesis anextract_apptarget, the suite beam post-e70ed5a lives at<target>/ebin/<suite>.beam— notest/exists in the runfiles tree.ct_runaborts withCompute
-dirfrom the package-relative dirnames of the_SUITE.beamentries incompiled_suites; fall back to"test"when none are found (defensive —ct_runwould error on an empty-dirarg). Drop the now-redundant-pa <dir>for any path already covered by-dir.2. ERL_LIBS missing the app under test and its prod deps
228b062 originally built ERL_LIBS via
flat_deps(ctx.attr.deps + ctx.attr.compiled_suites). 8faae61 narrowed that toflat_deps(ctx.attr.deps)becausecompiled_suitesunder thect_suitemacro areerlang_bytecodeoutputs and don't provideErlangAppInfo, soflat_deps'sdep[ErlangAppInfo]access fails at analysis.That's correct for the macro path, but it stripped the transitive app closure that an
extract_app(test = True)target contributes. Suites that rely onapplication:ensure_all_started/1of the app under test then failinit_per_suitebecause the app's prod deps are not in ERL_LIBS, e.g.Re-include only the
ErlangAppInfo-providing entries ofcompiled_suitesin theflat_depscall, leaving plain.beamtargets alone.Validation
cd test && bazelisk test //...-> 13/13 PASScd examples/umbrella && bazelisk test //...-> 9/9 PASS(covers the
ct_suitemacro path viaumbrella_smoke_SUITE).ct_testtargets of the form
ct_test(compiled_suites = [":test_erlang_app"], ...):before, every such target failed with the
Directory ... is invaliderror above (or, with Bump golang.org/x/net from 0.17.0 to 0.23.0 in /test #1 alone applied,
init_per_suitecrashed onthe missing prod dep); after, they pass.