From f6fed8b8317bf6f8ee8101c211f5a44787f2d97d Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 20 Sep 2024 17:18:32 -0700 Subject: [PATCH] nixos/switch-test: add test for multi-line unit values --- nixos/tests/switch-test.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/nixos/tests/switch-test.nix b/nixos/tests/switch-test.nix index 84c6e90689b3..e00c22b81682 100644 --- a/nixos/tests/switch-test.nix +++ b/nixos/tests/switch-test.nix @@ -260,6 +260,15 @@ in { systemd.services."escaped\\x2ddash".serviceConfig.X-Test = "test"; }; + unitWithMultilineValue.configuration = { + systemd.services.test.serviceConfig.ExecStart = '' + ${pkgs.coreutils}/bin/true \ + # ignored + ; ignored + blah blah + ''; + }; + unitStartingWithDash.configuration = { systemd.services."-" = { wantedBy = [ "multi-user.target" ]; @@ -874,9 +883,16 @@ in { machine.succeed("! test -e /run/current-system/dry-activate") machine.succeed("! test -e /run/current-system/bin/switch-to-configuration") + # Ensure units with multiline values work + out = switch_to_specialisation("${machine}", "unitWithMultilineValue") + assert_lacks(out, "NOT restarting the following changed units:") + assert_lacks(out, "reloading the following units:") + assert_lacks(out, "restarting the following units:") + assert_lacks(out, "the following new units were started:") + assert_contains(out, "starting the following units: test.service") + # Ensure \ works in unit names out = switch_to_specialisation("${machine}", "unitWithBackslash") - assert_contains(out, "stopping the following units: test.service\n") assert_lacks(out, "NOT restarting the following changed units:") assert_lacks(out, "reloading the following units:") assert_lacks(out, "\nrestarting the following units:")