From be0be3c42e653cac19655c1a2e8ee04ffdcc9fc8 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Tue, 21 Apr 2026 14:31:29 +0200 Subject: [PATCH 1/2] Added one more test case from promises.cf to macro formatting test Signed-off-by: Ole Herman Schumacher Elgesem --- tests/format/011_macros.expected.cf | 26 ++++++++++++++++++++++++++ tests/format/011_macros.input.cf | 23 +++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/format/011_macros.expected.cf b/tests/format/011_macros.expected.cf index d182a6d..8582eca 100644 --- a/tests/format/011_macros.expected.cf +++ b/tests/format/011_macros.expected.cf @@ -83,3 +83,29 @@ bundle agent half_with_comment string => "old_value"; @endif } + +bundle common cfe_internal_inputs +# @brief Include internal self management policies +{ + vars: + enterprise_edition.(policy_server|am_policy_hub):: + "input[enterprise_hub_specific]" + string => "cfe_internal/enterprise/CFE_hub_specific.cf", + comment => "Lorem ipsum."; +@if minimum_version(3.12.0) + "input[enterprise_hub_federation]" + string => "cfe_internal/enterprise/federation/federation.cf", + comment => "Lorem ipsum."; +@endif + enterprise_edition:: + "input[enterprise_knowledge]" + string => "cfe_internal/enterprise/CFE_knowledge.cf", + comment => "Lorem ipsum."; + + "input[enterprise_main]" + string => "cfe_internal/enterprise/main.cf", + comment => "Lorem ipsum."; + + any:: + "inputs" slist => getvalues("input"); +} diff --git a/tests/format/011_macros.input.cf b/tests/format/011_macros.input.cf index 6070106..90cf532 100644 --- a/tests/format/011_macros.input.cf +++ b/tests/format/011_macros.input.cf @@ -82,3 +82,26 @@ string => "new_value"; string => "old_value"; @endif } +bundle common cfe_internal_inputs +# @brief Include internal self management policies +{ +vars: +enterprise_edition.(policy_server|am_policy_hub):: +"input[enterprise_hub_specific]" +string => "cfe_internal/enterprise/CFE_hub_specific.cf", +comment => "Lorem ipsum."; +@if minimum_version(3.12.0) +"input[enterprise_hub_federation]" +string => "cfe_internal/enterprise/federation/federation.cf", +comment => "Lorem ipsum."; +@endif +enterprise_edition:: +"input[enterprise_knowledge]" +string => "cfe_internal/enterprise/CFE_knowledge.cf", +comment => "Lorem ipsum."; +"input[enterprise_main]" +string => "cfe_internal/enterprise/main.cf", +comment => "Lorem ipsum."; +any:: +"inputs" slist => getvalues("input"); +} From 55e9d94735a5deb7b035df822bbf640a7a2fb8e8 Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem Date: Tue, 21 Apr 2026 15:01:57 +0200 Subject: [PATCH 2/2] cfengine format: Removed extra empty lines around macros Co-authored-by: Claude Opus 4.6 (1M context) Signed-off-by: Ole Herman Schumacher Elgesem --- src/cfengine_cli/format.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cfengine_cli/format.py b/src/cfengine_cli/format.py index 9d23d1f..3ff77b4 100644 --- a/src/cfengine_cli/format.py +++ b/src/cfengine_cli/format.py @@ -606,6 +606,9 @@ def _needs_blank_line_before(child: Node, indent: int, line_length: int) -> bool return prev.type == "bundle_section" if child.type == "promise": + # An @if macro already provides visual separation + if prev.type == "macro" and text(prev).startswith("@if"): + return False # Skip past macros to find the content-bearing previous sibling, # so we detect promise groups separated by macro-split halves. prev_content = prev