Skip to content

Commit

Permalink
[antlir2][image_test] disable static listing for cpp at macro layer
Browse files Browse the repository at this point in the history
Summary:
This doesn't currently work. It requires a bit of a rethink about how we pass
args to the test runner to support both methods so for now just turn it off at
the macro layer to unblock antlir2 migration

Test Plan:
```
❯ buck2 test fbcode//antlir/antlir2/testing/tests:test-cpp fbcode//antlir/antlir2/testing/tests:test-cpp-booted
Buck UI: https://www.internalfb.com/buck2/adb4335c-960d-4f13-aa6d-36cf92d277c3
Test UI: https://www.internalfb.com/intern/testinfra/testrun/15199648752777346
Note:    Using experimental modern dice
Network: Up: 435B  Down: 1.3MiB  (reSessionID-ccf3a0f2-4822-4a08-98da-be465aaecff2)
Jobs completed: 43. Time elapsed: 10.9s.
Cache hits: 100%. Commands: 5 (cached: 5, remote: 0, local: 0)
Tests finished: Pass 4. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Reviewed By: epilatow

Differential Revision: D51262590

fbshipit-source-id: 62713c13537037eb0901c80ba9554f5cd2a3f59c
  • Loading branch information
vmagro authored and facebook-github-bot committed Nov 13, 2023
1 parent 5431469 commit c3d2a1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion antlir/antlir2/testing/image_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _impl(ctx: AnalysisContext) -> list[Provider]:
cmd_args(boot_requires_units, format = "--requires-unit={}") if ctx.attrs.boot else cmd_args(),
cmd_args(boot_after_units, format = "--after-unit={}") if ctx.attrs.boot else cmd_args(),
cmd_args(boot_wants_units, format = "--wants-unit={}") if ctx.attrs.boot else cmd_args(),
cmd_args(["{}={}".format(k, v) for k, v in ctx.attrs.test[ExternalRunnerTestInfo].env.items()], format = "--setenv={}"),
cmd_args(ctx.attrs.test[ExternalRunnerTestInfo].env.keys(), format = "--pass-env={}"),
cmd_args(mounts, format = "--mounts={}"),
cmd_args(str(ctx.attrs.allocate_loop_devices), format = "--allocate-loop-devices={}"),
ctx.attrs.test[ExternalRunnerTestInfo].test_type,
Expand Down Expand Up @@ -191,6 +191,7 @@ def _implicit_image_test(
image_cpp_test = partial(
_implicit_image_test,
cpp_unittest,
supports_static_listing = False,
_add_outer_labels = ["tpx:optout-test-result-output-spec"],
)

Expand Down
9 changes: 9 additions & 0 deletions antlir/antlir2/testing/image_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ struct Args {
/// Set these env vars in the test environment
setenv: Vec<KvPair>,
#[clap(long)]
/// Set these env vars in the test environment based on what is present in the parent
pass_env: Vec<String>,
#[clap(long)]
/// Mounts required by the layer-under-test
mounts: JsonFile<BTreeSet<Mount>>,
#[clap(long)]
Expand Down Expand Up @@ -113,6 +116,12 @@ fn main() -> Result<()> {
setenv.insert(key, val.into());
}
}
for key in args.pass_env {
let var =
std::env::var_os(&key).with_context(|| format!("--pass-env var '{key}' missing"))?;

setenv.insert(key, var);
}
if let Some(rust_log) = std::env::var_os("RUST_LOG") {
setenv.insert("RUST_LOG".into(), rust_log);
}
Expand Down
1 change: 0 additions & 1 deletion antlir/antlir2/testing/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ image.layer(
test_variants(
srcs = ["test.cpp"],
lang = "cpp",
supports_static_listing = False,
test_rule = image_cpp_test,
)

Expand Down

0 comments on commit c3d2a1e

Please sign in to comment.