From f860d6bdc2d3d3585f453de4086937852b75389f Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 19 Jun 2026 13:16:20 -0400 Subject: [PATCH] test/launch: fix missing app errors --- internal/appherder/launch_test.go | 40 +++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/internal/appherder/launch_test.go b/internal/appherder/launch_test.go index 6d97ec4..5ebb541 100644 --- a/internal/appherder/launch_test.go +++ b/internal/appherder/launch_test.go @@ -1,10 +1,40 @@ package appherder -import "testing" +import ( + "os" + "path/filepath" + "strings" + "testing" + "time" +) -func TestLaunchMissingApp(t *testing.T) { - a, _ := newTestApp(t) - if err := a.Launch("missing"); err == nil { - t.Fatal("Launch missing app succeeded, want error") +func TestLaunchExecutesInstalledAppImage(t *testing.T) { + app, home := newTestApp(t) + marker := filepath.Join(home, "launched") + script := "#!/bin/sh\nprintf launched > " + shellQuote(marker) + "\n" + if err := os.MkdirAll(filepath.Join(home, "AppImages"), 0o755); err != nil { + t.Fatal(err) } + if err := os.WriteFile(filepath.Join(home, "AppImages", "foo.appimage"), []byte(script), 0o755); err != nil { + t.Fatal(err) + } + + if err := app.Launch("foo"); err != nil { + t.Fatal(err) + } + + deadline := time.Now().Add(time.Second) + for { + if got, err := os.ReadFile(marker); err == nil && string(got) == "launched" { + return + } + if time.Now().After(deadline) { + t.Fatal("launched app did not write marker") + } + time.Sleep(10 * time.Millisecond) + } +} + +func shellQuote(value string) string { + return "'" + strings.ReplaceAll(value, "'", `'\''`) + "'" } -- 2.51.2