From 8aad22ded23eb30f287a1dd072474a000a0d8327 Mon Sep 17 00:00:00 2001 From: Chiio Tut Date: Fri, 13 Oct 2023 13:41:19 -0700 Subject: [PATCH] Revert D50194750: [antlir2][migration] add antlir2 only mode to PACKAGE files Test Plan: revert-hammer Differential Revision: D50194750 Original commit changeset: e5c73064bc69 Original Phabricator Diff: D50194750 fbshipit-source-id: 29837f455ea5587ed0a3785fe53e87963201f1e8 --- antlir/bzl/antlir2_migration.bzl | 11 +---- antlir/bzl/antlir2_shim.bzl | 58 ++---------------------- antlir/bzl/genrule/extractor/extract.bzl | 35 +++++++------- antlir/bzl/image/feature/new.bzl | 20 ++++---- antlir/bzl/image/package/new.bzl | 40 ++++++++-------- antlir/bzl/image_cpp_unittest.bzl | 33 ++++++-------- antlir/bzl/image_genrule_layer.bzl | 36 +++++++-------- antlir/bzl/image_layer.bzl | 38 ++++++++-------- antlir/bzl/image_layer_alias.bzl | 23 ++++------ antlir/bzl/image_layer_from_package.bzl | 39 ++++------------ antlir/bzl/image_python_unittest.bzl | 34 ++++++-------- antlir/bzl/image_rust_unittest.bzl | 40 ++++++++-------- 12 files changed, 150 insertions(+), 257 deletions(-) diff --git a/antlir/bzl/antlir2_migration.bzl b/antlir/bzl/antlir2_migration.bzl index 17626dca93e..59db6e8c8e5 100644 --- a/antlir/bzl/antlir2_migration.bzl +++ b/antlir/bzl/antlir2_migration.bzl @@ -5,16 +5,7 @@ load("//antlir/bzl:types.bzl", "types") -mode_t = enum( - # no antlir2 shadowing by default - "none", - # shadow all layers, features, packages and tests with antlir2 definitions by default - "shadow", - # transparently upgrade all targets to antlir2. - # antlir1 feature rules are kept around since they don't have conflicting - # names with the porcelain antlir2 targets - "upgrade", -) +mode_t = enum("none", "shadow") def _configure_package(*, mode: str | mode_t): if types.is_string(mode): diff --git a/antlir/bzl/antlir2_shim.bzl b/antlir/bzl/antlir2_shim.bzl index 29caa540f12..c27c04cd370 100644 --- a/antlir/bzl/antlir2_shim.bzl +++ b/antlir/bzl/antlir2_shim.bzl @@ -7,7 +7,6 @@ load("//antlir/bzl:build_defs.bzl", "export_file") load(":antlir2_migration.bzl?v2_only", "antlir2_migration") load(":build_defs.bzl", "is_buck2", "python_unittest") load(":flavor.shape.bzl", "flavor_t") -load(":structs.bzl", "structs") load(":target_helpers.bzl", "antlir_dep") load(":types.bzl", "types") @@ -44,18 +43,6 @@ def _should_shadow(antlir2: str | bool | None) -> bool: return antlir2 == antlir2_setting("yes") -def _should_upgrade() -> bool: - if not is_buck2(): - return False - package_mode = antlir2_migration.get_mode() - return package_mode == antlir2_migration.mode_t("upgrade") - -# features are currently left with an antlir1 definition because it does not -# conflict and features often have cross-package dependencies. -# when migration closer to complete, this can use the same logic as above -def _should_upgrade_feature(*args, **kwargs): - return False - def _fake_buck1_layer(name): # export a target of the same name to make td happy _fake_buck1_target(name = name + ".antlir2") @@ -80,52 +67,13 @@ def _fake_buck1_target(name): antlir_rule = "user-internal", ) -def _upgrade_or_shadow( - *, - name: str, - antlir2: str | bool | None, - fn, - fake_buck1: struct, - **kwargs) -> str | None: - if _should_upgrade(): - fn(name = name, **kwargs) - return "upgrade" - if _should_shadow(antlir2 = antlir2): - fn(name = name + ".antlir2", **kwargs) - if not is_buck2(): - fake = structs.to_dict(fake_buck1) - fake_fn = fake.pop("fn") - fake_fn(**fake) - return None - -def _upgrade_or_shadow_feature( - *, - name: str, - antlir2: str | bool | None, - fn, - **kwargs) -> str | None: - if _should_upgrade(): - fn(name = name, **kwargs) - if _should_shadow(antlir2 = antlir2): - fn(name = name, **kwargs) - return None - -def _getattr_buck2(val, attr): - if is_buck2(): - return getattr(val, attr) - else: - return None - antlir2_shim = struct( fake_buck1_layer = _fake_buck1_layer, fake_buck1_feature = _fake_buck1_target, fake_buck1_target = _fake_buck1_target, fake_buck1_test = _fake_buck1_test, - should_upgrade_layer = _should_upgrade, + should_shadow_feature = _should_shadow, should_shadow_layer = _should_shadow, - upgrade_or_shadow_layer = _upgrade_or_shadow, - upgrade_or_shadow_feature = _upgrade_or_shadow_feature, - upgrade_or_shadow_test = _upgrade_or_shadow, - upgrade_or_shadow_package = _upgrade_or_shadow, - getattr_buck2 = _getattr_buck2, + should_shadow_test = _should_shadow, + should_shadow_package = _should_shadow, ) diff --git a/antlir/bzl/genrule/extractor/extract.bzl b/antlir/bzl/genrule/extractor/extract.bzl index 7aefcae770c..9fe687a56d8 100644 --- a/antlir/bzl/genrule/extractor/extract.bzl +++ b/antlir/bzl/genrule/extractor/extract.bzl @@ -62,6 +62,7 @@ exported by a parent layer which also includes an extract.extract feature. load("@bazel_skylib//lib:paths.bzl", "paths") load("//antlir/antlir2/bzl/feature:defs.bzl?v2_only", antlir2_feature = "feature") load("//antlir/bzl:antlir2_shim.bzl", "antlir2_shim") +load("//antlir/bzl:build_defs.bzl", "is_buck2") load("//antlir/bzl:constants.bzl", "REPO_CFG") load("//antlir/bzl:image.bzl", "image") load("//antlir/bzl:sha256.bzl", "sha256_b64") @@ -88,25 +89,6 @@ def _extract( binaries = binaries or [] normalized_source = normalize_target(source) name = sha256_b64(normalized_source + " ".join(binaries) + dest) - - if antlir2_shim.upgrade_or_shadow_feature( - name = name, - antlir2 = antlir2, - fn = antlir2_feature.new, - features = [ - antlir2_feature.extract_from_layer( - binaries = binaries, - layer = source + ".antlir2", - ), - ], - visibility = [], - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_feature, - name = name, - ), - ) == "upgrade": - return normalize_target(":" + name) - base_extract_layer = "image-extract-setup--{}".format(name) image.layer( name = base_extract_layer, @@ -169,6 +151,21 @@ cp "${{source_layer_path}}{output_dir}/feature.json" "$OUT" deps = ["//antlir/bzl/genrule/extractor:extract"], ) + if antlir2_shim.should_shadow_feature(antlir2): + if is_buck2(): + antlir2_feature.new( + name = name, + features = [ + antlir2_feature.extract_from_layer( + binaries = binaries, + layer = source + ".antlir2", + ), + ], + visibility = [], + ) + else: + antlir2_shim.fake_buck1_feature(name) + return normalize_target(":" + name) # Helper to create a layer to use as 'source' for 'extract.extract', that diff --git a/antlir/bzl/image/feature/new.bzl b/antlir/bzl/image/feature/new.bzl index d6717289473..a64257e59eb 100644 --- a/antlir/bzl/image/feature/new.bzl +++ b/antlir/bzl/image/feature/new.bzl @@ -384,14 +384,12 @@ def feature_new( # If we're on buck2, instantiate an antlir2 feature rule. This does not # conflict with the feature above, since antlir1 adds a "private" suffix to # all feature targets - antlir2_shim.upgrade_or_shadow_feature( - antlir2 = antlir2, - name = name, - fn = antlir2_feature.new, - features = [f if types.is_string(f) else f.antlir2_feature for f in flatten.flatten(features)], - visibility = get_visibility(visibility), - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_feature, - name = name, - ), - ) + if antlir2_shim.should_shadow_layer(antlir2): + if is_buck2(): + antlir2_feature.new( + name, + features = [f if types.is_string(f) else f.antlir2_feature for f in flatten.flatten(features)], + visibility = get_visibility(visibility), + ) + else: + antlir2_shim.fake_buck1_feature(name) diff --git a/antlir/bzl/image/package/new.bzl b/antlir/bzl/image/package/new.bzl index ec9d1370ddb..dd8d575539b 100644 --- a/antlir/bzl/image/package/new.bzl +++ b/antlir/bzl/image/package/new.bzl @@ -12,11 +12,10 @@ load("@bazel_skylib//lib:shell.bzl", "shell") load("//antlir/antlir2/bzl/package:defs.bzl?v2_only", antlir2_package = "package") load("//antlir/bzl:antlir2_shim.bzl", "antlir2_shim") load("//antlir/bzl:bash.bzl", "wrap_bash_build_in_common_boilerplate") -load("//antlir/bzl:build_defs.bzl", "buck_genrule", "get_visibility") +load("//antlir/bzl:build_defs.bzl", "buck_genrule", "get_visibility", "is_buck2") load("//antlir/bzl:loopback_opts.bzl", "normalize_loopback_opts") load("//antlir/bzl:query.bzl", "layer_deps_query") load("//antlir/bzl:shape.bzl", "shape") -load("//antlir/bzl:structs.bzl", "structs") load("//antlir/bzl:target_helpers.bzl", "antlir_dep", "targets_and_outputs_arg_list") _IMAGE_PACKAGE = "image_package" @@ -56,27 +55,24 @@ def package_new( if format in _SENDSTREAM_FORMATS and not subvol_name: subvol_name = "volume" - if shape.is_any_instance(loopback_opts): - opts_kwargs = shape.as_dict_shallow(loopback_opts) - elif loopback_opts: - opts_kwargs = structs.to_dict(loopback_opts) - else: - opts_kwargs = {} + if antlir2_shim.should_shadow_package(antlir2 = antlir2): + if is_buck2(): + antlir2_opts = shape.as_dict_shallow(loopback_opts) if loopback_opts else None + opts_kwargs = { + "opts": antlir2_opts, + } if antlir2_opts else {} - if antlir2_shim.upgrade_or_shadow_package( - antlir2 = antlir2, - name = name, - fn = antlir2_package.backward_compatible_new, - layer = layer + ".antlir2", - format = format, - visibility = visibility, - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_target, - name = name + ".antlir2", - ), - **opts_kwargs - ) == "upgrade": - return + antlir2_package.backward_compatible_new( + name = name + ".antlir2", + layer = layer + ".antlir2", + format = format, + visibility = visibility, + **opts_kwargs + ) + else: + antlir2_shim.fake_buck1_target( + name = name + ".antlir2", + ) loopback_opts = normalize_loopback_opts(loopback_opts) diff --git a/antlir/bzl/image_cpp_unittest.bzl b/antlir/bzl/image_cpp_unittest.bzl index bd19498a9b0..fd1a5cb1f57 100644 --- a/antlir/bzl/image_cpp_unittest.bzl +++ b/antlir/bzl/image_cpp_unittest.bzl @@ -5,8 +5,7 @@ load("//antlir/antlir2/testing:image_test.bzl?v2_only", antlir2_image_cpp_test = "image_cpp_test") load(":antlir2_shim.bzl", "antlir2_shim") -load(":build_defs.bzl", "buck_sh_test", "cpp_unittest", "python_binary") -load(":container_opts.bzl", "normalize_container_opts") +load(":build_defs.bzl", "buck_sh_test", "cpp_unittest", "is_buck2", "python_binary") load(":image_unittest_helpers.bzl", helpers = "image_unittest_helpers") def image_cpp_unittest( @@ -20,23 +19,6 @@ def image_cpp_unittest( antlir2 = None, **cpp_unittest_kwargs): visibility = visibility or [] - container_opts = normalize_container_opts(container_opts) - - if antlir2_shim.upgrade_or_shadow_test( - antlir2 = antlir2, - fn = antlir2_image_cpp_test, - name = name, - layer = layer + ".antlir2", - boot = boot, - run_as_user = run_as_user, - boot_requires_units = ["dbus.socket"] if (boot and container_opts and container_opts.boot_await_dbus) else [], - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_test, - name = name, - ), - **cpp_unittest_kwargs - ) == "upgrade": - return supports_static_listing = cpp_unittest_kwargs.pop("supports_static_listing", False) wrapper_props = helpers.nspawn_wrapper_properties( @@ -102,3 +84,16 @@ def image_cpp_unittest( visibility = visibility, **wrapper_props.outer_test_kwargs ) + + if antlir2_shim.should_shadow_test(antlir2): + if is_buck2(): + antlir2_image_cpp_test( + name = name + ".antlir2", + layer = layer + ".antlir2", + boot = boot, + run_as_user = run_as_user, + boot_requires_units = ["dbus.socket"] if (boot and wrapper_props.container_opts.boot_await_dbus) else [], + **cpp_unittest_kwargs + ) + else: + antlir2_shim.fake_buck1_test(name = name) diff --git a/antlir/bzl/image_genrule_layer.bzl b/antlir/bzl/image_genrule_layer.bzl index 2d65ac4a282..38fb268317a 100644 --- a/antlir/bzl/image_genrule_layer.bzl +++ b/antlir/bzl/image_genrule_layer.bzl @@ -109,26 +109,22 @@ Optional arguments: - See the `_image_layer_impl` signature (in `image_layer_utils.bzl`) for supported, but less commonly used, kwargs. """ - antlir2 = image_layer_kwargs.pop("antlir2", None) - if antlir2_shim.upgrade_or_shadow_layer( - antlir2 = antlir2, - name = name, - fn = antlir2_shim.getattr_buck2(antlir2_image, "layer"), - parent_layer = parent_layer + ".antlir2" if parent_layer else None, - flavor = flavor, - features = [ - antlir2_feature.genrule( - cmd = cmd, - user = user, - ), - ], - implicit_antlir2 = True, - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_layer, - name = name, - ), - ) == "upgrade": - return + if antlir2_shim.should_shadow_layer(image_layer_kwargs.pop("antlir2", None)): + if is_buck2(): + antlir2_image.layer( + name = name + ".antlir2", + parent_layer = parent_layer + ".antlir2" if parent_layer else None, + flavor = flavor, + features = [ + antlir2_feature.genrule( + cmd = cmd, + user = user, + ), + ], + implicit_antlir2 = True, + ) + else: + antlir2_shim.fake_buck1_layer(name = name) flavor = flavor_to_struct(flavor) container_opts = normalize_container_opts(container_opts) diff --git a/antlir/bzl/image_layer.bzl b/antlir/bzl/image_layer.bzl index 8aa794b562f..e8f7031bdfd 100644 --- a/antlir/bzl/image_layer.bzl +++ b/antlir/bzl/image_layer.bzl @@ -143,25 +143,25 @@ def image_layer( [docs](/docs/tutorials/helper-buck-targets#imagelayer) for the list of possible helpers, their respective behaviours, and how to invoke them. """ - if antlir2_shim.upgrade_or_shadow_layer( - name = name, - antlir2 = image_layer_kwargs.pop("antlir2", None), - fn = antlir2_shim.getattr_buck2(antlir2_image, "layer"), - flavor = flavor, - parent_layer = parent_layer + ".antlir2" if parent_layer else None, - features = (features or []) + antlir2_features, - implicit_antlir2 = True, - compatible_with = antlir2_compatible_with, - visibility = get_visibility(image_layer_kwargs.get("visibility")), - # Antlir1 provisioning images explicitly install package-devel stub, we need to allow them here. - dnf_excluded_rpms = ["aziot-identity-service"], - default_mountpoint = antlir2_default_mountpoint, - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_layer, - name = name, - ), - ) == "upgrade": - return + if antlir2_shim.should_shadow_layer(image_layer_kwargs.pop("antlir2", None)): + if is_buck2(): + if not antlir2_allow_ignored_flavor_config_override and flavor_config_override: + fail("antlir2 does not support flavor_config_override: {}".format(flavor_config_override)) + + antlir2_image.layer( + name = name + ".antlir2", + flavor = flavor, + parent_layer = parent_layer + ".antlir2" if parent_layer else None, + features = (features or []) + antlir2_features, + implicit_antlir2 = True, + compatible_with = antlir2_compatible_with, + visibility = get_visibility(image_layer_kwargs.get("visibility")), + # Antlir1 provisioning images explicitly install package-devel stub, we need to allow them here. + dnf_excluded_rpms = ["aziot-identity-service"], + default_mountpoint = antlir2_default_mountpoint, + ) + else: + antlir2_shim.fake_buck1_layer(name = name) flavor = flavor_to_struct(flavor) if not flavor and parent_layer: diff --git a/antlir/bzl/image_layer_alias.bzl b/antlir/bzl/image_layer_alias.bzl index f323407f43c..1aa626b388f 100644 --- a/antlir/bzl/image_layer_alias.bzl +++ b/antlir/bzl/image_layer_alias.bzl @@ -3,7 +3,7 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -load("//antlir/bzl:build_defs.bzl", "alias", "buck_genrule") +load("//antlir/bzl:build_defs.bzl", "alias", "buck_genrule", "is_buck2") load("//antlir/bzl/image/feature:new.bzl", "PRIVATE_DO_NOT_USE_feature_target_name") load(":antlir2_shim.bzl", "antlir2_shim") load(":constants.bzl", "BZL_CONST") @@ -71,15 +71,12 @@ def image_layer_alias(name, layer, runtime = None, visibility = None, antlir2 = add_runtime_targets(name, runtime) - if antlir2_shim.upgrade_or_shadow_layer( - antlir2 = antlir2, - name = name, - fn = alias, - actual = layer, - antlir_rule = "user-internal", - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_target, - name = name, - ), - ) == "upgrade": - return + if antlir2_shim.should_shadow_layer(antlir2): + if is_buck2(): + alias( + name = name + ".antlir2", + actual = layer + ".antlir2", + antlir_rule = "user-internal", + ) + else: + antlir2_shim.fake_buck1_target(name + ".antlir2") diff --git a/antlir/bzl/image_layer_from_package.bzl b/antlir/bzl/image_layer_from_package.bzl index c8d97e8367c..1a49e430cdb 100644 --- a/antlir/bzl/image_layer_from_package.bzl +++ b/antlir/bzl/image_layer_from_package.bzl @@ -33,9 +33,7 @@ def image_layer_from_package_helper( antlir2_src): flavor = flavor_to_struct(flavor) target = normalize_target(":" + name) - antlir2 = image_layer_kwargs.pop("antlir2", None) - antlir2_upgrade = antlir2_shim.should_upgrade_layer() - antlir2 = antlir2_shim.should_shadow_layer(antlir2) + antlir2 = antlir2_shim.should_shadow_layer(image_layer_kwargs.pop("antlir2", None)) # Do argument validation for bad_kwarg in ["parent_layer", "features"]: @@ -56,26 +54,18 @@ def image_layer_from_package_helper( fail("{}'s rc build was requested but `rc_layer` is unset!".format(target)) if use_rc_target(target = target) and rc_layer != None: - if antlir2_upgrade: + image_layer_alias( + name = name, + layer = rc_layer, + antlir2 = antlir2, + ) + if antlir2: alias( - name = name, + name = name + ".antlir2", antlir_rule = "user-internal", - layer = rc_layer, + layer = rc_layer + ".antlir2", visibility = get_visibility(image_layer_kwargs.get("visibility")), ) - else: - image_layer_alias( - name = name, - layer = rc_layer, - antlir2 = antlir2, - ) - if antlir2: - alias( - name = name + ".antlir2", - antlir_rule = "user-internal", - layer = rc_layer + ".antlir2", - visibility = get_visibility(image_layer_kwargs.get("visibility")), - ) else: _make_subvol_cmd, _deps_query = compile_image_features_fn( name = name, @@ -86,16 +76,7 @@ def image_layer_from_package_helper( parent_layer = None, ) - if antlir2_upgrade: - antlir2_image.prebuilt( - name = name, - src = antlir2_src, - flavor = antlir2_compat.from_antlir1_flavor(flavor), - format = format, - visibility = get_visibility(image_layer_kwargs.get("visibility")), - ) - return - elif antlir2: + if antlir2: if is_buck2(): antlir2_image.prebuilt( name = name + ".antlir2", diff --git a/antlir/bzl/image_python_unittest.bzl b/antlir/bzl/image_python_unittest.bzl index 4a356e23e9b..088c0a6d9df 100644 --- a/antlir/bzl/image_python_unittest.bzl +++ b/antlir/bzl/image_python_unittest.bzl @@ -5,8 +5,7 @@ load("//antlir/antlir2/testing:image_test.bzl?v2_only", antlir2_image_python_test = "image_python_test") load(":antlir2_shim.bzl", "antlir2_shim") -load(":build_defs.bzl", "add_test_framework_label", "python_unittest") -load(":container_opts.bzl", "normalize_container_opts") +load(":build_defs.bzl", "add_test_framework_label", "is_buck2", "python_unittest") load(":flavor.shape.bzl", "flavor_t") load(":image_unittest_helpers.bzl", helpers = "image_unittest_helpers") load(":types.bzl", "types") @@ -33,24 +32,6 @@ def image_python_unittest( antlir2 = None, **python_unittest_kwargs): visibility = visibility or [] - container_opts = normalize_container_opts(container_opts) - - if antlir2_shim.upgrade_or_shadow_test( - antlir2 = antlir2, - fn = antlir2_image_python_test, - name = name, - layer = layer + ".antlir2", - boot = boot, - run_as_user = run_as_user, - boot_requires_units = ["dbus.socket"] if (boot and container_opts and container_opts.boot_await_dbus) else [], - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_test, - name = name, - test = "python", - ), - **python_unittest_kwargs - ) == "upgrade": - return wrapper_props = helpers.nspawn_wrapper_properties( name = name, @@ -154,3 +135,16 @@ def image_python_unittest( supports_static_listing = False, **wrapper_props.outer_test_kwargs ) + + if antlir2_shim.should_shadow_test(antlir2): + if is_buck2(): + antlir2_image_python_test( + name = name + ".antlir2", + layer = layer + ".antlir2", + boot = boot, + run_as_user = run_as_user, + boot_requires_units = ["dbus.socket"] if (boot and wrapper_props.container_opts.boot_await_dbus) else [], + **python_unittest_kwargs + ) + else: + antlir2_shim.fake_buck1_test(name = name, test = "python") diff --git a/antlir/bzl/image_rust_unittest.bzl b/antlir/bzl/image_rust_unittest.bzl index 8d3eb86905b..8bd236ca888 100644 --- a/antlir/bzl/image_rust_unittest.bzl +++ b/antlir/bzl/image_rust_unittest.bzl @@ -5,8 +5,7 @@ load("//antlir/antlir2/testing:image_test.bzl?v2_only", antlir2_image_rust_test = "image_rust_test") load(":antlir2_shim.bzl", "antlir2_shim") -load(":build_defs.bzl", "buck_sh_test", "get_visibility", "python_binary", "rust_unittest") -load(":container_opts.bzl", "normalize_container_opts") +load(":build_defs.bzl", "buck_sh_test", "get_visibility", "is_buck2", "python_binary", "rust_unittest") load(":image_unittest_helpers.bzl", helpers = "image_unittest_helpers") def image_rust_unittest( @@ -18,25 +17,9 @@ def image_rust_unittest( container_opts = None, visibility = None, antlir2 = None, + antlir2_requires_units = None, + antlir2_after_units = None, **rust_unittest_kwargs): - container_opts = normalize_container_opts(container_opts) - if antlir2_shim.upgrade_or_shadow_test( - antlir2 = antlir2, - fn = antlir2_image_rust_test, - name = name, - layer = layer + ".antlir2", - boot = boot, - run_as_user = run_as_user, - boot_requires_units = ["dbus.socket"] if (boot and container_opts and container_opts.boot_await_dbus) else [], - crate = rust_unittest_kwargs.pop("crate", name + "_unittest"), - fake_buck1 = struct( - fn = antlir2_shim.fake_buck1_test, - name = name, - ), - **rust_unittest_kwargs - ) == "upgrade": - return - wrapper_props = helpers.nspawn_wrapper_properties( name = name, layer = layer, @@ -79,3 +62,20 @@ def image_rust_unittest( visibility = get_visibility(visibility), **wrapper_props.outer_test_kwargs ) + + if antlir2_shim.should_shadow_test(antlir2): + if is_buck2(): + antlir2_image_rust_test( + name = name + ".antlir2", + layer = layer + ".antlir2", + boot = boot, + run_as_user = run_as_user, + boot_requires_units = (( + ["dbus.socket"] if (boot and wrapper_props.container_opts.boot_await_dbus) else [] + ) + (antlir2_requires_units or [])) if (boot and wrapper_props.container_opts.boot_await_dbus) else antlir2_requires_units, + boot_after_units = antlir2_after_units, + crate = rust_unittest_kwargs.pop("crate", name + "_unittest"), + **rust_unittest_kwargs + ) + else: + antlir2_shim.fake_buck1_test(name = name)