From f16e2261fc6a13bb5396291e62f735124fc71acf Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 2 May 2020 00:12:29 -0500 Subject: [PATCH] maint/build ~ improve `cargo make format` to include test formatting --- Makefile.toml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 1a696a6b6..275fcd2e9 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -113,6 +113,8 @@ description = "Format" category = "[project]" dependencies = [ "action-format", + "action-determine-tests", + "action-format-tests", ] [tasks.help] @@ -230,15 +232,34 @@ set_env CARGO_MAKE_TASK_BUILD_UTILS_ARGS "${package_options}" ''' ] +[tasks.action-determine-tests] +script_runner = "@duckscript" +script = [ +''' +test_files = glob_array tests/**/*.rs +for file in ${test_files} + if is_empty "${tests}" + tests = set "${file}" + else + tests = set "${tests} ${file}" + end_if +end +set_env CARGO_MAKE_VAR_TESTS "${tests}" +''' +] + [tasks.action-format] description = "`cargo fmt`" command = "cargo" args = ["fmt"] -[tasks.action-fmt] -description = "`cargo fmt`" +[tasks.action-format-tests] +description = "`cargo fmt` tests" command = "cargo" -args = ["fmt"] +args = ["fmt", "--", "@@split(CARGO_MAKE_VAR_TESTS, )"] + +[tasks.action-fmt] +alias = "action-format" [tasks.action-fmt_report] description = "`cargo fmt` lint report"