Exit on fatal microphone device errors
This commit is contained in:
committed by
Brandon McGinty
parent
d2e94c76b5
commit
6bf79acc6a
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -8,10 +9,24 @@ import (
|
||||
"unicode/utf8"
|
||||
|
||||
"git.stormux.org/storm/barnard/gumble/gumble"
|
||||
"git.stormux.org/storm/barnard/gumble/gumbleopenal"
|
||||
)
|
||||
|
||||
// Regression: HTML escaping left terminal control sequences in server text,
|
||||
// allowing ANSI/OSC sequences to alter the terminal that rendered it.
|
||||
// Regression: a capture-device open error left the application alive with no
|
||||
// usable microphone. These errors are fatal and use the post-TUI stderr path.
|
||||
func TestFatalAudioOpenError(t *testing.T) {
|
||||
for _, err := range []error{gumbleopenal.ErrMic, gumbleopenal.ErrInputDevice, gumbleopenal.ErrOutputDevice, fmt.Errorf("wrapped: %w", gumbleopenal.ErrMic)} {
|
||||
if !fatalAudioOpenError(err) {
|
||||
t.Fatalf("%v was not fatal", err)
|
||||
}
|
||||
}
|
||||
if fatalAudioOpenError(gumbleopenal.ErrState) {
|
||||
t.Fatal("state error should remain recoverable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEscRemovesTerminalControlSequences(t *testing.T) {
|
||||
got := esc("name\x1b]0;spoof\a\x7f\u202e")
|
||||
if got != "name]0;spoof" {
|
||||
|
||||
Reference in New Issue
Block a user