Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 5 additions & 68 deletions .sync/rust/Makefiles/Makefile-patina-dxe-core-qemu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -198,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
Expand Down
5 changes: 5 additions & 0 deletions .sync/rust/Makefiles/Makefile-patina-readiness-tool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Loading