From 7b944796af93f0809b49c016486f5f286cc72060 Mon Sep 17 00:00:00 2001 From: Elias Bakken Date: Sun, 9 Aug 2026 21:40:07 +0200 Subject: [PATCH] Fix lastLine() killing the whole process via log.Fatal lastLine() is used to read the last line of the in-progress flash progress file. Before that file exists (right at the start of a flash, or when driving handleSerialCommand directly as in tests), the underlying `tail` command fails - and log.Fatal called os.Exit(1) on that, taking down the entire server process rather than just this one read. The only caller already handles a non-numeric/empty result by falling back to 0 (strconv.Atoi's error case), so returning "" here instead of crashing is a correct, already-expected fallback path, not a new one. This was silently killing the whole `go test ./...` run partway through TestHandleSerialCommand, since the STATUS subtest exercises this exact path without the progress file existing yet - no other tests after it in the package ever actually ran. Co-Authored-By: Claude Sonnet 5 --- reflash/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reflash/server.go b/reflash/server.go index cbb286a..f8b9212 100644 --- a/reflash/server.go +++ b/reflash/server.go @@ -987,7 +987,12 @@ func parseXzUncompressedSize(out string) int { func lastLine(file string) string { out, err := exec.Command("tail", "-n1", file).Output() if err != nil { - log.Fatal(err) + // Expected before the progress file exists yet (e.g. right at + // the start of a flash, or in tests) - the caller already + // falls back to 0 on a non-numeric result. log.Fatal here + // used to kill the whole process on this, not just this one + // read. + return "" } return strings.TrimSpace(string(out[:])) }