Skip to content

Commit 1c3f5c5

Browse files
committed
test/battery: fix tests…
1 parent 71c5a75 commit 1c3f5c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/plugins/battery.plugin.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ function setup_acpi {
193193
# Creates a `upower` function that simulates output like the real `upower` command.
194194
# The passed in parameter is used for the remaining battery percentage.
195195
function setup_upower {
196+
trap -p PIPE | grep -q PIPE || trap '' PIPE
196197
percent="$1"
197198
BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM"
198199

199200
function upower {
200201
case $1 in
201202
'-e'|'--enumerate')
202-
# don't just `echo` twice because `grep` will close the pipe after matching the first line...
203-
echo "$BAT0"$'\n'"/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
203+
printf '%s\n' "$BAT0" "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery"
204204
;;
205205
'-i'|'--show-info')
206206
if [[ $2 == "$BAT0" ]]

0 commit comments

Comments
 (0)