From 28b3126ec0dbc1e093f2acf2c135a286b4460385 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Fri, 24 Jul 2026 10:31:32 -0400 Subject: [PATCH 1/2] .sync: Constrain `coverage_attribute` in DXE Core and Readiness makefiles Set `coverage_attribute` only when running coverage. Updates the patina-dxe-core-qemu and patina-readiness-tool makefiles to set the feature in their makefiles similar to other files. Signed-off-by: Michael Kubacki --- .sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml | 5 +++++ .sync/rust/Makefiles/Makefile-patina-readiness-tool.toml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml b/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml index 26c4ae0..5535738 100644 --- a/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml +++ b/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml @@ -175,6 +175,11 @@ args = ["test", "@@split(CARGO_MAKE_TASK_ARGS,;)"] description = "Run tests and collect coverage data without generating reports." install_crate = false clear = true +# `coverage_attribute` is deliberately excluded from the default allow-features in +# .cargo/config.toml so ungated `#[cfg_attr(coverage, coverage(off))]` fails to compile. Coverage runs set the +# `coverage` cfg (set by cargo-llvm-cov), which needs the feature, so re-add it here. +# Note: RUSTFLAGS replaces build.rustflags. +env = { RUSTFLAGS = "-Z allow-features=c_variadic,allocator_api,coverage_attribute" } command = "cargo" args = ["llvm-cov", "@@split(COV_FLAGS, )", "--no-report"] dependencies = ["individual-package-targets"] diff --git a/.sync/rust/Makefiles/Makefile-patina-readiness-tool.toml b/.sync/rust/Makefiles/Makefile-patina-readiness-tool.toml index f85a66f..9656680 100644 --- a/.sync/rust/Makefiles/Makefile-patina-readiness-tool.toml +++ b/.sync/rust/Makefiles/Makefile-patina-readiness-tool.toml @@ -211,6 +211,11 @@ args = ["llvm-cov", "clean", "--workspace"] description = "Run tests and collect coverage data without generating reports." install_crate = false clear = true +# `coverage_attribute` is deliberately excluded from the default allow-features in +# .cargo/config.toml so ungated `#[coverage(off)]` fails to compile. Coverage runs set the +# `coverage` cfg (set by cargo-llvm-cov), which needs the feature, so re-add it here. +# Note: RUSTFLAGS replaces build.rustflags. +env = { RUSTFLAGS = "-Z allow-features=c_variadic,allocator_api,coverage_attribute" } command = "cargo" args = ["llvm-cov", "--profile", "test", "--ignore-filename-regex", ".*test.*", "--no-report", "--doctests", "-p", "dxe_readiness_capture", "-p", "dxe_readiness_validator"] dependencies = ["llvm-cov-clean"] From 2dba3f8b1a6f1c773271bdd67225f72fd1356c6e Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Fri, 24 Jul 2026 10:34:53 -0400 Subject: [PATCH 2/2] Makefile-patina-dxe-core-qemu.toml: Drop the coverage-fail task This task currently fails because it expects a workspace with members. Even if that's accounted for, the repo does not emphasize testing coverage. The task is removed in this change to simplify the file. Signed-off-by: Michael Kubacki --- .../Makefile-patina-dxe-core-qemu.toml | 68 ------------------- 1 file changed, 68 deletions(-) diff --git a/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml b/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml index 5535738..88b6ff9 100644 --- a/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml +++ b/.sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml @@ -203,74 +203,6 @@ description = "Build and run all tests and calculate coverage (runs test once an dependencies = ["coverage-collect", "coverage-lcov", "coverage-html"] clear = true -[tasks.coverage-filter] -description = "Generates the coverage filter to ignore coverage data for other packages." -private = true -script_runner = "@duckscript" -script = ''' -package = get_env PACKAGE -members = get_env CARGO_MAKE_CRATE_WORKSPACE_MEMBERS - -1 = split ${members} , - -2 = array -for member in ${1} - if not contains ${member} ${package} - array_push ${2} ${member} - end - - -end - -joined = array_join ${2} "|" - -set_env PACKAGE_COVERAGE_FILTER ${joined} -release ${1} -release ${2} -release ${joined_args} -release ${joined} -''' - -[tasks.coverage-fail-package] -private = true -install_crate = false -description = """Generates Code coverage for $(PACKAGE) and fails the build if coverage is below 80%.""" -dependencies = ["coverage-filter"] -command = "cargo" -args = ["llvm-cov", "--package", "${PACKAGE}", "--fail-under-lines", "80", "--ignore-filename-regex", "${PACKAGE_COVERAGE_FILTER}"] - -[tasks.coverage-fail] -description = """Runs coverage on one or all packages and fails if coverage is below 80%. - -Examples: - `cargo make coverage-fail` - `cargo make coverage-fail patina_dxe_core` -""" -script_runner = "@duckscript" -script = ''' -1 = get_env CARGO_MAKE_CRATE_WORKSPACE_MEMBERS -2 = split ${1} , -3 = get_env CARGO_MAKE_TASK_ARGS - -if not is_empty ${3} - set_env PACKAGE ${3} - cm_run_task coverage-fail-package -else - for member in ${2} - 4 = split ${member} / - 5 = array_pop ${4} - set_env PACKAGE ${5} - cm_run_task coverage-fail-package - release ${4} - release ${5} - end -endif - -release ${1} -release ${2} -release ${3} -''' - [tasks.test-asan] description = "Run tests with AddressSanitizer enabled. Example `cargo make test-asan`. Use `cargo make test-asan --print-dll-path` to print the ASan runtime DLL directory." clear = true