@@ -20,19 +20,25 @@ func makeExecutableFile(t *testing.T, path string, content string) {
2020 }
2121}
2222
23- func waitForFile (t * testing.T , path string , timeout time.Duration ) string {
23+ func waitForFile (t * testing.T , path string , timeout time.Duration , wantLine string ) string {
2424 t .Helper ()
2525 deadline := time .Now ().Add (timeout )
2626 for {
2727 data , err := os .ReadFile (path )
2828 if err == nil {
29- return string (data )
29+ content := string (data )
30+ if wantLine == "" || hasLine (content , wantLine ) {
31+ return content
32+ }
3033 }
3134 if ! errors .Is (err , os .ErrNotExist ) {
3235 t .Fatalf ("read %s: %v" , path , err )
3336 }
3437 if time .Now ().After (deadline ) {
35- t .Fatalf ("timed out waiting for %s" , path )
38+ if wantLine == "" {
39+ t .Fatalf ("timed out waiting for %s" , path )
40+ }
41+ t .Fatalf ("timed out waiting for %s to contain line %q" , path , wantLine )
3642 }
3743 time .Sleep (20 * time .Millisecond )
3844 }
@@ -142,14 +148,14 @@ func TestStartVoiceDaemonLaunchesProcessAndStops(t *testing.T) {
142148 t .Fatalf ("expected voiceAutoStarting=true after start" )
143149 }
144150
145- argsOut := waitForFile (t , argsPath , 2 * time .Second )
151+ argsOut := waitForFile (t , argsPath , 2 * time .Second , "--meter" )
146152 for _ , arg := range []string {"-server" , "http://dialtone.test" , "-token" , "secret-token" , "-ipc" , "/tmp/dialtone-test.sock" , "--meter" } {
147153 if ! hasLine (argsOut , arg ) {
148154 t .Fatalf ("expected daemon arg %q in:\n %s" , arg , argsOut )
149155 }
150156 }
151157
152- envOut := waitForFile (t , envPath , 2 * time .Second )
158+ envOut := waitForFile (t , envPath , 2 * time .Second , "DIALTONE_KEEP_ME=ok" )
153159 if strings .Contains (envOut , "XDG_ACTIVATION_TOKEN=" ) {
154160 t .Fatalf ("expected launcher token removed from daemon environment" )
155161 }
0 commit comments