From 1c3f5c56eb9e93dce8f4e302524980e43c8b4a87 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Thu, 3 Mar 2022 23:14:33 -0800 Subject: [PATCH] =?UTF-8?q?test/battery:=20fix=20tests=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/plugins/battery.plugin.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/plugins/battery.plugin.bats b/test/plugins/battery.plugin.bats index 51ef93e944..8d83ca3245 100755 --- a/test/plugins/battery.plugin.bats +++ b/test/plugins/battery.plugin.bats @@ -193,14 +193,14 @@ function setup_acpi { # Creates a `upower` function that simulates output like the real `upower` command. # The passed in parameter is used for the remaining battery percentage. function setup_upower { + trap -p PIPE | grep -q PIPE || trap '' PIPE percent="$1" BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM" function upower { case $1 in '-e'|'--enumerate') - # don't just `echo` twice because `grep` will close the pipe after matching the first line... - echo "$BAT0"$'\n'"/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery" + printf '%s\n' "$BAT0" "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery" ;; '-i'|'--show-info') if [[ $2 == "$BAT0" ]]