After commit c018f5fd29 Fenrir is being switched over to go. If you do not want to be part of the testing process, please switch to master.

This commit is contained in:
Storm Dragon committed 2026-10-27 20:30:55 -04:00
1 parent c018f5fd29
commit 0e50de4c76
1047 files changed
+58364 -63747

No files matched your search

+76
View File
@@ -0,0 +1,76 @@
// Fenrir console screen reader.
// Copyright (c) 2026 Storm Dragon
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
package speech
import (
"errors"
"reflect"
"testing"
)
func TestRegistryIsTheImplementationAndSelectionBoundary(t *testing.T) {
available := Drivers()
if len(available) != 6 || available[0].ID != "speech-dispatcher" || available[0].Open == nil || available[0].Modules == nil {
t.Fatal(available)
}
available[0].ID = "altered"
if _, err := Find_driver("speech-dispatcher"); err != nil {
t.Fatal("registry aliased", err)
}
if _, err := Open_driver("invented", Options{}); err == nil {
t.Fatal("unknown driver opened")
}
// A supported but locally unavailable backend must not block another driver,
// and selecting it must never call its constructor or silently fall back.
original := drivers
opened := false
drivers = append(Drivers(), Driver{ID: "fixture", Label: "Fixture", Check: func() error { return errors.New("fixture dependency missing") }, Open: func(Options) (Transport, error) { opened = true; return nil, nil }})
defer func() { drivers = original }()
if _, err := Find_driver("fixture"); err != nil {
t.Fatal("unavailable support disappeared", err)
}
if err := Drivers()[0].Availability(); err != nil {
t.Fatal("unselected dependency blocked supported driver", err)
}
if _, err := Open_driver("fixture", Options{}); err == nil || opened {
t.Fatal("unavailable driver constructed or fell back", opened, err)
}
}
func TestModuleDiscoveryDoesNotSpeakOrChangeActiveClient(t *testing.T) {
server := new_fake_server(t, false)
driver, err := Find_driver("speech-dispatcher")
if err != nil {
t.Fatal(err)
}
t.Setenv("SPEECHD_ADDRESS", "unix_socket:"+server.path)
client, err := Open_driver(driver.ID, Options{Rate: 80})
if err != nil {
t.Fatal(err)
}
defer client.Close()
modules, err := driver.Modules(Options{})
if err != nil || !reflect.DeepEqual(modules, []string{"fixture", "other"}) {
t.Fatal(modules, err)
}
select {
case event := <-server.events:
t.Fatal("discovery changed speech", event)
default:
}
}