fix(scheduled-jobs): a file without a last newline no longer swallows the next header
driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / test (3.13) (pull_request) Successful in 1m4s
driver / build (pull_request) Successful in 32s
driver / lowest (pull_request) Successful in 41s
driver / security (pull_request) Successful in 1m13s
CI / driver (pull_request) Successful in 2m43s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 15s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m6s
driver / test (3.13) (pull_request) Successful in 1m4s
driver / build (pull_request) Successful in 32s
driver / lowest (pull_request) Successful in 41s
driver / security (pull_request) Successful in 1m13s
CI / driver (pull_request) Successful in 2m43s
driver / publish (pull_request) Skipped
GNU sed keeps a missing final newline, so the next section's header ran on into the file's last line and its jobs were lost. The report ends every such file with a newline of its own. Refs #86
This commit is contained in:
1 parent
edef6cf07c
commit
ffbb194300
2 files changed
+9
-1
No files matched your search
@@ -86,7 +86,9 @@ def _q(path: str) -> str:
|
||||
def _files(section: str, pattern: str) -> str:
|
||||
return (
|
||||
f'for f in {pattern}; do [ -f "$f" ] || continue; printf \'[%s %s]\\n\' {section} "$f"; '
|
||||
'sed \'s/^/|/\' "$f"; P="$P\n$f"; done; '
|
||||
# GNU sed keeps a missing last newline; without one of its own the next
|
||||
# header would run on into the file's last line.
|
||||
'sed \'s/^/|/\' "$f"; [ -n "$(tail -c 1 "$f")" ] && echo; P="$P\n$f"; done; '
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -266,6 +266,12 @@ class TestReading:
|
||||
assert backup["next_run"] == "2026-11-04T03:00:00+00:00"
|
||||
assert "last_result" not in backup
|
||||
|
||||
def test_a_file_without_a_last_newline_does_not_swallow_the_next(self, root: Path):
|
||||
(root / "etc/cron.d/certbot").write_text("0 */12 * * * root certbot -q renew")
|
||||
jobs = _jobs(Host(root))
|
||||
assert any(j["source"].endswith("certbot") for j in jobs.values())
|
||||
assert any(j["source"].endswith("spool/www-data") for j in jobs.values())
|
||||
|
||||
def test_without_systemd_no_timers(self, root: Path):
|
||||
jobs = _jobs(Host(root, systemd=False))
|
||||
assert not [j for j in jobs.values() if j["kind"] == "systemd_timer"]
|
||||
|
||||
Reference in new issue
Block a user