Skip to content

Commit

Permalink
More robust handling of hass subprocess in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freol35241 authored Dec 4, 2024
1 parent c12c89e commit 38475f5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/bats/test_integration.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ _run_hass () {
echo "Starting HA with configuration directory: ${config_dir}"
hass --skip-pip -c "$config_dir" 3>&- 2>&1 & hass_pid=$!

sleep 1

# Listen for successful startup (allowing maximum 120 seconds) by tailing the log file
tail -f "${config_dir}/home-assistant.log" | timeout 120s grep --line-buffered -m 1 "Home Assistant initialized in"
log_file="${config_dir}/home-assistant.log"
touch "${log_file}" # Make sure the file exists so we can tail it...
tail -f -n +1 "${log_file}" | timeout 120s grep --line-buffered -m 1 "Home Assistant initialized in"

# Kill the subprocess
kill "$hass_pid"

# Read log file
local logs
logs="$(cat "${config_dir}/home-assistant.log")"
logs="$(cat "${log_file}")"
echo "$logs"
}

Expand Down Expand Up @@ -190,4 +190,4 @@ teardown() {
assert_line --partial "We found a custom integration ltss which has not been tested by Home Assistant."
assert_line --partial "Setup of domain ltss took"
refute_line --partial "ERROR (LTSS)"
}
}

0 comments on commit 38475f5

Please sign in to comment.