test(qa): RC2 re-check of v0.2.8 (QA fixes, config, session, signals)
Re-verify QA-1..QA-11 fixes and the stage-2C config/session/signal changes used by the old UI. New bugs QA-12..QA-19 are skip-tagged tests; QA-12 (SIGTERM can hang vcom: main and Bubble Tea both handle it) blocks the release. The cross-device trash test now cleans the topdir trash it uses. Report: plans/rework/05-qa-v0.2.8.md, section RC2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
058616de38
commit
2e3c5959b6
6 changed files with 941 additions and 1 deletions
93
cmd/vcom/qa_signal_test.go
Normal file
93
cmd/vcom/qa_signal_test.go
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
package main
|
||||
|
||||
// QA (v0.2.8 RC2): SIGTERM must end vcom and save the session. main
|
||||
// registers its own SIGTERM handler next to Bubble Tea's; when main's
|
||||
// tea.Quit wins, Bubble Tea's handler blocks forever on an unbuffered send
|
||||
// and Program.shutdown waits for it: the process hangs in the alt screen
|
||||
// and the session is never saved. The test runs the real run() in a child
|
||||
// process (this test binary) on a pty (util-linux `script`) and sends
|
||||
// SIGTERM repeatedly.
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestQASigtermHelperProcess(t *testing.T) {
|
||||
if os.Getenv("VCOM_QA_CHILD") != "1" {
|
||||
t.Skip("helper process")
|
||||
}
|
||||
home := os.Getenv("HOME")
|
||||
_ = os.WriteFile(filepath.Join(home, "pid"), []byte(strconv.Itoa(os.Getpid())), 0o600)
|
||||
os.Args = []string{"vcom"}
|
||||
os.Exit(run())
|
||||
}
|
||||
|
||||
func TestQASigtermExitsAndSavesSession(t *testing.T) {
|
||||
t.Skip("BUG QA-12 (P1, regression from 2C): SIGTERM sometimes hangs vcom forever: main.go:83-92 subscribes to SIGTERM in addition to Bubble Tea; if main's tea.Quit wins, Bubble Tea's signal goroutine blocks on p.msgs <- QuitMsg{} and Program.shutdown waits for it (vendor bubbletea tea.go:302, :814); terminal stays in alt screen, session not saved")
|
||||
script, err := exec.LookPath("script")
|
||||
if err != nil {
|
||||
t.Skip("util-linux script not available")
|
||||
}
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const runs = 12
|
||||
hung, saved := 0, 0
|
||||
for i := 0; i < runs; i++ {
|
||||
home := t.TempDir()
|
||||
child := exe + " -test.run=^TestQASigtermHelperProcess$"
|
||||
cmd := exec.Command(script, "-qfec", "stty rows 40 cols 120; "+child, "/dev/null")
|
||||
cmd.Env = append(os.Environ(),
|
||||
"VCOM_QA_CHILD=1", "HOME="+home, "TERM=xterm-256color",
|
||||
"XDG_CONFIG_HOME="+filepath.Join(home, ".config"),
|
||||
"XDG_STATE_HOME="+filepath.Join(home, ".local", "state"),
|
||||
"XDG_CACHE_HOME="+filepath.Join(home, ".cache"),
|
||||
"XDG_DATA_HOME="+filepath.Join(home, ".local", "share"),
|
||||
"VCOM_CONFIG=", "SSH_AUTH_SOCK=",
|
||||
)
|
||||
cmd.Dir = home
|
||||
var out strings.Builder
|
||||
cmd.Stdout, cmd.Stderr = &out, &out
|
||||
if err := cmd.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
done := make(chan struct{})
|
||||
go func() { cmd.Wait(); close(done) }()
|
||||
var pid int
|
||||
for w := 0; w < 500 && pid == 0; w++ {
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
if b, err := os.ReadFile(filepath.Join(home, "pid")); err == nil {
|
||||
pid, _ = strconv.Atoi(strings.TrimSpace(string(b)))
|
||||
}
|
||||
}
|
||||
if pid == 0 {
|
||||
cmd.Process.Kill()
|
||||
<-done
|
||||
t.Fatalf("child did not start: %.400q", out.String())
|
||||
}
|
||||
time.Sleep(1500 * time.Millisecond) // UI up and idle
|
||||
_ = syscall.Kill(pid, syscall.SIGTERM)
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(4 * time.Second):
|
||||
hung++
|
||||
_ = syscall.Kill(pid, syscall.SIGKILL)
|
||||
<-done
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, ".local", "state", "vcom", "session.toml")); err == nil {
|
||||
saved++
|
||||
}
|
||||
}
|
||||
t.Logf("runs=%d hung=%d saved=%d", runs, hung, saved)
|
||||
if hung > 0 || saved != runs {
|
||||
t.Fatalf("SIGTERM: vcom hung in %d of %d runs; session saved in %d", hung, runs, saved)
|
||||
}
|
||||
}
|
||||
191
internal/config/qa_rc2_test.go
Normal file
191
internal/config/qa_rc2_test.go
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
package config
|
||||
|
||||
// QA (v0.2.8 RC2): config loading and SetKey (stage 2C) from the user's
|
||||
// side: symlinked/read-only/odd configs must never be lost or corrupted.
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func qaIsolate(t *testing.T) string {
|
||||
t.Helper()
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_STATE_HOME", filepath.Join(home, ".local", "state"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
t.Setenv("VCOM_CONFIG", "")
|
||||
return home
|
||||
}
|
||||
|
||||
func qaWrite(t *testing.T, p, s string, mode os.FileMode) {
|
||||
t.Helper()
|
||||
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(p, []byte(s), mode); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Chmod(p, mode); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Dotfiles: the config is a symlink into a dotfiles repo. The link stays,
|
||||
// the target gets the new theme, comments survive.
|
||||
func TestQASetKeyThroughSymlink(t *testing.T) {
|
||||
home := qaIsolate(t)
|
||||
target := filepath.Join(home, "dotfiles", "vcom.toml")
|
||||
qaWrite(t, target, "# mine\n[ui]\ntheme = \"old\" # c\n", 0o640)
|
||||
link := filepath.Join(home, ".config", "vcom", "vcom.toml")
|
||||
if err := os.MkdirAll(filepath.Dir(link), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink("../../dotfiles/vcom.toml", link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, info, err := Load("")
|
||||
if err != nil || !info.Found || cfg.UI.Theme != "old" {
|
||||
t.Fatalf("load via symlink: %v %+v theme=%q", err, info, cfg.UI.Theme)
|
||||
}
|
||||
if _, err := SetKey(info.Path, "ui", "theme", "new"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fi, err := os.Lstat(link); err != nil || fi.Mode()&os.ModeSymlink == 0 {
|
||||
t.Fatal("symlink replaced by a regular file")
|
||||
}
|
||||
b, _ := os.ReadFile(target)
|
||||
if string(b) != "# mine\n[ui]\ntheme = \"new\" # c\n" {
|
||||
t.Fatalf("target content %q", b)
|
||||
}
|
||||
if fi, _ := os.Stat(target); fi.Mode().Perm() != 0o640 {
|
||||
t.Fatalf("target mode changed to %o", fi.Mode().Perm())
|
||||
}
|
||||
}
|
||||
|
||||
// A user who made the config read-only (chmod a-w) expects vcom not to
|
||||
// change it. v0.2.7 failed with EACCES; atomic rename now replaces it.
|
||||
func TestQASetKeyReadOnlyConfig(t *testing.T) {
|
||||
t.Skip("BUG QA-13 (P2): SetKey replaces a read-only (0444) config via temp+rename; v0.2.7 refused (EACCES). atomicfile.Write ignores the missing write permission (atomicfile.go:40-52)")
|
||||
home := qaIsolate(t)
|
||||
p := filepath.Join(home, ".config", "vcom", "vcom.toml")
|
||||
qaWrite(t, p, "[ui]\ntheme = \"locked\"\n", 0o444)
|
||||
if _, err := SetKey(p, "ui", "theme", "other"); err == nil {
|
||||
b, _ := os.ReadFile(p)
|
||||
t.Fatalf("read-only config was rewritten: %q", b)
|
||||
}
|
||||
}
|
||||
|
||||
// Valid TOML forms of the same key: dotted key at the root and an inline
|
||||
// table. SetKey must either edit them or fail without touching the file;
|
||||
// failing means the theme silently stops being saved for these users.
|
||||
func TestQASetKeyDottedAndInlineForms(t *testing.T) {
|
||||
t.Skip("BUG QA-14 (P2): SetKey cannot save the theme when the config uses `ui.theme = ...` at the root or `ui = { theme = ... }`: it appends a second [ui] table, verify() rejects the result, theme change reports 'save failed' (setkey.go:86-152)")
|
||||
for name, content := range map[string]string{
|
||||
"dotted": "ui.theme = \"old\"\nui.icon_mode = \"ascii\"\n",
|
||||
"inline": "ui = { theme = \"old\" }\n",
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
home := qaIsolate(t)
|
||||
p := filepath.Join(home, "vcom.toml")
|
||||
qaWrite(t, p, content, 0o644)
|
||||
if _, _, err := Parse([]byte(content)); err != nil {
|
||||
t.Fatalf("fixture must be valid: %v", err)
|
||||
}
|
||||
if _, err := SetKey(p, "ui", "theme", "new"); err != nil {
|
||||
t.Fatalf("SetKey on a valid %s config: %v", name, err)
|
||||
}
|
||||
b, _ := os.ReadFile(p)
|
||||
c, _, err := Parse(b)
|
||||
if err != nil || c.UI.Theme != "new" {
|
||||
t.Fatalf("result %q: theme=%q err=%v", b, c.UI.Theme, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Even when SetKey fails on such a file, it must stay byte-identical.
|
||||
func TestQASetKeyFailureLeavesFileIntact(t *testing.T) {
|
||||
for _, content := range []string{
|
||||
"ui.theme = \"old\"\n",
|
||||
"ui = { theme = \"old\" }\n",
|
||||
"[ui]\ntheme = \"\"\"multi\nline\"\"\"\n",
|
||||
"[ui\ntheme = 1\n", // broken
|
||||
} {
|
||||
home := qaIsolate(t)
|
||||
p := filepath.Join(home, "vcom.toml")
|
||||
qaWrite(t, p, content, 0o600)
|
||||
_, _ = SetKey(p, "ui", "theme", "new")
|
||||
b, _ := os.ReadFile(p)
|
||||
c, _, perr := Parse(b)
|
||||
if string(b) != content && (perr != nil || c.UI.Theme != "new") {
|
||||
t.Fatalf("file damaged: before %q after %q", content, b)
|
||||
}
|
||||
if left, _ := filepath.Glob(filepath.Join(home, ".vcom.toml.tmp-*")); len(left) != 0 {
|
||||
t.Fatalf("temp files left: %v", left)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UTF-8 BOM and CRLF (configs edited on Windows / by some editors).
|
||||
func TestQASetKeyBOM(t *testing.T) {
|
||||
home := qaIsolate(t)
|
||||
p := filepath.Join(home, "vcom.toml")
|
||||
content := "\ufeff[ui]\r\ntheme = \"old\"\r\n"
|
||||
qaWrite(t, p, content, 0o644)
|
||||
if _, _, err := Parse([]byte(content)); err != nil {
|
||||
t.Skipf("go-toml does not accept a BOM: %v", err)
|
||||
}
|
||||
_, err := SetKey(p, "ui", "theme", "new")
|
||||
b, _ := os.ReadFile(p)
|
||||
if err != nil {
|
||||
if string(b) != content {
|
||||
t.Fatalf("failed SetKey changed the file: %q", b)
|
||||
}
|
||||
t.Logf("SetKey refuses a BOM config: %v", err)
|
||||
return
|
||||
}
|
||||
if c, _, err := Parse(b); err != nil || c.UI.Theme != "new" || strings.Count(string(b), "[ui]") != 1 {
|
||||
t.Fatalf("BOM config result %q (err %v)", b, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Load: a directory or an unreadable file in place of the config gives
|
||||
// defaults plus an error, never a crash.
|
||||
func TestQALoadDirAndUnreadable(t *testing.T) {
|
||||
home := qaIsolate(t)
|
||||
p := filepath.Join(home, ".config", "vcom", "vcom.toml")
|
||||
if err := os.MkdirAll(p, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, _, err := Load("")
|
||||
if err == nil {
|
||||
t.Fatal("directory as config must report an error")
|
||||
}
|
||||
if cfg.UI.Theme != Default().UI.Theme {
|
||||
t.Fatal("defaults not used")
|
||||
}
|
||||
os.Remove(p)
|
||||
qaWrite(t, p, "[ui]\ntheme = \"x\"\n", 0o000)
|
||||
if os.Geteuid() == 0 {
|
||||
t.Skip("root reads 0000 files")
|
||||
}
|
||||
if _, _, err := Load(""); err == nil {
|
||||
t.Fatal("unreadable config must report an error")
|
||||
}
|
||||
}
|
||||
|
||||
// -config / $VCOM_CONFIG pointing to a missing file: Load reports where it
|
||||
// would be created (info.Path = that file).
|
||||
func TestQALoadExplicitMissing(t *testing.T) {
|
||||
home := qaIsolate(t)
|
||||
want := filepath.Join(home, "custom", "vcom.toml")
|
||||
t.Setenv("VCOM_CONFIG", want)
|
||||
_, info, err := Load("")
|
||||
if err != nil || info.Found || info.Path != want {
|
||||
t.Fatalf("info=%+v err=%v", info, err)
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
|
@ -333,8 +334,10 @@ func TestQATrashCrossDevice(t *testing.T) {
|
|||
if dir == "" {
|
||||
t.Skip("no second filesystem available")
|
||||
}
|
||||
p := filepath.Join(dir, "on-other-fs.txt")
|
||||
name := "vcom-qa-" + filepath.Base(dir) + ".txt"
|
||||
p := filepath.Join(dir, name)
|
||||
qaWrite(t, p, "x", 0o644)
|
||||
cleanupTopdirTrash(t, dir, name)
|
||||
if err := MoveToTrash(p); err != nil {
|
||||
t.Fatalf("MoveToTrash across filesystems: %v", err)
|
||||
}
|
||||
|
|
@ -389,3 +392,46 @@ func TestQAMakeDirEdgeCases(t *testing.T) {
|
|||
t.Fatalf("cyrillic name: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// cleanupTopdirTrash removes name (and its .trashinfo) from the topdir trash
|
||||
// of dir's filesystem after the test, and the trash dirs themselves if the
|
||||
// test created them: the topdir is a real mount (/dev/shm, /run/user/...).
|
||||
func cleanupTopdirTrash(t *testing.T, dir, name string) {
|
||||
t.Helper()
|
||||
var st syscall.Stat_t
|
||||
if err := syscall.Stat(dir, &st); err != nil {
|
||||
return
|
||||
}
|
||||
top := dir
|
||||
for {
|
||||
parent := filepath.Dir(top)
|
||||
var ps syscall.Stat_t
|
||||
if parent == top || syscall.Stat(parent, &ps) != nil || ps.Dev != st.Dev {
|
||||
break
|
||||
}
|
||||
top = parent
|
||||
}
|
||||
uid := strconv.Itoa(os.Getuid())
|
||||
trashes := []string{filepath.Join(top, ".Trash-"+uid), filepath.Join(top, ".Trash", uid)}
|
||||
existed := map[string]bool{}
|
||||
for _, tr := range trashes {
|
||||
if _, err := os.Lstat(tr); err == nil {
|
||||
existed[tr] = true
|
||||
}
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
for _, tr := range trashes {
|
||||
matches, _ := filepath.Glob(filepath.Join(tr, "files", name+"*"))
|
||||
for _, m := range matches {
|
||||
os.RemoveAll(m)
|
||||
os.Remove(filepath.Join(tr, "info", filepath.Base(m)+".trashinfo"))
|
||||
}
|
||||
if !existed[tr] {
|
||||
os.Remove(filepath.Join(tr, "files"))
|
||||
os.Remove(filepath.Join(tr, "info"))
|
||||
os.Remove(filepath.Join(tr, "expunged"))
|
||||
os.Remove(tr)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
114
internal/state/qa_rc2_test.go
Normal file
114
internal/state/qa_rc2_test.go
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
package state
|
||||
|
||||
// QA (v0.2.8 RC2): session edge cases (stage 2C.3).
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func qaWrite(t *testing.T, p, s string) {
|
||||
t.Helper()
|
||||
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(p, []byte(s), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestQASessionEmptyAndBroken(t *testing.T) {
|
||||
home := isolate(t)
|
||||
p := filepath.Join(home, ".local", "state", "vcom", "session.toml")
|
||||
qaWrite(t, p, "")
|
||||
if s, err := Load(); err != nil || s.Left.Path != "" {
|
||||
t.Fatalf("empty session: %+v %v", s, err)
|
||||
}
|
||||
qaWrite(t, p, "active_pane = 'left'\n[left\npath = '/x'\n")
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("broken session must report an error")
|
||||
}
|
||||
// A broken new file must not trigger migration from the old one.
|
||||
old := filepath.Join(home, ".config", "vcom", "session.toml")
|
||||
qaWrite(t, old, "active_pane = 'right'\n")
|
||||
_, _ = Load()
|
||||
if _, err := os.Stat(old); err != nil {
|
||||
t.Fatal("old session removed although the new one is broken")
|
||||
}
|
||||
// Saving replaces the broken file with a valid one.
|
||||
if err := Save(Session{ActivePane: "right"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if s, err := Load(); err != nil || s.ActivePane != "right" {
|
||||
t.Fatalf("after save: %+v %v", s, err)
|
||||
}
|
||||
}
|
||||
|
||||
// A broken OLD session is neither migrated nor deleted.
|
||||
func TestQASessionBrokenOldKept(t *testing.T) {
|
||||
home := isolate(t)
|
||||
old := filepath.Join(home, ".config", "vcom", "session.toml")
|
||||
qaWrite(t, old, "[[[")
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("broken old session must report an error")
|
||||
}
|
||||
if _, err := os.Stat(old); err != nil {
|
||||
t.Fatal("broken old session deleted")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(home, ".local", "state", "vcom", "session.toml")); !os.IsNotExist(err) {
|
||||
t.Fatal("broken old session migrated")
|
||||
}
|
||||
}
|
||||
|
||||
// Session as a symlink (dotfiles) stays a symlink.
|
||||
func TestQASessionSymlink(t *testing.T) {
|
||||
home := isolate(t)
|
||||
target := filepath.Join(home, "elsewhere", "session.toml")
|
||||
qaWrite(t, target, "active_pane = 'left'\n")
|
||||
p := filepath.Join(home, ".local", "state", "vcom", "session.toml")
|
||||
if err := os.MkdirAll(filepath.Dir(p), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(target, p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Save(Session{ActivePane: "right"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if fi, _ := os.Lstat(p); fi.Mode()&os.ModeSymlink == 0 {
|
||||
t.Fatal("session symlink replaced")
|
||||
}
|
||||
if s, _ := Load(); s.ActivePane != "right" {
|
||||
t.Fatal("target not updated")
|
||||
}
|
||||
}
|
||||
|
||||
// When the new state dir cannot be written, Load returns the old session
|
||||
// AND an error; the caller (ui.applySession) drops the session on any
|
||||
// error, so the user loses the restored panes although they were read.
|
||||
func TestQASessionMigrationUnwritableStateDir(t *testing.T) {
|
||||
if os.Geteuid() == 0 {
|
||||
t.Skip("root ignores permissions")
|
||||
}
|
||||
home := isolate(t)
|
||||
old := filepath.Join(home, ".config", "vcom", "session.toml")
|
||||
qaWrite(t, old, "active_pane = 'right'\n[left]\npath = '/tmp'\n")
|
||||
ro := filepath.Join(home, "ro")
|
||||
if err := os.MkdirAll(ro, 0o500); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { os.Chmod(ro, 0o700) })
|
||||
t.Setenv("XDG_STATE_HOME", filepath.Join(ro, "state"))
|
||||
s, err := Load()
|
||||
if s.ActivePane != "right" {
|
||||
t.Fatalf("old session not returned: %+v %v", s, err)
|
||||
}
|
||||
if _, serr := os.Stat(old); serr != nil {
|
||||
t.Fatal("old session removed although migration failed")
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("expected a migration error")
|
||||
}
|
||||
// Documented in the report as QA-16: ui.applySession ignores s when err != nil.
|
||||
}
|
||||
340
internal/ui/qa_rc2_test.go
Normal file
340
internal/ui/qa_rc2_test.go
Normal file
|
|
@ -0,0 +1,340 @@
|
|||
package ui
|
||||
|
||||
// QA (v0.2.8 RC2): re-check of the QA fixes from the user's side and of the
|
||||
// stage-2C changes the old UI now uses (config/SetKey, session, trash).
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"vcom/internal/config"
|
||||
vfs "vcom/internal/fs"
|
||||
"vcom/internal/testutil/teadriver"
|
||||
)
|
||||
|
||||
// newModelLikeMain mirrors cmd/vcom/main.go: Load, pass info.Path only if
|
||||
// the file was found and parsed, set the notice.
|
||||
func newModelLikeMain(t *testing.T, left, right string) (*teadriver.Driver, config.LoadInfo) {
|
||||
t.Helper()
|
||||
cfg, info, err := config.Load("")
|
||||
resolved := ""
|
||||
if info.Found && err == nil {
|
||||
resolved = info.Path
|
||||
}
|
||||
cfg.UI.IconMode = "ascii"
|
||||
cfg.Startup.LeftPath, cfg.Startup.RightPath = left, right
|
||||
m, merr := NewModel(cfg, resolved)
|
||||
if merr != nil {
|
||||
t.Fatalf("NewModel: %v", merr)
|
||||
}
|
||||
if err != nil {
|
||||
m = m.WithStatus(err.Error())
|
||||
}
|
||||
t.Cleanup(func() { m.cleanupArchiveMounts(); m.cleanupRemoteImageTemp() })
|
||||
d := teadriver.New(t, m, 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
return d, info
|
||||
}
|
||||
|
||||
func userConfig(t *testing.T) string {
|
||||
return filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "vcom", "vcom.toml")
|
||||
}
|
||||
|
||||
// Unknown theme name: vcom starts with the default theme and says why;
|
||||
// choosing a theme then fixes the file, keeping the rest of it.
|
||||
func TestQAUnknownThemeStartsAndIsFixable(t *testing.T) {
|
||||
isolateEnv(t)
|
||||
dir := t.TempDir()
|
||||
p := userConfig(t)
|
||||
writeFile(t, p, "# keep me\n[ui]\ntheme = \"no-such-theme\"\nicon_mode = \"ascii\"\n")
|
||||
d, _ := newModelLikeMain(t, dir, dir)
|
||||
if !d.ScreenContains("no-such-theme") {
|
||||
t.Fatalf("unknown theme not explained on screen:\n%s", d.Screen())
|
||||
}
|
||||
d.Press("t", "j", "enter")
|
||||
d.Settle(settle)
|
||||
b, _ := os.ReadFile(p)
|
||||
if strings.Contains(string(b), "no-such-theme") || !strings.Contains(string(b), "# keep me") || !strings.Contains(string(b), "icon_mode") {
|
||||
t.Fatalf("config after theme choice: %q (status %q)", b, cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// Broken config: vcom starts with defaults, shows the error; choosing a
|
||||
// theme must not overwrite (or "repair") the user's broken file.
|
||||
func TestQABrokenConfigNotOverwrittenByTheme(t *testing.T) {
|
||||
isolateEnv(t)
|
||||
dir := t.TempDir()
|
||||
p := userConfig(t)
|
||||
broken := "[ui]\ntheme = \"catppuccin-mocha\"\nicon_mode = \n# half-edited\n"
|
||||
writeFile(t, p, broken)
|
||||
d, _ := newModelLikeMain(t, dir, dir)
|
||||
if !d.ScreenContains("incomplete number") { // shown, though not highlighted as an error (see report)
|
||||
t.Fatalf("broken config not reported: %q", cur(t, d).status)
|
||||
}
|
||||
d.Press("t", "j", "enter")
|
||||
d.Settle(settle)
|
||||
if b, _ := os.ReadFile(p); string(b) != broken {
|
||||
t.Fatalf("broken config was rewritten: %q", b)
|
||||
}
|
||||
}
|
||||
|
||||
// $VCOM_CONFIG (or -config) names a file that does not exist yet: the
|
||||
// theme must be saved there, so the next start (which reads $VCOM_CONFIG)
|
||||
// sees it. main passes "" for a missing file and SetKey("") writes the
|
||||
// default ~/.config/vcom/vcom.toml instead.
|
||||
func TestQAThemeSavedToExplicitMissingConfig(t *testing.T) {
|
||||
t.Skip("BUG QA-15 (P2): with -config/$VCOM_CONFIG pointing to a missing file, the theme is saved to ~/.config/vcom/vcom.toml (main.go:41-43 passes resolvedPath=\"\" unless the file exists; SetKey(\"\") uses the default path); the next start reads the explicit path and loses it")
|
||||
home := isolateEnv(t)
|
||||
explicit := filepath.Join(home, "custom", "vcom.toml")
|
||||
t.Setenv("VCOM_CONFIG", explicit)
|
||||
dir := t.TempDir()
|
||||
d, info := newModelLikeMain(t, dir, dir)
|
||||
if info.Path != explicit {
|
||||
t.Fatalf("Load info.Path=%q", info.Path)
|
||||
}
|
||||
d.Press("t", "j", "enter")
|
||||
d.Settle(settle)
|
||||
if _, err := os.Stat(explicit); err != nil {
|
||||
t.Fatalf("theme not saved to $VCOM_CONFIG (%v); default exists: %v", err, exists(userConfig(t)))
|
||||
}
|
||||
}
|
||||
|
||||
// A broken session.toml: start at the startup paths, quit writes a valid one.
|
||||
func TestQABrokenSessionRecovers(t *testing.T) {
|
||||
isolateEnv(t)
|
||||
dir := t.TempDir()
|
||||
sp := filepath.Join(os.Getenv("XDG_STATE_HOME"), "vcom", "session.toml")
|
||||
writeFile(t, sp, "active_pane = 'right'\n[left\n")
|
||||
d := teadriver.New(t, newTestModelKeepEnv(t, dir, dir), 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
if p := activeOf(t, d).Path; p != dir {
|
||||
t.Fatalf("pane at %q, want startup %q", p, dir)
|
||||
}
|
||||
d.Press("q")
|
||||
d.Settle(settle)
|
||||
s, err := config.LoadSession()
|
||||
if err != nil || s.Left.Path != dir {
|
||||
t.Fatalf("session after quit: %+v %v", s, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Old session location: restored once, then moved to the state dir.
|
||||
func TestQAOldSessionMigratedThroughUI(t *testing.T) {
|
||||
isolateEnv(t)
|
||||
start, saved := t.TempDir(), t.TempDir()
|
||||
old := filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "vcom", "session.toml")
|
||||
writeFile(t, old, "active_pane = 'left'\n[left]\npath = '"+saved+"'\n[right]\npath = '"+saved+"'\n")
|
||||
m := newTestModelKeepEnv(t, start, start)
|
||||
if m.left.Path != saved {
|
||||
t.Fatalf("old session not restored: left=%q", m.left.Path)
|
||||
}
|
||||
if exists(old) {
|
||||
t.Fatal("old session not removed after migration")
|
||||
}
|
||||
if !exists(filepath.Join(os.Getenv("XDG_STATE_HOME"), "vcom", "session.toml")) {
|
||||
t.Fatal("session not written to the state dir")
|
||||
}
|
||||
}
|
||||
|
||||
// State dir not writable (e.g. XDG_STATE_HOME on a read-only mount): the
|
||||
// old session is read but not applied, because applySession drops the
|
||||
// session whenever Load returns an error.
|
||||
func TestQAOldSessionRestoredWhenStateDirReadOnly(t *testing.T) {
|
||||
t.Skip("BUG QA-16 (P2): if migrating the session to an unwritable state dir fails, state.Load returns the old session with an error and ui.applySession (model.go:5453-5457) discards it: panes are not restored")
|
||||
if os.Geteuid() == 0 {
|
||||
t.Skip("root ignores permissions")
|
||||
}
|
||||
home := isolateEnv(t)
|
||||
start, saved := t.TempDir(), t.TempDir()
|
||||
old := filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "vcom", "session.toml")
|
||||
writeFile(t, old, "active_pane = 'left'\n[left]\npath = '"+saved+"'\n")
|
||||
ro := filepath.Join(home, "ro")
|
||||
if err := os.MkdirAll(ro, 0o500); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { os.Chmod(ro, 0o700) })
|
||||
t.Setenv("XDG_STATE_HOME", filepath.Join(ro, "state"))
|
||||
m := newTestModelKeepEnv(t, start, start)
|
||||
if m.left.Path != saved {
|
||||
t.Fatalf("session not restored: left=%q", m.left.Path)
|
||||
}
|
||||
}
|
||||
|
||||
// newTestModelKeepEnv is newTestModel without re-isolating the environment
|
||||
// (the test prepared files in it).
|
||||
func newTestModelKeepEnv(t *testing.T, left, right string) Model {
|
||||
t.Helper()
|
||||
cfg := config.Default()
|
||||
cfg.UI.IconMode = "ascii"
|
||||
cfg.Startup.LeftPath, cfg.Startup.RightPath = left, right
|
||||
m, err := NewModel(cfg, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { m.cleanupArchiveMounts(); m.cleanupRemoteImageTemp() })
|
||||
return m
|
||||
}
|
||||
|
||||
// QA-1 bypass: one item the trash refuses (name too long for its
|
||||
// .trashinfo) in a multi-selection with an ordinary file. Only the refused
|
||||
// item may be offered for permanent deletion; the ordinary file belongs in
|
||||
// the trash.
|
||||
func TestQATrashOfferOnlyForRefusedItems(t *testing.T) {
|
||||
t.Skip("BUG QA-17 (P2): when the trash refuses one item, the permanent-delete offer covers it AND every later selected item, which the trash would have accepted (model.go:5314: trashFailed = sources[i:]); confirming deletes them irrecoverably")
|
||||
dir := t.TempDir()
|
||||
long := strings.Repeat("a", 250) // + ".trashinfo" > NAME_MAX
|
||||
writeFile(t, filepath.Join(dir, long), "x")
|
||||
writeFile(t, filepath.Join(dir, "b.txt"), "ordinary")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
m := cur(t, d)
|
||||
for _, e := range m.activePane().Entries {
|
||||
if !e.IsParent {
|
||||
m.activePane().EnsureMarked(e.Path)
|
||||
}
|
||||
}
|
||||
d = teadriver.New(t, m, 160, 40, teadriver.WithoutInit(), teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Press("f8", "enter")
|
||||
d.Settle(settle)
|
||||
if exists(filepath.Join(dir, "b.txt")) {
|
||||
if d.ScreenContains("Not in trash: 2") {
|
||||
t.Fatalf("b.txt (trashable) offered for permanent deletion:\n%s", d.Screen())
|
||||
}
|
||||
}
|
||||
if !exists(filepath.Join(trashFiles(t), "b.txt")) {
|
||||
t.Fatal("b.txt should be in the trash")
|
||||
}
|
||||
}
|
||||
|
||||
// Long names: does the trash accept a 250-byte name at all? (Recorded in
|
||||
// the report; the offer flow covers it.)
|
||||
func TestQATrashLongNameOffered(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
long := strings.Repeat("л", 125) // 250 bytes
|
||||
writeFile(t, filepath.Join(dir, long), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
selectName(t, d, long)
|
||||
d.Press("f8", "enter")
|
||||
d.Settle(settle)
|
||||
if exists(filepath.Join(dir, long)) {
|
||||
if !d.ScreenContains("Delete permanently?") {
|
||||
t.Fatalf("long name neither trashed nor offered:\n%s\nstatus %q", d.Screen(), cur(t, d).status)
|
||||
}
|
||||
d.Press("esc")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(dir, long)) {
|
||||
t.Fatal("esc deleted the file")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// QA-2 neighbour: mirror from a local pane INTO a pane that is inside an
|
||||
// archive. The passive pane keeps its archive mount while showing a real
|
||||
// directory: it stays "read-only" on the real filesystem, can never leave
|
||||
// the archive (root is the temp dir) and the temp dir lingers.
|
||||
func TestQAMirrorIntoArchivePane(t *testing.T) {
|
||||
t.Skip("BUG QA-18 (P2, since v0.2.7): mirror (p) into a pane that is inside an archive sets its path to a real directory but keeps the archive mount: the pane treats the real filesystem as a read-only archive and Backspace never closes the archive (model.go:2667-2669, handleMirrorPane local branch only clears remote mounts)")
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "inner.txt"), "in")
|
||||
if err := vfs.CreateArchive(context.Background(), []string{filepath.Join(dir, "inner.txt")}, filepath.Join(dir, "box.zip"), nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
work := t.TempDir()
|
||||
writeFile(t, filepath.Join(work, "w.txt"), "w")
|
||||
d := newDriver(t, dir, work)
|
||||
selectName(t, d, "box.zip")
|
||||
d.Press("enter") // left into the archive
|
||||
d.Settle(settle)
|
||||
d.Press("tab", "p") // right (local) mirrors into left
|
||||
d.Settle(settle)
|
||||
m := cur(t, d)
|
||||
if m.passivePane().Path == work && m.passivePane().InArchive() {
|
||||
t.Fatalf("passive pane shows %s but is still in the archive", work)
|
||||
}
|
||||
}
|
||||
|
||||
// QA-3 re-check: shifted letters, digits, space and Cyrillic are text in
|
||||
// the filter; arrows still navigate.
|
||||
func TestQAFilterAllPrintable(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "My Kj 2 файл.txt"), "x")
|
||||
writeFile(t, filepath.Join(dir, "other"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
d.Press("/")
|
||||
d.Type("My Kj 2 фа")
|
||||
if q := cur(t, d).filterQuery; q != "My Kj 2 фа" {
|
||||
t.Fatalf("filter query %q", q)
|
||||
}
|
||||
d.Press("enter")
|
||||
if d.ScreenContains("other") {
|
||||
t.Fatalf("filter did not narrow:\n%s", d.Screen())
|
||||
}
|
||||
}
|
||||
|
||||
// QA-4 re-check: '?' typed into every SSH form field; F1 toggles help.
|
||||
func TestQASSHFormQuestionMarkEveryField(t *testing.T) {
|
||||
d := newDriver(t, t.TempDir(), t.TempDir())
|
||||
openSSHAddForm(t, d)
|
||||
for i := 0; i < 5; i++ {
|
||||
d.Type("a?b")
|
||||
if got := cur(t, d).ssh.inputs[i].Value(); got != "a?b" {
|
||||
t.Fatalf("field %d = %q", i, got)
|
||||
}
|
||||
d.Press("tab")
|
||||
}
|
||||
d.Press("f1")
|
||||
if !cur(t, d).ssh.showHelp {
|
||||
t.Fatal("F1 did not open help")
|
||||
}
|
||||
d.Press("f1")
|
||||
if cur(t, d).ssh.showHelp || cur(t, d).modal.kind != modalSSHConnect {
|
||||
t.Fatal("F1 did not close help")
|
||||
}
|
||||
}
|
||||
|
||||
// QA-10 re-check: F7 in an SSH pane: existing name → error, new nested
|
||||
// name works, existing *file* name → error.
|
||||
func TestQARemoteMkdirVariants(t *testing.T) {
|
||||
rdir := t.TempDir()
|
||||
writeFile(t, filepath.Join(rdir, "file"), "x")
|
||||
d := newRemoteDriver(t, rdir, t.TempDir())
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
ok bool
|
||||
}{{"file", false}, {"new/sub", true}, {"new/sub", false}, {"папка", true}} {
|
||||
d.Press("f7")
|
||||
d.Type(tc.name)
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
isErr := classifyStatus(cur(t, d).status) == statusError
|
||||
if cur(t, d).modal.kind != modalNone {
|
||||
d.Press("esc") // the dialog stays open after an error
|
||||
}
|
||||
if isErr == tc.ok {
|
||||
t.Fatalf("mkdir %q: status %q", tc.name, cur(t, d).status)
|
||||
}
|
||||
}
|
||||
if !exists(filepath.Join(rdir, "new", "sub")) || !exists(filepath.Join(rdir, "папка")) {
|
||||
t.Fatal("remote dirs not created")
|
||||
}
|
||||
}
|
||||
|
||||
// When saving the chosen theme fails (broken config, forms SetKey cannot
|
||||
// edit), the user must see it. finalizeTheme sets "Theme: X (save failed:
|
||||
// ...)", but the theme selector overwrites the status with "Theme: X" right
|
||||
// after, so a theme that was not persisted looks saved.
|
||||
func TestQAThemeSaveFailureVisible(t *testing.T) {
|
||||
t.Skip("BUG QA-19 (P2): theme selector overwrites finalizeTheme's \"save failed\" status with \"Theme: X\" (model.go:1645-1648): a theme that was not saved looks saved")
|
||||
isolateEnv(t)
|
||||
dir := t.TempDir()
|
||||
writeFile(t, userConfig(t), "[ui]\nicon_mode = \n")
|
||||
d, _ := newModelLikeMain(t, dir, dir)
|
||||
d.Press("t", "j", "enter")
|
||||
d.Settle(settle)
|
||||
if !strings.Contains(cur(t, d).status, "save failed") {
|
||||
t.Fatalf("theme save failure not reported: %q", cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
|
@ -170,3 +170,159 @@ U-P1-16) **подтверждены** и выдержали попытки об
|
|||
Остальное (QA-2..QA-10) не блокирует релиз; QA-3 (j/k в фильтре) и QA-10 (несоответствие CHANGELOG) стоит взять в
|
||||
следующий хотфикс или в этап 6. CHANGELOG стоит поправить: для F7 указать, что ошибка на существующем имени пока
|
||||
только для локальных панелей.
|
||||
|
||||
---
|
||||
|
||||
## Повторная проверка (RC2)
|
||||
|
||||
Ветка `rework/stabilize` @ `058616d`: это `4bb60d0` плюс один тестовый коммит transfer (3.4). Проверены:
|
||||
- QA-фиксы разработчика C (QA-1 UI, 2, 3, 4, 6, 7, 9, 10, 11);
|
||||
- корзина `localfs.Trash` (fs-часть QA-1, QA-5, QA-8);
|
||||
- изменения 2C, которые использует старый UI: config/SetKey, state/session, paths, atomicfile, logx, сигналы в `main`.
|
||||
|
||||
Новые пакеты `internal/vfs`, `internal/ssh`, `internal/transfer` глубоко не тестировал: прогнаны только их собственные тесты.
|
||||
|
||||
Новые тесты:
|
||||
- `cmd/vcom/qa_signal_test.go` — настоящий `run()` в дочернем процессе на pty (`script`), SIGTERM ×12. **Внимание:**
|
||||
`.gitignore` содержит шаблон `vcom`, а он игнорирует весь каталог `cmd/vcom/`. Файл добавлен через `git add -f`, и
|
||||
новые файлы в `cmd/vcom` у всех будут молча не попадать в коммиты.
|
||||
- `internal/config/qa_rc2_test.go` — SetKey: симлинк, read-only, точечные ключи и inline-таблица, неудачная правка не
|
||||
портит файл, BOM; Load: каталог или нечитаемый файл вместо конфига, отсутствующий `$VCOM_CONFIG`.
|
||||
- `internal/state/qa_rc2_test.go` — пустой/битый session.toml, битый старый, симлинк, миграция в недоступный
|
||||
state-каталог.
|
||||
- `internal/ui/qa_rc2_test.go` — неизвестная тема, битый конфиг + смена темы, `$VCOM_CONFIG` + тема, битая сессия,
|
||||
миграция сессии через UI, обходы QA-1/2/3/4/10, видимость ошибки сохранения темы.
|
||||
- Поправлен мой `TestQATrashCrossDevice`. С новой корзиной он стал реально класть файл в `/dev/shm/.Trash-1000` и
|
||||
оставлял там мусор `on-other-fs.txt*`. Теперь файл получает уникальное имя и удаляется вместе со своим
|
||||
`.trashinfo`, а `.Trash-$uid` удаляется, если его создал тест. Мусор уже удалён, но версия теста в
|
||||
`rework/stabilize` будет мусорить при каждом прогоне (в других worktree уже насорила), пока исправление не смержат.
|
||||
|
||||
### Прогоны
|
||||
|
||||
| Команда | Результат |
|
||||
|---|---|
|
||||
| `make ci` | зелёный |
|
||||
| `go test -race -count=3 ./...` (до и после добавления RC2-тестов) | зелёный, флейков нет |
|
||||
| Ручной e2e: собранный `vcom` в pty, `kill -TERM` / `kill -HUP` | HUP: выход, сессия сохранена, run-dir удалён. TERM: **2 зависания из 9** (QA-12) |
|
||||
|
||||
### QA-фиксы: результат повторной проверки
|
||||
|
||||
| Баг | Проверено | Итог |
|
||||
|---|---|---|
|
||||
| QA-1 | корзина на другом разделе (topdir `/dev/shm/.Trash-1000`), сломанная корзина → предложение удалить безвозвратно, имя 250 байт (корзина отказывает → предложение, Esc сохраняет файл) | закрыт; побочный эффект — QA-17 |
|
||||
| QA-2 | mirror из архива отклоняется | закрыт; соседний путь (mirror *в* архив-панель) — QA-18 |
|
||||
| QA-3 | в фильтр набираются `j k J K`, цифры, пробел, кириллица; стрелки двигают курсор | закрыт |
|
||||
| QA-4 | `?` набирается во всех 5 полях SSH-формы, F1 открывает и закрывает справку | закрыт |
|
||||
| QA-5, QA-8 | мои тесты сняты со skip и проходят | закрыт |
|
||||
| QA-6, QA-7 | мои тесты проходят | закрыт |
|
||||
| QA-9 | `link/` | закрыт |
|
||||
| QA-10 | F7 в SSH: существующий каталог/файл → ошибка; вложенное и кириллическое имя создаются | закрыт |
|
||||
| QA-11 | строка `ssh-mldsa44-ed25519` пропускается | закрыт. На машине мейнтейнера не проверял (не подключаюсь к его хостам) |
|
||||
|
||||
### Новые баги
|
||||
|
||||
#### QA-12 (P1, регрессия 2C — блокирует). SIGTERM иногда навсегда вешает vcom
|
||||
- **Где:** `cmd/vcom/main.go:83-92` подписывается на `SIGTERM` (и `SIGHUP`) и шлёт `tea.Quit`. Bubble Tea сам ловит
|
||||
SIGTERM (`vendor/github.com/charmbracelet/bubbletea/tea.go:286-302`) и шлёт `QuitMsg` в небуферизованный `p.msgs`,
|
||||
не проверяя `ctx`. Если первым дошёл `tea.Quit` из `main`, цикл событий уже завершён, горутина Bubble Tea
|
||||
навсегда висит на отправке, а `Program.shutdown` (`tea.go:814`) ждёт её в `handlers.shutdown()`.
|
||||
- **Шаги:** запустить vcom в терминале, `kill <pid>` (systemd/logout/`kill` по умолчанию).
|
||||
- **Ожидаемое:** выход, терминал восстановлен, сессия сохранена (это и обещает CHANGELOG RC2).
|
||||
- **Фактическое:** в 2 из 9 ручных запусков и в 4 из 12 запусков теста процесс не завершился. Дамп горутин (SIGQUIT):
|
||||
`main.run → Program.Run → shutdown → channelHandlers.shutdown → WaitGroup.Wait`, а
|
||||
`handleSignals.func1` стоит в `chan send`. Терминал остаётся в alt-screen/raw, сессия не сохранена, run-dir не
|
||||
удалён, помогает только `kill -9`. В v0.2.7 SIGTERM обрабатывал только Bubble Tea, и vcom выходил всегда.
|
||||
- **Фикс (для разработчика):** не подписываться на SIGTERM в `main`, оставить там только SIGHUP. Либо отключить
|
||||
обработчик Bubble Tea (`tea.WithoutSignalHandler()`) и обрабатывать оба сигнала в `main`.
|
||||
- **Тест:** `cmd/vcom/qa_signal_test.go` `TestQASigtermExitsAndSavesSession`. Медленный (~95 с из-за таймаута
|
||||
запроса цвета терминала в pty), стоит на skip.
|
||||
|
||||
#### QA-13 (P2). SetKey переписывает read-only конфиг
|
||||
- **Где:** `internal/atomicfile/atomicfile.go:40-52`: temp+rename не смотрит на отсутствие права записи у файла.
|
||||
- **Шаги:** `chmod 444 ~/.config/vcom/vcom.toml`, выбрать тему.
|
||||
- **Ожидаемое:** файл не меняется, ошибка. В v0.2.7 было EACCES.
|
||||
- **Фактическое:** файл переписан, права 0444 сохранены. Конфиг через симлинк в read-only каталог (home-manager,
|
||||
/nix/store) по-прежнему защищён: temp-файл создать нельзя.
|
||||
- **Тест:** `internal/config/qa_rc2_test.go` `TestQASetKeyReadOnlyConfig`.
|
||||
|
||||
#### QA-14 (P2). Тема не сохраняется при `ui.theme = …` в корне или `ui = { theme = … }`
|
||||
- **Где:** `internal/config/setkey.go:86-152`: `editTOML` ищет только `[ui]`, дописывает вторую таблицу `[ui]`, и
|
||||
`verify` отвергает результат.
|
||||
- **Фактическое:** ошибка `table ui already exists` / `key ui should be a table`. Файл не портится (проверено в
|
||||
`TestQASetKeyFailureLeavesFileIntact`), но из-за QA-19 пользователь не узнаёт, что тема не сохранилась.
|
||||
- **Тест:** `TestQASetKeyDottedAndInlineForms`.
|
||||
|
||||
#### QA-15 (P2). При `-config`/`$VCOM_CONFIG` на ещё не существующий файл тема пишется в `~/.config/vcom/vcom.toml`
|
||||
- **Где:** `cmd/vcom/main.go:41-43` передаёт в UI путь, только если файл найден. `SetKey("")` пишет по пути по
|
||||
умолчанию, хотя `LoadInfo.Path` уже содержит нужный путь.
|
||||
- **Фактическое:** создаётся `~/.config/vcom/vcom.toml`. Следующий запуск читает `$VCOM_CONFIG` (файла нет), и тема
|
||||
потеряна.
|
||||
- **Тест:** `internal/ui/qa_rc2_test.go` `TestQAThemeSavedToExplicitMissingConfig`. Тест повторяет логику `main`
|
||||
(`newModelLikeMain`).
|
||||
|
||||
#### QA-16 (P2). Сессия не восстанавливается, если миграция в state-каталог не удалась
|
||||
- **Где:** `state.Load` возвращает прочитанную старую сессию вместе с ошибкой сохранения. `ui.applySession`
|
||||
(`model.go:5453-5457`) при любой ошибке выбрасывает сессию.
|
||||
- **Шаги:** старый `~/.config/vcom/session.toml`, `XDG_STATE_HOME` недоступен для записи.
|
||||
- **Фактическое:** панели открываются на стартовых путях. Старый файл не удаляется (это правильно).
|
||||
- **Тесты:** `TestQAOldSessionRestoredWhenStateDirReadOnly` (ui); поведение `state.Load` зафиксировано в
|
||||
`internal/state/qa_rc2_test.go` `TestQASessionMigrationUnwritableStateDir` (проходит).
|
||||
|
||||
#### QA-17 (P2). Предложение «удалить безвозвратно» захватывает элементы, которые корзина приняла бы
|
||||
- **Где:** `model.go:5314`: `trashFailed = sources[i:]` — неудачный элемент и все следующие за ним.
|
||||
- **Шаги:** выделить файл, который корзина отвергает (имя 250 байт: `.trashinfo` длиннее NAME_MAX), и обычный
|
||||
`b.txt`, F8 → Enter.
|
||||
- **Ожидаемое:** `b.txt` уходит в корзину, а безвозвратное удаление предлагается только для первого файла.
|
||||
- **Фактическое:** диалог «Not in trash: 2». Подтверждение удаляет `b.txt` безвозвратно. Без подтверждения ничего не
|
||||
удаляется, поэтому P2. Но диалог подталкивает удалить то, что можно было восстановить.
|
||||
- **Тест:** `TestQATrashOfferOnlyForRefusedItems`.
|
||||
|
||||
#### QA-18 (P2, есть с v0.2.7). Mirror *в* панель, которая находится в архиве
|
||||
- **Где:** `handleMirrorPane`, локальная ветка (`model.go:2667-2669`): чистит только remote-mount’ы, архивный mount
|
||||
пассивной панели остаётся.
|
||||
- **Фактическое:** пассивная панель показывает настоящий каталог, но остаётся «в архиве». Запись туда запрещена,
|
||||
Backspace никогда не закрывает архив (корень архива — temp-каталог), temp-каталог висит до выхода. Данные не
|
||||
теряются.
|
||||
- **Тест:** `TestQAMirrorIntoArchivePane`.
|
||||
|
||||
#### QA-19 (P2). Ошибка сохранения темы не видна
|
||||
- **Где:** `model.go:1645-1648`: после `finalizeTheme` выбор темы перезаписывает статус «save failed» строкой
|
||||
«Theme: X».
|
||||
- **Фактическое:** при битом конфиге (с RC2 vcom с ним запускается), при QA-13/QA-14 и при любой другой ошибке
|
||||
пользователь видит «Theme: X», хотя тема не сохранена. Сам битый конфиг не трогается (проверено:
|
||||
`TestQABrokenConfigNotOverwrittenByTheme`).
|
||||
- **Тест:** `TestQAThemeSaveFailureVisible`.
|
||||
|
||||
### Проверено без замечаний (2C)
|
||||
- Битый конфиг: vcom стартует с дефолтами, ошибка видна на экране. Мелочь: сообщение `… incomplete number (using
|
||||
defaults)` не содержит слов из `statusErrorWords`, поэтому показано как обычный статус, а не красным.
|
||||
- Неизвестная тема: старт с темой по умолчанию, причина на экране; выбор темы чинит файл, комментарии и прочие
|
||||
ключи сохраняются.
|
||||
- Конфиг-симлинк (dotfiles): ссылка сохраняется, правится цель, права цели сохраняются.
|
||||
- `./vcom.toml` из cwd не загружается (тест разработчика); `$VCOM_CONFIG` на отсутствующий файл корректно отражён в
|
||||
`LoadInfo`; каталог или нечитаемый файл вместо конфига — дефолты и ошибка.
|
||||
- Сессия: пустой и битый файл не мешают старту, выход записывает валидную сессию; битый старый файл не мигрирует и
|
||||
не удаляется; симлинк сохраняется; права 0600, каталог 0700; миграция со старого пути через UI работает, старый
|
||||
файл удаляется.
|
||||
- sudo: прочитал `paths` и тест разработчика `TestSudoWritePathsEffectiveUser`: state/cache/trash/known_hosts
|
||||
пишутся под effective user, при `sudo -E` унаследованные `XDG_*` для записи игнорируются, старый session
|
||||
пользователя не удаляется. Настоящий sudo не запускал. Замечание: под sudo смена темы правит конфиг **вызвавшего**
|
||||
пользователя (`~bob/.config/vcom/vcom.toml`). Владелец сохраняется (`atomicfile` делает chown), но это расходится с
|
||||
doc-комментарием `paths`: «config is READ from the invoking user's home».
|
||||
- logx: файл 0600, каталог 0700, ротация на старте; в вызовах `log.Printf` старого UI секретов не нашёл.
|
||||
- SIGHUP: сессия сохраняется, run-dir удаляется.
|
||||
- После паники в `Update` `Program.Run` возвращает nil-модель, `shutdown(nil)` ничего не делает, и сессия не
|
||||
сохраняется. Doc-комментарий `run()` обещает teardown «or a panic Bubble Tea recovered from». Так было и в v0.2.7;
|
||||
стоит поправить комментарий или сохранять сессию из `recover`.
|
||||
|
||||
### Вердикт RC2
|
||||
|
||||
Все QA-фиксы v0.2.8 (QA-1..QA-11) **подтверждены**, обойти их не удалось. CI и `-race -count=3` зелёные, флейков нет.
|
||||
|
||||
**RC2 к релизу не готов из-за одного бага — QA-12 (P1, регрессия 2C):** vcom зависает на SIGTERM примерно в трети
|
||||
случаев, а именно эту обработку сигналов CHANGELOG RC2 заявляет как новую возможность. Фикс в одну строку: убрать
|
||||
`syscall.SIGTERM` из `signal.Notify` в `main.go`. После него QA-12 нужно перепроверить тестом
|
||||
`TestQASigtermExitsAndSavesSession` (снять skip).
|
||||
|
||||
QA-13..QA-19 — P2, потери данных нет. Желательно до релиза исправить QA-19: без него не видны QA-13/14/15. Остальное
|
||||
можно отложить. Ещё стоит поправить `.gitignore` (`/vcom` вместо `vcom`), чтобы не игнорировался `cmd/vcom/`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue