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
5 changes: 5 additions & 0 deletions src/cfengine_cli/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ def can_single_line_promise(node: Node, indent: int, line_length: int) -> bool:
next_sib = node.next_named_sibling
while next_sib and next_sib.type == "macro":
next_sib = next_sib.next_named_sibling

if not attrs and not _has_stakeholder(children):
# Promises without attributes and without stakeholder are
# always single line
return True
if len(attrs) > 1:
# We always want to multiline a promise with multiple attributes
# even if it would fit on one line, i.e this should be split:
Expand Down
39 changes: 39 additions & 0 deletions tests/format/009_single_line.expected.cf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,42 @@ bundle agent main
"libltdl7" package_policy => "delete";
"libltdl-dev" package_policy => "delete";
}

bundle agent mix
{
reports:
DEBUG|DEBUG_cfe_internal_cleanup_agent_reports::
"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";
}
39 changes: 39 additions & 0 deletions tests/format/009_single_line.input.cf
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,42 @@ bundle agent main

"libltdl-dev" package_policy => "delete";
}

bundle agent mix
{
reports:
DEBUG|DEBUG_cfe_internal_cleanup_agent_reports::
"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Client history purge triggered"
if => "cfe_internal_purge_reports";

"DEBUG $(this.bundle): Size of '$(files)' = '$(reports_size[$(files)])'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";
"DEBUG $(this.bundle): Size of all reports = '$(total_report_size)'";
"DEBUG $(this.bundle): Purge threshold = '$(def.max_client_history_size)'";
}
Loading