Skip to content

Commit

Permalink
Make it work with older versinos of hostnamectl.
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Oct 23, 2024
1 parent 102ccd8 commit 255c900
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/hostname-test.toit
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@ main:
if system.platform == system.PLATFORM-WINDOWS:
expected-hostname = pipe.backticks "hostname"
else if system.platform == system.PLATFORM-LINUX:
expected-hostname = pipe.backticks "hostnamectl" "hostname"
else:
// On newer versions of `hostnamectl` we could also use "hostnamectl hostname",
// but our buildbot doesn't support that yet.
output := pipe.backticks "hostnamectl" "status"
// Something like:
// Static hostname: red
// Icon name: computer-desktop
// Chassis: desktop 🖥
// ...
line := (output.split "\n")[0]
expected-hostname = (line.split ":")[1]
else if system.platform == system.PLATFORM-MACOS:
expected-hostname = pipe.backticks "hostname" "-s"
expected-hostname = expected-hostname.trim
else:
unreachable

expected-hostname = expected-hostname.trim
expect-equals expected-hostname system.hostname

0 comments on commit 255c900

Please sign in to comment.