test(qa): independent v0.2.8 checks and regression tests
Probe the stage-1 hotfixes from adjacent paths (all archive formats, symlink variants, every text field and layer, trash edge cases, Close under concurrent transfers, background jobs leaving the host) and add a regression pass over the main local and SSH scenarios. Tests exposing open bugs are skipped with BUG QA-n (see plans/rework/05-qa-v0.2.8.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
945ae80c73
commit
4bd84dc8d2
4 changed files with 1511 additions and 0 deletions
397
internal/fs/qa_archive_trash_test.go
Normal file
397
internal/fs/qa_archive_trash_test.go
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
package vfs
|
||||
|
||||
// QA (v0.2.8): independent checks of the stage-1 fixes in archive.go and
|
||||
// ops.go (U-P0-1 archive safety, U-P0-4 trash as default delete, MakeDir).
|
||||
// Tests that expose a still-open bug are skipped with "BUG QA-n" and are
|
||||
// described in plans/rework/05-qa-v0.2.8.md.
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"archive/zip"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func qaWrite(t *testing.T, p string, data 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(data), mode); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Every format: archiving a file whose archive name equals its own name
|
||||
// into the same directory is refused and leaves the source intact.
|
||||
func TestQAArchiveIntoSourceDirAllFormats(t *testing.T) {
|
||||
cases := []struct{ name, format string }{
|
||||
{"data.zip", "zip"},
|
||||
{"data.tar", "tar"},
|
||||
{"data.tar", "tar.gz"}, // data.tar -> data.tar.gz: allowed, different file
|
||||
{"data.gz", "tar.gz"}, // data.gz -> data.tar.gz: allowed
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name+"->"+tc.format, func(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
src := filepath.Join(d, tc.name)
|
||||
payload := strings.Repeat("z", 50000)
|
||||
qaWrite(t, src, payload, 0o644)
|
||||
arc := filepath.Join(d, ArchiveName([]string{src}, tc.format))
|
||||
err := CreateArchive(context.Background(), []string{src}, arc, nil)
|
||||
if arc == src {
|
||||
if err == nil {
|
||||
t.Fatal("archive equal to source must be refused")
|
||||
}
|
||||
} else if err != nil {
|
||||
t.Fatalf("archive %s of %s should work: %v", arc, src, err)
|
||||
}
|
||||
if b, _ := os.ReadFile(src); string(b) != payload {
|
||||
t.Fatalf("source changed (len %d)", len(b))
|
||||
}
|
||||
if left, _ := filepath.Glob(filepath.Join(d, ".vcom-tmp-*")); len(left) != 0 {
|
||||
t.Fatalf("temp files left: %v", left)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// The produced archive must actually contain the source (zip, tar, tar.gz),
|
||||
// i.e. the temp+rename path did not break the formats.
|
||||
func TestQAArchiveContentsRoundTrip(t *testing.T) {
|
||||
for _, format := range []string{"zip", "tar", "tar.gz"} {
|
||||
t.Run(format, func(t *testing.T) {
|
||||
d, out := t.TempDir(), t.TempDir()
|
||||
qaWrite(t, filepath.Join(d, "proj", "a.txt"), "alpha", 0o644)
|
||||
qaWrite(t, filepath.Join(d, "proj", "sub", "б.txt"), "бета", 0o644)
|
||||
src := filepath.Join(d, "proj")
|
||||
arc := filepath.Join(out, ArchiveName([]string{src}, format))
|
||||
if err := CreateArchive(context.Background(), []string{src}, arc, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
names := qaListArchive(t, arc)
|
||||
joined := strings.Join(names, "\n")
|
||||
for _, want := range []string{"a.txt", "б.txt"} {
|
||||
if !strings.Contains(joined, want) {
|
||||
t.Fatalf("%s missing from %s: %v", want, arc, names)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func qaListArchive(t *testing.T, p string) []string {
|
||||
t.Helper()
|
||||
var names []string
|
||||
switch {
|
||||
case strings.HasSuffix(p, ".zip"):
|
||||
zr, err := zip.OpenReader(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer zr.Close()
|
||||
for _, f := range zr.File {
|
||||
names = append(names, f.Name)
|
||||
}
|
||||
default:
|
||||
f, err := os.Open(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
var r io.Reader = f
|
||||
if strings.HasSuffix(p, ".gz") {
|
||||
gz, err := gzip.NewReader(f)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r = gz
|
||||
}
|
||||
tr := tar.NewReader(r)
|
||||
for {
|
||||
h, err := tr.Next()
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
names = append(names, h.Name)
|
||||
}
|
||||
}
|
||||
return names
|
||||
}
|
||||
|
||||
// Overwriting an existing archive after confirmation must not widen its
|
||||
// permissions: a private 0600 archive became world-readable 0644.
|
||||
func TestQAArchiveOverwriteKeepsPermissions(t *testing.T) {
|
||||
t.Skip("BUG QA-6: CreateArchive chmods the new archive to 0644, an existing 0600 archive becomes world-readable (archive.go:354)")
|
||||
d, out := t.TempDir(), t.TempDir()
|
||||
qaWrite(t, filepath.Join(d, "secret.txt"), "pin 1234", 0o600)
|
||||
arc := filepath.Join(out, "secret.zip")
|
||||
qaWrite(t, arc, "old", 0o600)
|
||||
if err := CreateArchive(context.Background(), []string{filepath.Join(d, "secret.txt")}, arc, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
st, err := os.Stat(arc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if st.Mode().Perm() != 0o600 {
|
||||
t.Fatalf("existing 0600 archive replaced with mode %o", st.Mode().Perm())
|
||||
}
|
||||
}
|
||||
|
||||
// A long but valid file name (NAME_MAX is 255 bytes) can no longer be
|
||||
// archived: the temp name ".vcom-tmp-<rand>-<name>" exceeds NAME_MAX.
|
||||
func TestQAArchiveLongName(t *testing.T) {
|
||||
t.Skip("BUG QA-7: archive temp file name adds ~20 bytes to the target name; names near NAME_MAX fail with ENAMETOOLONG (archive.go:344)")
|
||||
d, out := t.TempDir(), t.TempDir()
|
||||
base := strings.Repeat("n", 240)
|
||||
src := filepath.Join(d, base+".txt")
|
||||
qaWrite(t, src, "x", 0o644)
|
||||
arc := filepath.Join(out, ArchiveName([]string{src}, "zip")) // 244 bytes: valid
|
||||
if err := CreateArchive(context.Background(), []string{src}, arc, nil); err != nil {
|
||||
t.Fatalf("archive with a valid %d-byte name failed: %v", len(filepath.Base(arc)), err)
|
||||
}
|
||||
}
|
||||
|
||||
// A source that is a symlink to a directory, archived into that directory:
|
||||
// the link is resolved by nobody, so the check does not see the archive is
|
||||
// inside the (dereferenced) source. Make sure at least nothing is destroyed
|
||||
// and the archive does not contain itself.
|
||||
func TestQAArchiveSymlinkDirSourceIntoTarget(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
proj := filepath.Join(d, "proj")
|
||||
qaWrite(t, filepath.Join(proj, "a.txt"), "alpha", 0o644)
|
||||
link := filepath.Join(d, "link")
|
||||
if err := os.Symlink(proj, link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
arc := filepath.Join(proj, "link.tar")
|
||||
err := CreateArchive(context.Background(), []string{link}, arc, nil)
|
||||
if b, _ := os.ReadFile(filepath.Join(proj, "a.txt")); string(b) != "alpha" {
|
||||
t.Fatal("source content damaged")
|
||||
}
|
||||
if err == nil {
|
||||
for _, n := range qaListArchive(t, arc) {
|
||||
if strings.Contains(n, "link.tar") || strings.Contains(n, ".vcom-tmp") {
|
||||
t.Fatalf("archive contains itself: %v", n)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cancelled archive into a directory with an existing archive: old archive
|
||||
// stays, no temp file (tar and tar.gz paths, the developer only tested zip).
|
||||
func TestQAArchiveCancelKeepsOldAllFormats(t *testing.T) {
|
||||
for _, format := range []string{"zip", "tar", "tar.gz"} {
|
||||
t.Run(format, func(t *testing.T) {
|
||||
d, out := t.TempDir(), t.TempDir()
|
||||
qaWrite(t, filepath.Join(d, "src", "f"), "x", 0o644)
|
||||
src := filepath.Join(d, "src")
|
||||
arc := filepath.Join(out, ArchiveName([]string{src}, format))
|
||||
qaWrite(t, arc, "OLD", 0o644)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
if err := CreateArchive(ctx, []string{src}, arc, nil); err == nil {
|
||||
t.Fatal("cancelled archive should fail")
|
||||
}
|
||||
if b, _ := os.ReadFile(arc); string(b) != "OLD" {
|
||||
t.Fatalf("old archive replaced: %q", b)
|
||||
}
|
||||
if left, _ := filepath.Glob(filepath.Join(out, ".vcom-tmp-*")); len(left) != 0 {
|
||||
t.Fatalf("temp files left: %v", left)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// --- Trash (now the default delete) ---------------------------------------
|
||||
|
||||
func qaTrashHome(t *testing.T) string {
|
||||
t.Helper()
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("XDG_DATA_HOME", filepath.Join(home, ".local", "share"))
|
||||
return filepath.Join(home, ".local", "share", "Trash")
|
||||
}
|
||||
|
||||
// Names with spaces and Cyrillic, and same-name collisions, all land in the
|
||||
// trash under distinct names with a matching .trashinfo.
|
||||
func TestQATrashNamesAndCollisions(t *testing.T) {
|
||||
trash := qaTrashHome(t)
|
||||
work := filepath.Join(os.Getenv("HOME"), "work") // same filesystem as HOME
|
||||
names := []string{"my file.txt", "отчёт 2026.txt"}
|
||||
for _, n := range names {
|
||||
qaWrite(t, filepath.Join(work, "a", n), "A "+n, 0o644)
|
||||
qaWrite(t, filepath.Join(work, "b", n), "B "+n, 0o644)
|
||||
}
|
||||
for _, sub := range []string{"a", "b"} {
|
||||
for _, n := range names {
|
||||
if err := MoveToTrash(filepath.Join(work, sub, n)); err != nil {
|
||||
t.Fatalf("MoveToTrash(%s/%s): %v", sub, n, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
files, _ := os.ReadDir(filepath.Join(trash, "files"))
|
||||
infos, _ := os.ReadDir(filepath.Join(trash, "info"))
|
||||
if len(files) != 4 || len(infos) != 4 {
|
||||
t.Fatalf("want 4 trashed files and 4 infos, got %d/%d", len(files), len(infos))
|
||||
}
|
||||
for _, f := range files {
|
||||
if _, err := os.Stat(filepath.Join(trash, "info", f.Name()+".trashinfo")); err != nil {
|
||||
t.Errorf("no trashinfo for %s", f.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The XDG trash spec requires Path= in .trashinfo to be percent-encoded
|
||||
// (RFC 2396). Unencoded spaces/Cyrillic/newlines break restore in other
|
||||
// tools (gio, trash-cli) — a newline in a file name corrupts the info file.
|
||||
func TestQATrashInfoPathEncoded(t *testing.T) {
|
||||
t.Skip("BUG QA-5: .trashinfo Path= is written raw, not percent-encoded as the XDG trash spec requires (ops.go:323)")
|
||||
trash := qaTrashHome(t)
|
||||
work := filepath.Join(os.Getenv("HOME"), "work")
|
||||
p := filepath.Join(work, "my file\nx.txt")
|
||||
qaWrite(t, p, "x", 0o644)
|
||||
if err := MoveToTrash(p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b, err := os.ReadFile(filepath.Join(trash, "info", "my file\nx.txt.trashinfo"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var pathLine string
|
||||
for _, l := range strings.Split(string(b), "\n") {
|
||||
if strings.HasPrefix(l, "Path=") {
|
||||
pathLine = strings.TrimPrefix(l, "Path=")
|
||||
}
|
||||
}
|
||||
got, err := url.PathUnescape(pathLine)
|
||||
if err != nil || got != p {
|
||||
t.Fatalf("Path=%q does not decode to %q (err %v)", pathLine, p, err)
|
||||
}
|
||||
}
|
||||
|
||||
// XDG_DATA_HOME must be honoured ($XDG_DATA_HOME/Trash), otherwise vcom and
|
||||
// the desktop use different trash cans.
|
||||
func TestQATrashHonoursXDGDataHome(t *testing.T) {
|
||||
t.Skip("BUG QA-5: MoveToTrash ignores XDG_DATA_HOME and always uses ~/.local/share/Trash (ops.go:286)")
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
xdg := filepath.Join(home, "xdgdata")
|
||||
t.Setenv("XDG_DATA_HOME", xdg)
|
||||
p := filepath.Join(home, "f.txt")
|
||||
qaWrite(t, p, "x", 0o644)
|
||||
if err := MoveToTrash(p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(xdg, "Trash", "files", "f.txt")); err != nil {
|
||||
t.Fatalf("file not in $XDG_DATA_HOME/Trash: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// otherDevice returns a writable directory on a different filesystem than
|
||||
// home, or "" if none is available.
|
||||
func otherDevice(t *testing.T, home string) string {
|
||||
t.Helper()
|
||||
var hs syscall.Stat_t
|
||||
if err := syscall.Stat(home, &hs); err != nil {
|
||||
return ""
|
||||
}
|
||||
wd, _ := os.Getwd()
|
||||
for _, cand := range []string{"/dev/shm", os.Getenv("XDG_RUNTIME_DIR"), "/var/tmp", wd} {
|
||||
if cand == "" {
|
||||
continue
|
||||
}
|
||||
var cs syscall.Stat_t
|
||||
if err := syscall.Stat(cand, &cs); err != nil || cs.Dev == hs.Dev {
|
||||
continue
|
||||
}
|
||||
dir, err := os.MkdirTemp(cand, ".vcom-qa-*")
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
t.Cleanup(func() { os.RemoveAll(dir) })
|
||||
return dir
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// With trash as the default, deleting a file on another filesystem than
|
||||
// $HOME (/tmp on tmpfs, /mnt, USB, a second disk) must still work: the spec
|
||||
// uses $topdir/.Trash-$uid or a copy. Here MoveToTrash only does os.Rename
|
||||
// and fails with EXDEV.
|
||||
func TestQATrashCrossDevice(t *testing.T) {
|
||||
t.Skip("BUG QA-1: MoveToTrash fails with EXDEV for files on another filesystem than $HOME; with trash now the default, F8+Enter cannot delete files in /tmp, /mnt, USB disks (ops.go:312)")
|
||||
home := qaTrashHome(t)
|
||||
_ = home
|
||||
dir := otherDevice(t, os.Getenv("HOME"))
|
||||
if dir == "" {
|
||||
t.Skip("no second filesystem available")
|
||||
}
|
||||
p := filepath.Join(dir, "on-other-fs.txt")
|
||||
qaWrite(t, p, "x", 0o644)
|
||||
if err := MoveToTrash(p); err != nil {
|
||||
t.Fatalf("MoveToTrash across filesystems: %v", err)
|
||||
}
|
||||
if _, err := os.Lstat(p); !os.IsNotExist(err) {
|
||||
t.Fatal("file still in place")
|
||||
}
|
||||
}
|
||||
|
||||
// A trashed broken symlink with the same name must not be silently replaced
|
||||
// by the next trashed item (collision check uses Stat, which follows links).
|
||||
func TestQATrashCollisionWithBrokenSymlink(t *testing.T) {
|
||||
t.Skip("BUG QA-8: trash collision check uses os.Stat; a broken symlink already in Trash/files is overwritten by the next item with that name (ops.go:303)")
|
||||
trash := qaTrashHome(t)
|
||||
work := filepath.Join(os.Getenv("HOME"), "work")
|
||||
if err := os.MkdirAll(work, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
link := filepath.Join(work, "x")
|
||||
if err := os.Symlink("/nonexistent/target", link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := MoveToTrash(link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
qaWrite(t, link, "file now", 0o644)
|
||||
if err := MoveToTrash(link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
files, _ := os.ReadDir(filepath.Join(trash, "files"))
|
||||
if len(files) != 2 {
|
||||
t.Fatalf("want 2 items in trash, got %d (first one overwritten)", len(files))
|
||||
}
|
||||
}
|
||||
|
||||
// --- MakeDir ---------------------------------------------------------------
|
||||
|
||||
func TestQAMakeDirEdgeCases(t *testing.T) {
|
||||
d := t.TempDir()
|
||||
if _, err := MakeDir(d, "a/b"); err != nil {
|
||||
t.Fatalf("nested name: %v", err)
|
||||
}
|
||||
if _, err := MakeDir(d, "a/b"); err == nil {
|
||||
t.Fatal("existing nested dir must error")
|
||||
}
|
||||
if _, err := MakeDir(d, "a"); err == nil {
|
||||
t.Fatal("existing parent must error")
|
||||
}
|
||||
qaWrite(t, filepath.Join(d, "file"), "x", 0o644)
|
||||
if _, err := MakeDir(d, "file"); err == nil {
|
||||
t.Fatal("name of an existing file must error")
|
||||
}
|
||||
if _, err := MakeDir(d, "папка с пробелом"); err != nil {
|
||||
t.Fatalf("cyrillic name: %v", err)
|
||||
}
|
||||
}
|
||||
177
internal/fs/remote/qa_remote_test.go
Normal file
177
internal/fs/remote/qa_remote_test.go
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
package remote
|
||||
|
||||
// QA (v0.2.8): independent checks of N-P0-3 (RemoveRecursive never follows
|
||||
// symlinks) and N-P0-8 (Close is safe under concurrent use, refcount).
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestQARemoveRecursiveSymlinkVariants(t *testing.T) {
|
||||
_, c, dir := setup(t)
|
||||
target := filepath.Join(dir, "target")
|
||||
writeFile(t, filepath.Join(target, "keep.txt"), 10, 0o644)
|
||||
file := filepath.Join(dir, "file.txt")
|
||||
writeFile(t, file, 10, 0o644)
|
||||
|
||||
mk := func(name, to string) string {
|
||||
p := filepath.Join(dir, name)
|
||||
if err := os.Symlink(to, p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return p
|
||||
}
|
||||
cases := map[string]string{
|
||||
"broken": mk("broken", filepath.Join(dir, "nowhere")),
|
||||
"to-file": mk("to-file", file),
|
||||
"relative": mk("relative", "target"),
|
||||
"to-parent": mk("to-parent", ".."),
|
||||
}
|
||||
for name, p := range cases {
|
||||
if err := c.RemoveRecursive(p); err != nil {
|
||||
t.Errorf("%s: RemoveRecursive: %v", name, err)
|
||||
}
|
||||
if _, err := os.Lstat(p); !os.IsNotExist(err) {
|
||||
t.Errorf("%s: link not removed", name)
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(target, "keep.txt")); err != nil {
|
||||
t.Fatalf("target content removed: %v", err)
|
||||
}
|
||||
if _, err := os.Stat(file); err != nil {
|
||||
t.Fatalf("link target file removed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A directory containing symlinks to a sibling directory and to a file
|
||||
// outside: only the links go, targets survive.
|
||||
func TestQARemoveRecursiveDirWithOutsideLinks(t *testing.T) {
|
||||
_, c, dir := setup(t)
|
||||
outside := filepath.Join(dir, "outside")
|
||||
writeFile(t, filepath.Join(outside, "a.txt"), 10, 0o644)
|
||||
writeFile(t, filepath.Join(outside, "b.txt"), 10, 0o644)
|
||||
victim := filepath.Join(dir, "victim")
|
||||
writeFile(t, filepath.Join(victim, "own.txt"), 10, 0o644)
|
||||
if err := os.MkdirAll(filepath.Join(victim, "deep", "deeper"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(outside, filepath.Join(victim, "deep", "deeper", "dirlink")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(filepath.Join(outside, "b.txt"), filepath.Join(victim, "filelink")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := c.RemoveRecursive(victim); err != nil {
|
||||
t.Fatalf("RemoveRecursive: %v", err)
|
||||
}
|
||||
if _, err := os.Lstat(victim); !os.IsNotExist(err) {
|
||||
t.Fatal("victim dir still exists")
|
||||
}
|
||||
for _, f := range []string{"a.txt", "b.txt"} {
|
||||
if _, err := os.Stat(filepath.Join(outside, f)); err != nil {
|
||||
t.Fatalf("outside/%s removed through a link: %v", f, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "link/" (trailing slash) makes lstat resolve the link on POSIX servers.
|
||||
// The UI never builds such paths today, but RemoveRecursive is a public
|
||||
// helper: with a trailing slash it still empties the target.
|
||||
func TestQARemoveRecursiveSymlinkTrailingSlash(t *testing.T) {
|
||||
t.Skip("BUG QA-9 (P2): RemoveRecursive(\"link/\") follows the link (lstat with trailing slash resolves it) and deletes the target's contents (client.go:528)")
|
||||
_, c, dir := setup(t)
|
||||
target := filepath.Join(dir, "target")
|
||||
writeFile(t, filepath.Join(target, "keep.txt"), 10, 0o644)
|
||||
link := filepath.Join(dir, "link")
|
||||
if err := os.Symlink(target, link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = c.RemoveRecursive(link + "/")
|
||||
if _, err := os.Stat(filepath.Join(target, "keep.txt")); err != nil {
|
||||
t.Fatalf("target content removed via link/: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Close while uploads and downloads are streaming: errors, no panic, no race.
|
||||
func TestQACloseDuringTransfers(t *testing.T) {
|
||||
_, c, dir := setup(t)
|
||||
src := filepath.Join(dir, "big.bin")
|
||||
writeFile(t, src, 4<<20, 0o644)
|
||||
var wg sync.WaitGroup
|
||||
panics := make(chan any, 16)
|
||||
for i := 0; i < 3; i++ {
|
||||
wg.Add(2)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
panics <- r
|
||||
}
|
||||
}()
|
||||
_ = c.CopyFileToRemote(src, filepath.Join(dir, "up", "u"+string(rune('0'+i))))
|
||||
}(i)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
panics <- r
|
||||
}
|
||||
}()
|
||||
_ = c.CopyFileFromRemote(src, filepath.Join(dir, "down", "d"+string(rune('0'+i))))
|
||||
_ = c.RemoveRecursive(filepath.Join(dir, "up"))
|
||||
_ = c.ExecWithProgress("true", func(string) {})
|
||||
_ = c.MkdirAll(filepath.Join(dir, "m", "n"))
|
||||
}(i)
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
var cw sync.WaitGroup
|
||||
for i := 0; i < 3; i++ {
|
||||
cw.Add(1)
|
||||
go func() { defer cw.Done(); c.Close() }()
|
||||
}
|
||||
cw.Wait()
|
||||
wg.Wait()
|
||||
close(panics)
|
||||
for p := range panics {
|
||||
t.Fatalf("panic during Close: %v", p)
|
||||
}
|
||||
if c.IsConnected() {
|
||||
t.Fatal("still connected after Close")
|
||||
}
|
||||
}
|
||||
|
||||
// Concurrent Acquire/Release from panels and jobs: the client is closed
|
||||
// exactly when the last user leaves, never earlier.
|
||||
func TestQAAcquireReleaseConcurrent(t *testing.T) {
|
||||
_, c, dir := setup(t)
|
||||
const n = 50
|
||||
for i := 0; i < n; i++ {
|
||||
c.Acquire()
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < n; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_, _ = c.ReadDir(dir)
|
||||
c.Release()
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
if !c.IsConnected() {
|
||||
t.Fatal("client closed while the original user still holds it")
|
||||
}
|
||||
if c.Users() != 1 {
|
||||
t.Fatalf("users=%d, want 1", c.Users())
|
||||
}
|
||||
c.Release()
|
||||
if c.IsConnected() {
|
||||
t.Fatal("last Release must close")
|
||||
}
|
||||
// Extra Release (double release by a buggy caller) must not panic.
|
||||
c.Release()
|
||||
}
|
||||
458
internal/ui/qa_hotfix_test.go
Normal file
458
internal/ui/qa_hotfix_test.go
Normal file
|
|
@ -0,0 +1,458 @@
|
|||
package ui
|
||||
|
||||
// QA (v0.2.8): independent checks of the stage-1 UI hotfixes, aimed at the
|
||||
// paths next to the ones the developer fixed. Tests that expose an open bug
|
||||
// are skipped with "BUG QA-n"; see plans/rework/05-qa-v0.2.8.md.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/muesli/termenv"
|
||||
|
||||
vfs "vcom/internal/fs"
|
||||
"vcom/internal/testutil/teadriver"
|
||||
)
|
||||
|
||||
// --- U-P1-5: Cyrillic / arbitrary text in every input ---------------------
|
||||
|
||||
// Mkdir and rename fields must accept the letters that are also dialog
|
||||
// keys elsewhere: q (close), n (no), y (confirm), j/k (move), ? (help).
|
||||
func TestQATextModalsAcceptCommandLetters(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "old.txt"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
d.Press("f7")
|
||||
d.Type("qnyjk?п")
|
||||
if got := cur(t, d).modal.input.Value(); got != "qnyjk?п" {
|
||||
t.Fatalf("mkdir input %q, want %q", got, "qnyjk?п")
|
||||
}
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(dir, "qnyjk?п")) {
|
||||
t.Fatalf("dir not created, status %q", cur(t, d).status)
|
||||
}
|
||||
|
||||
selectName(t, d, "old.txt")
|
||||
d.Press("f2", "ctrl+u")
|
||||
d.Type("qй ё?.txt")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(dir, "qй ё?.txt")) {
|
||||
t.Fatalf("rename failed, status %q", cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// The filter is a text field: typing "jpg" or "kotlin" must filter by that
|
||||
// text. j/k are bound to Up/Down inside the filter handler and never reach
|
||||
// the input.
|
||||
func TestQAFilterAcceptsJK(t *testing.T) {
|
||||
t.Skip("BUG QA-3: j and k typed into the filter move the cursor instead of being typed (filter handler matches keys.Up/Down = k/j before the input, model.go:1015-1020); filtering for \"jpg\" yields \"pg\"")
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "photo.jpg"), "x")
|
||||
writeFile(t, filepath.Join(dir, "notes.txt"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
d.Press("/")
|
||||
d.Type("jpg")
|
||||
if q := cur(t, d).filterQuery; q != "jpg" {
|
||||
t.Fatalf("filter query %q, want jpg", q)
|
||||
}
|
||||
}
|
||||
|
||||
// Cyrillic filter: the list really narrows (the developer only checked the
|
||||
// query string).
|
||||
func TestQAFilterCyrillicNarrows(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "отчёт.txt"), "x")
|
||||
writeFile(t, filepath.Join(dir, "summary.txt"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
d.Press("/")
|
||||
d.Type("отч")
|
||||
d.Press("enter")
|
||||
s := d.Screen()
|
||||
if !strings.Contains(s, "отчёт.txt") || strings.Contains(s, "summary.txt") {
|
||||
t.Fatalf("Cyrillic filter did not narrow the list:\n%s", s)
|
||||
}
|
||||
}
|
||||
|
||||
func openSSHAddForm(t *testing.T, d *teadriver.Driver) {
|
||||
t.Helper()
|
||||
d.Press("s") // SSH host list
|
||||
d.Settle(settle)
|
||||
if p := activeOf(t, d).Path; p != sshHostListPath {
|
||||
t.Fatalf("SSH host list not opened, path %q", p)
|
||||
}
|
||||
selectName(t, d, "+ Add host")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if cur(t, d).modal.kind != modalSSHConnect {
|
||||
t.Fatalf("add-host form not opened (modal %d)", cur(t, d).modal.kind)
|
||||
}
|
||||
}
|
||||
|
||||
// SSH form: Cyrillic name, and q/n/y/j/k in fields.
|
||||
func TestQASSHFormCyrillicAndLetters(t *testing.T) {
|
||||
d := newDriver(t, t.TempDir(), t.TempDir())
|
||||
openSSHAddForm(t, d)
|
||||
d.Type("сервер-qnyjk")
|
||||
d.Press("tab")
|
||||
d.Type("host.example")
|
||||
m := cur(t, d)
|
||||
if got := m.ssh.inputs[0].Value(); got != "сервер-qnyjk" {
|
||||
t.Fatalf("name field %q", got)
|
||||
}
|
||||
if got := m.ssh.inputs[1].Value(); got != "host.example" {
|
||||
t.Fatalf("host field %q", got)
|
||||
}
|
||||
if m.modal.kind != modalSSHConnect {
|
||||
t.Fatal("form closed while typing")
|
||||
}
|
||||
}
|
||||
|
||||
// '?' is a valid password character, but in the SSH form it toggles help.
|
||||
func TestQASSHFormPasswordQuestionMark(t *testing.T) {
|
||||
t.Skip("BUG QA-4: '?' (and F1) in the SSH add-host form toggles help instead of being typed; passwords/user names containing '?' cannot be entered (model.go:1563-1568)")
|
||||
d := newDriver(t, t.TempDir(), t.TempDir())
|
||||
openSSHAddForm(t, d)
|
||||
for i := 0; i < 4; i++ {
|
||||
d.Press("tab")
|
||||
}
|
||||
d.Type("pa?ss")
|
||||
if got := cur(t, d).ssh.inputs[4].Value(); got != "pa?ss" {
|
||||
t.Fatalf("password field %q, want pa?ss", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Russian layout in yes/no dialogs: "т" (n) cancels, "н" (y) confirms.
|
||||
func TestQARussianLayoutInConfirm(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "a.txt"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
selectName(t, d, "a.txt")
|
||||
d.Press("f8", "т")
|
||||
d.Settle(settle)
|
||||
if cur(t, d).modal.kind != modalNone || !exists(filepath.Join(dir, "a.txt")) {
|
||||
t.Fatal("т (n on the Russian layout) should cancel")
|
||||
}
|
||||
d.Press("f8", "н")
|
||||
d.Settle(settle)
|
||||
if exists(filepath.Join(dir, "a.txt")) {
|
||||
t.Fatal("н (y on the Russian layout) should confirm")
|
||||
}
|
||||
}
|
||||
|
||||
// --- U-P1-16: q / Esc in every layer --------------------------------------
|
||||
|
||||
func TestQAQAndEscCloseEveryLayer(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "a.txt"), "hello\nworld\n")
|
||||
writeFile(t, filepath.Join(dir, "b.txt"), "x")
|
||||
type layer struct {
|
||||
name string
|
||||
open []string
|
||||
check func(m Model) bool // true while the layer is open
|
||||
}
|
||||
layers := []layer{
|
||||
{"help", []string{"f1"}, func(m Model) bool { return m.modal.kind == modalHelp }},
|
||||
{"theme", []string{"t"}, func(m Model) bool { return m.modal.kind == modalThemeSelect }},
|
||||
{"view", []string{"f3"}, func(m Model) bool { return m.viewMode }},
|
||||
{"info", []string{"f9"}, func(m Model) bool { return m.infoMode }},
|
||||
{"caret", []string{"f9", "i"}, func(m Model) bool { return m.cursorMode || m.infoMode }},
|
||||
{"confirm-delete", []string{"f8"}, func(m Model) bool { return m.modal.kind == modalConfirm }},
|
||||
{"archive-type", []string{"f4"}, func(m Model) bool { return m.modal.kind == modalArchiveType }},
|
||||
{"copy-confirm", []string{"f5"}, func(m Model) bool { return m.modal.kind == modalConfirm }},
|
||||
{"selection", []string{"J"}, func(m Model) bool { return len(m.activePane().MarkedEntries()) > 0 }},
|
||||
}
|
||||
for _, closeKey := range []string{"q", "esc"} {
|
||||
for _, l := range layers {
|
||||
t.Run(closeKey+"/"+l.name, func(t *testing.T) {
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
selectName(t, d, "a.txt")
|
||||
d.Press(l.open...)
|
||||
d.Settle(settle)
|
||||
if !l.check(cur(t, d)) {
|
||||
t.Fatalf("layer did not open")
|
||||
}
|
||||
for i := 0; i < 3 && l.check(cur(t, d)); i++ {
|
||||
d.Press(closeKey)
|
||||
d.Settle(settle)
|
||||
if d.Quit() {
|
||||
t.Fatalf("%s quit the program with %s open", closeKey, l.name)
|
||||
}
|
||||
}
|
||||
if l.check(cur(t, d)) {
|
||||
t.Fatalf("%s did not close %s", closeKey, l.name)
|
||||
}
|
||||
if !exists(filepath.Join(dir, "a.txt")) {
|
||||
t.Fatal("closing a layer deleted a.txt")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- U-P0-1: archive through the UI, all formats ---------------------------
|
||||
|
||||
func TestQAArchiveSameDirZipThroughUI(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
src := filepath.Join(dir, "report.zip")
|
||||
writeFile(t, src, strings.Repeat("r", 40000))
|
||||
d := newDriver(t, dir, dir)
|
||||
selectName(t, d, "report.zip")
|
||||
d.Press("f4")
|
||||
d.Settle(settle)
|
||||
if f := cur(t, d).archiveFormat; f != "zip" {
|
||||
t.Fatalf("default format %q", f)
|
||||
}
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if fileSize(t, src) != 40000 {
|
||||
t.Fatal("report.zip truncated")
|
||||
}
|
||||
if !d.ScreenContains("Cannot archive") {
|
||||
t.Fatalf("no refusal on screen:\n%s", d.Screen())
|
||||
}
|
||||
}
|
||||
|
||||
// Archive a directory into the same pane for every format, then archive it
|
||||
// again over the existing file with confirmation.
|
||||
func TestQAArchiveFormatsAndOverwriteThroughUI(t *testing.T) {
|
||||
formats := []struct {
|
||||
presses int // presses of "f" from the default zip
|
||||
ext string
|
||||
}{{0, ".zip"}, {1, ".tar"}, {2, ".tar.gz"}}
|
||||
for _, f := range formats {
|
||||
t.Run(f.ext, func(t *testing.T) {
|
||||
dir, out := t.TempDir(), t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "proj", "a.txt"), "alpha")
|
||||
d := newDriver(t, dir, out)
|
||||
selectName(t, d, "proj")
|
||||
for round := 0; round < 2; round++ {
|
||||
d.Press("f4")
|
||||
d.Settle(settle)
|
||||
for i := 0; i < f.presses; i++ {
|
||||
d.Press("f")
|
||||
}
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if round == 1 {
|
||||
if !d.ScreenContains("Overwrite existing archive") {
|
||||
t.Fatalf("second archive did not ask to overwrite:\n%s", d.Screen())
|
||||
}
|
||||
d.Press("y")
|
||||
d.Settle(settle)
|
||||
}
|
||||
}
|
||||
arc := filepath.Join(out, "proj"+f.ext)
|
||||
if st, err := os.Stat(arc); err != nil || st.Size() == 0 {
|
||||
t.Fatalf("archive %s not written: %v (status %q)", arc, err, cur(t, d).status)
|
||||
}
|
||||
left, _ := filepath.Glob(filepath.Join(out, ".vcom-tmp-*"))
|
||||
if len(left) != 0 {
|
||||
t.Fatalf("temp files left: %v", left)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// --- U-P0-2: archive pane as target, adjacent paths -------------------------
|
||||
|
||||
// Mirror (p) from a pane inside an archive gives the passive pane the
|
||||
// archive's temp extraction directory as a plain local path: it is not
|
||||
// marked as an archive, so canWriteTo lets copy/move write there, and the
|
||||
// directory is deleted when the archive is closed.
|
||||
func TestQAMirrorFromArchiveKeepsReadOnly(t *testing.T) {
|
||||
t.Skip("BUG QA-2: mirror (p) from an archive pane gives the passive pane the temp extraction dir as a plain writable local dir (no archive mount): mkdir/rename/delete/edit/copy there are allowed and silently lost when the archive is closed; the pane is left on a deleted dir (model.go:2620-2626)")
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "inner.txt"), "in archive")
|
||||
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, "precious.txt"), "user data")
|
||||
|
||||
d := newDriver(t, dir, work)
|
||||
selectName(t, d, "box.zip")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if !activeOf(t, d).InArchive() {
|
||||
t.Fatal("did not enter archive")
|
||||
}
|
||||
d.Press("p") // mirror: right pane now shows the archive's temp dir
|
||||
d.Settle(settle)
|
||||
m := cur(t, d)
|
||||
if err := canWriteTo(m.passivePane()); err == nil {
|
||||
// Show the actual loss: move a real file there, close the archive.
|
||||
m.passivePane()
|
||||
t.Fatalf("passive pane %q (mirror of an archive) is writable", m.passivePane().Path)
|
||||
}
|
||||
}
|
||||
|
||||
// Delete/mkdir in a pane that shows an archive's temp dir via mirror.
|
||||
// (Documented together with QA-2.)
|
||||
|
||||
// --- U-P0-3: caret on every profile, with the status line and the filter ---
|
||||
|
||||
func TestQACaretAllProfilesNarrowTerminal(t *testing.T) {
|
||||
for name, profile := range map[string]termenv.Profile{"Ascii": termenv.Ascii, "ANSI": termenv.ANSI, "ANSI256": termenv.ANSI256, "TrueColor": termenv.TrueColor} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "t.txt"), "строка один\n\tтаб\n"+strings.Repeat("длинная ", 40)+"\n")
|
||||
m := newTestModel(t, dir, t.TempDir())
|
||||
d := teadriver.New(t, m, 72, 18, teadriver.WithProfile(profile), teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
selectName(t, d, "t.txt")
|
||||
d.Press("f9")
|
||||
d.Settle(settle)
|
||||
d.Press("i")
|
||||
d.Settle(settle)
|
||||
d.Press("j", "j", "l", "l", "w", "v", "l", "l", "e", "b", "k")
|
||||
_ = d.Screen()
|
||||
d.Press("f3") // view mode on top
|
||||
d.Settle(settle)
|
||||
_ = d.Screen()
|
||||
if n := len(strings.Split(d.Screen(), "\n")); n != 18 {
|
||||
t.Fatalf("view height %d, want 18", n)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// --- U-P1-1: the status line ------------------------------------------------
|
||||
|
||||
// Multi-line and very long errors stay on one line and keep the height.
|
||||
func TestQAStatusLineMultilineAndLong(t *testing.T) {
|
||||
d := newDriver(t, t.TempDir(), t.TempDir())
|
||||
m := cur(t, d)
|
||||
m.status = "Copy failed: first line\nsecond line\r\n" + strings.Repeat("ошибка ", 100)
|
||||
d2 := teadriver.New(t, m, 80, 20, teadriver.WithoutInit())
|
||||
s := d2.Screen()
|
||||
lines := strings.Split(s, "\n")
|
||||
if len(lines) != 20 {
|
||||
t.Fatalf("height %d, want 20", len(lines))
|
||||
}
|
||||
found := false
|
||||
for _, l := range lines {
|
||||
if strings.Contains(l, "first line second line") {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("status not joined on one line:\n%s", s)
|
||||
}
|
||||
}
|
||||
|
||||
// Status line under every profile does not change the line count.
|
||||
func TestQAStatusLineProfiles(t *testing.T) {
|
||||
for _, profile := range []termenv.Profile{termenv.Ascii, termenv.ANSI, termenv.TrueColor} {
|
||||
dir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(dir, "x"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := newTestModel(t, dir, t.TempDir())
|
||||
d := teadriver.New(t, m, 100, 25, teadriver.WithProfile(profile), teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
d.Press("f7")
|
||||
d.Type("x")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if !d.ScreenContains("file exists") {
|
||||
t.Fatalf("profile %v: error not shown:\n%s", profile, d.Screen())
|
||||
}
|
||||
if n := len(strings.Split(d.Screen(), "\n")); n != 25 {
|
||||
t.Fatalf("profile %v: %d lines", profile, n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- U-P0-4: delete defaults to trash ----------------------------------------
|
||||
|
||||
// Multi-selection with names containing spaces and Cyrillic, plus a
|
||||
// directory, all go to the trash.
|
||||
func TestQADeleteToTrashMultiSelection(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
for _, n := range []string{"a b.txt", "отчёт.txt"} {
|
||||
writeFile(t, filepath.Join(dir, n), n)
|
||||
}
|
||||
writeFile(t, filepath.Join(dir, "папка", "inner"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
selectName(t, d, "a b.txt")
|
||||
m := cur(t, d)
|
||||
p := m.activePane()
|
||||
for _, e := range p.Entries {
|
||||
if !e.IsParent {
|
||||
p.EnsureMarked(e.Path)
|
||||
}
|
||||
}
|
||||
d = teadriver.New(t, m, 160, 40, teadriver.WithoutInit(), teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Press("f8")
|
||||
d.Settle(settle)
|
||||
if !d.ScreenContains("to trash") {
|
||||
t.Fatalf("dialog does not say trash:\n%s", d.Screen())
|
||||
}
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
left, _ := os.ReadDir(dir)
|
||||
if len(left) != 0 {
|
||||
t.Fatalf("left in dir: %v (status %q)", left, cur(t, d).status)
|
||||
}
|
||||
trashed, _ := os.ReadDir(trashFiles(t))
|
||||
if len(trashed) != 3 {
|
||||
t.Fatalf("trash has %d items, want 3", len(trashed))
|
||||
}
|
||||
}
|
||||
|
||||
// D toggles to permanent and back: the second D must return to trash.
|
||||
func TestQADeleteModeToggleBack(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "a.txt"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
selectName(t, d, "a.txt")
|
||||
d.Press("f8", "D", "D")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(trashFiles(t), "a.txt")) {
|
||||
t.Fatalf("after D,D the file should go to the trash (status %q)", cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// The delete kind must not leak into the next dialog: after a permanent
|
||||
// delete, the next F8 starts in trash mode again.
|
||||
func TestQADeleteModeResetsBetweenDialogs(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "a.txt"), "x")
|
||||
writeFile(t, filepath.Join(dir, "b.txt"), "y")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
selectName(t, d, "a.txt")
|
||||
d.Press("f8", "D", "esc")
|
||||
selectName(t, d, "b.txt")
|
||||
d.Press("f8", "enter")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(trashFiles(t), "b.txt")) {
|
||||
t.Fatal("cancelled permanent mode leaked into the next delete")
|
||||
}
|
||||
}
|
||||
|
||||
// With trash as default, the user sees the failure when the trash is not
|
||||
// usable (here: a file where the trash directory should be) and the file
|
||||
// stays.
|
||||
func TestQADeleteTrashFailureVisible(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFile(t, filepath.Join(dir, "a.txt"), "x")
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
trash := filepath.Join(os.Getenv("HOME"), ".local", "share", "Trash")
|
||||
writeFile(t, trash, "not a dir")
|
||||
selectName(t, d, "a.txt")
|
||||
d.Press("f8", "enter")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(dir, "a.txt")) {
|
||||
t.Fatal("file lost although the trash is broken")
|
||||
}
|
||||
if st := cur(t, d).status; classifyStatus(st) != statusError || !d.ScreenContains("trash") {
|
||||
t.Fatalf("trash failure not reported: %q\n%s", st, d.Screen())
|
||||
}
|
||||
}
|
||||
479
internal/ui/qa_regression_test.go
Normal file
479
internal/ui/qa_regression_test.go
Normal file
|
|
@ -0,0 +1,479 @@
|
|||
package ui
|
||||
|
||||
// QA (v0.2.8): regression pass over the main user scenarios through the
|
||||
// teadriver (local panes) and through sshtest (remote pane).
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"vcom/internal/config"
|
||||
"vcom/internal/fs/remote"
|
||||
"vcom/internal/testutil/sshtest"
|
||||
"vcom/internal/testutil/teadriver"
|
||||
)
|
||||
|
||||
func readFile(t *testing.T, p string) string {
|
||||
t.Helper()
|
||||
b, err := os.ReadFile(p)
|
||||
if err != nil {
|
||||
t.Fatalf("read %s: %v", p, err)
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// F5 local->local: overwrite confirmed replaces, cancelled keeps.
|
||||
func TestQACopyOverwriteConfirmAndCancel(t *testing.T) {
|
||||
src, dst := t.TempDir(), t.TempDir()
|
||||
writeFile(t, filepath.Join(src, "a.txt"), "NEW")
|
||||
writeFile(t, filepath.Join(dst, "a.txt"), "OLD")
|
||||
d := newDriver(t, src, dst)
|
||||
selectName(t, d, "a.txt")
|
||||
|
||||
d.Press("f5")
|
||||
d.Settle(settle)
|
||||
if !d.ScreenContains("verwrite") {
|
||||
t.Fatalf("no overwrite warning:\n%s", d.Screen())
|
||||
}
|
||||
d.Press("n")
|
||||
d.Settle(settle)
|
||||
if got := readFile(t, filepath.Join(dst, "a.txt")); got != "OLD" {
|
||||
t.Fatalf("cancel overwrote: %q", got)
|
||||
}
|
||||
d.Press("f5")
|
||||
d.Settle(settle)
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if got := readFile(t, filepath.Join(dst, "a.txt")); got != "NEW" {
|
||||
t.Fatalf("confirmed overwrite: %q (status %q)", got, cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// F6 local->local: file and directory, without and with an existing target.
|
||||
func TestQAMoveFileAndDir(t *testing.T) {
|
||||
src, dst := t.TempDir(), t.TempDir()
|
||||
writeFile(t, filepath.Join(src, "f.txt"), "file")
|
||||
writeFile(t, filepath.Join(src, "dir", "inner.txt"), "inner")
|
||||
writeFile(t, filepath.Join(src, "dup.txt"), "NEW")
|
||||
writeFile(t, filepath.Join(dst, "dup.txt"), "OLD")
|
||||
d := newDriver(t, src, dst)
|
||||
for _, n := range []string{"f.txt", "dir"} {
|
||||
selectName(t, d, n)
|
||||
d.Press("f6")
|
||||
d.Settle(settle)
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if exists(filepath.Join(src, n)) || !exists(filepath.Join(dst, n)) {
|
||||
t.Fatalf("move %s failed (status %q)", n, cur(t, d).status)
|
||||
}
|
||||
}
|
||||
if readFile(t, filepath.Join(dst, "dir", "inner.txt")) != "inner" {
|
||||
t.Fatal("moved dir content wrong")
|
||||
}
|
||||
selectName(t, d, "dup.txt")
|
||||
d.Press("f6")
|
||||
d.Settle(settle)
|
||||
d.Press("esc")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(src, "dup.txt")) || readFile(t, filepath.Join(dst, "dup.txt")) != "OLD" {
|
||||
t.Fatal("cancelled move changed files")
|
||||
}
|
||||
d.Press("f6")
|
||||
d.Settle(settle)
|
||||
d.Press("y")
|
||||
d.Settle(settle)
|
||||
if exists(filepath.Join(src, "dup.txt")) || readFile(t, filepath.Join(dst, "dup.txt")) != "NEW" {
|
||||
t.Fatalf("confirmed move-overwrite failed (status %q)", cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// Sorting, hidden files toggle, history back/forward, mirror, info, view,
|
||||
// theme selector, PgUp/PgDn.
|
||||
func TestQABrowseScenarios(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
for i := 0; i < 60; i++ {
|
||||
writeFile(t, filepath.Join(dir, fmt.Sprintf("f%02d.txt", i)), strings.Repeat("x", i))
|
||||
}
|
||||
writeFile(t, filepath.Join(dir, ".hidden"), "h")
|
||||
writeFile(t, filepath.Join(dir, "sub", "deep", "z.txt"), "z")
|
||||
other := t.TempDir()
|
||||
d := newDriver(t, dir, other)
|
||||
|
||||
// hidden toggle
|
||||
before := d.ScreenContains(".hidden")
|
||||
d.Press(".")
|
||||
d.Settle(settle)
|
||||
if d.ScreenContains(".hidden") == before {
|
||||
t.Fatal(". did not toggle hidden files")
|
||||
}
|
||||
|
||||
// sort cycles and changes order
|
||||
first := func() string {
|
||||
p := activeOf(t, d)
|
||||
for _, e := range p.Entries {
|
||||
if !e.IsParent && !e.IsDir {
|
||||
return e.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
order0 := first()
|
||||
changed := false
|
||||
for i := 0; i < 4; i++ {
|
||||
d.Press("g")
|
||||
d.Settle(settle)
|
||||
if first() != order0 {
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
t.Fatal("g never changed the order")
|
||||
}
|
||||
|
||||
// PgDn / PgUp
|
||||
d.Press("pgdown")
|
||||
mid := activeOf(t, d).Cursor
|
||||
d.Press("pgup")
|
||||
if mid == 0 || activeOf(t, d).Cursor >= mid {
|
||||
t.Fatalf("PgDn/PgUp: %d then %d", mid, activeOf(t, d).Cursor)
|
||||
}
|
||||
|
||||
// history
|
||||
selectName(t, d, "sub")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
selectName(t, d, "deep")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
d.Press("alt+left")
|
||||
d.Settle(settle)
|
||||
if p := activeOf(t, d).Path; p != filepath.Join(dir, "sub") {
|
||||
t.Fatalf("history back -> %s", p)
|
||||
}
|
||||
d.Press("alt+right")
|
||||
d.Settle(settle)
|
||||
if p := activeOf(t, d).Path; p != filepath.Join(dir, "sub", "deep") {
|
||||
t.Fatalf("history forward -> %s", p)
|
||||
}
|
||||
|
||||
// mirror
|
||||
d.Press("p")
|
||||
d.Settle(settle)
|
||||
m := cur(t, d)
|
||||
if m.passivePane().Path != filepath.Join(dir, "sub", "deep") {
|
||||
t.Fatalf("mirror: passive at %s", m.passivePane().Path)
|
||||
}
|
||||
|
||||
// info + view
|
||||
selectName(t, d, "z.txt")
|
||||
d.Press("f9")
|
||||
d.Settle(settle)
|
||||
if !cur(t, d).infoMode {
|
||||
t.Fatal("info did not open")
|
||||
}
|
||||
d.Press("f3")
|
||||
d.Settle(settle)
|
||||
if !cur(t, d).viewMode {
|
||||
t.Fatal("view did not open")
|
||||
}
|
||||
d.Press("esc")
|
||||
d.Settle(settle)
|
||||
if cur(t, d).viewMode {
|
||||
t.Fatal("esc did not close view")
|
||||
}
|
||||
d.Press("f9")
|
||||
d.Settle(settle)
|
||||
|
||||
// theme selector: move and confirm
|
||||
d.Press("t")
|
||||
d.Settle(settle)
|
||||
if cur(t, d).modal.kind != modalThemeSelect {
|
||||
t.Fatal("theme selector did not open")
|
||||
}
|
||||
d.Press("j", "enter")
|
||||
d.Settle(settle)
|
||||
if cur(t, d).modal.kind != modalNone {
|
||||
t.Fatal("theme selector did not close on enter")
|
||||
}
|
||||
if n := len(strings.Split(d.Screen(), "\n")); n != 40 {
|
||||
t.Fatalf("height %d after theme change", n)
|
||||
}
|
||||
}
|
||||
|
||||
// F7 with a nested name and the error for an existing one is visible.
|
||||
func TestQAMkdirNestedAndExisting(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
d := newDriver(t, dir, t.TempDir())
|
||||
d.Press("f7")
|
||||
d.Type("a/b")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if !exists(filepath.Join(dir, "a", "b")) {
|
||||
t.Fatalf("nested mkdir failed: %q", cur(t, d).status)
|
||||
}
|
||||
d.Press("f7")
|
||||
d.Type("a")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if classifyStatus(cur(t, d).status) != statusError || !d.ScreenContains("exists") {
|
||||
t.Fatalf("existing dir not reported: %q", cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// --- remote pane (sshtest) -------------------------------------------------
|
||||
|
||||
func TestQARemoteListingCopyBothWays(t *testing.T) {
|
||||
rdir, local := t.TempDir(), t.TempDir()
|
||||
writeFile(t, filepath.Join(rdir, "remote.txt"), "from server")
|
||||
writeFile(t, filepath.Join(rdir, "rdir", "nested.txt"), "nested")
|
||||
writeFile(t, filepath.Join(local, "local.txt"), "from laptop")
|
||||
writeFile(t, filepath.Join(local, "ldir", "n.txt"), "ln")
|
||||
d := newRemoteDriver(t, rdir, local)
|
||||
if !d.ScreenContains("remote.txt") || !d.ScreenContains("rdir") {
|
||||
t.Fatalf("remote listing missing:\n%s", d.Screen())
|
||||
}
|
||||
// remote -> local, file and dir
|
||||
for _, n := range []string{"remote.txt", "rdir"} {
|
||||
selectName(t, d, n)
|
||||
d.Press("f5")
|
||||
d.Settle(settle)
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
}
|
||||
if readFile(t, filepath.Join(local, "remote.txt")) != "from server" || readFile(t, filepath.Join(local, "rdir", "nested.txt")) != "nested" {
|
||||
t.Fatal("remote->local copy wrong")
|
||||
}
|
||||
// local -> remote
|
||||
d.Press("tab")
|
||||
for _, n := range []string{"local.txt", "ldir"} {
|
||||
selectName(t, d, n)
|
||||
d.Press("f5")
|
||||
d.Settle(settle)
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
}
|
||||
if readFile(t, filepath.Join(rdir, "local.txt")) != "from laptop" || readFile(t, filepath.Join(rdir, "ldir", "n.txt")) != "ln" {
|
||||
t.Fatalf("local->remote copy wrong (status %q)", cur(t, d).status)
|
||||
}
|
||||
// the remote pane shows the uploaded files after refresh
|
||||
d.Press("tab", "ctrl+r")
|
||||
d.Settle(settle)
|
||||
if !d.ScreenContains("local.txt") {
|
||||
t.Fatalf("remote pane not refreshed:\n%s", d.Screen())
|
||||
}
|
||||
}
|
||||
|
||||
func TestQARemoteDeleteFileDirAndSymlink(t *testing.T) {
|
||||
rdir := t.TempDir()
|
||||
writeFile(t, filepath.Join(rdir, "f.txt"), "x")
|
||||
writeFile(t, filepath.Join(rdir, "d", "inner.txt"), "x")
|
||||
precious := t.TempDir()
|
||||
writeFile(t, filepath.Join(precious, "keep.txt"), "keep")
|
||||
if err := os.Symlink(precious, filepath.Join(rdir, "link")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// confirm_delete=false must not skip the question for a permanent remote delete
|
||||
m := newTestModel(t, t.TempDir(), t.TempDir(), func(c *config.Config) { c.Behavior.ConfirmDelete = false })
|
||||
c := connectTestHost(t)
|
||||
mountRemote(t, &m, PaneLeft, c, rdir)
|
||||
d := teadriver.New(t, m, 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
for _, n := range []string{"f.txt", "d", "link"} {
|
||||
selectName(t, d, n)
|
||||
d.Press("f8")
|
||||
d.Settle(settle)
|
||||
if cur(t, d).modal.kind != modalConfirm {
|
||||
t.Fatalf("remote delete of %s did not ask (permanent)", n)
|
||||
}
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if exists(filepath.Join(rdir, n)) {
|
||||
t.Fatalf("%s not deleted (status %q)", n, cur(t, d).status)
|
||||
}
|
||||
}
|
||||
if readFile(t, filepath.Join(precious, "keep.txt")) != "keep" {
|
||||
t.Fatal("deleting the remote symlink removed the target content")
|
||||
}
|
||||
if d.ScreenContains("f.txt") {
|
||||
t.Fatalf("remote pane not refreshed after delete:\n%s", d.Screen())
|
||||
}
|
||||
}
|
||||
|
||||
// Remote mkdir with an existing name: the local path now reports an error
|
||||
// (CHANGELOG: "Creating a directory that already exists reports an
|
||||
// error"), the SSH pane still reports success.
|
||||
func TestQARemoteMkdirExisting(t *testing.T) {
|
||||
t.Skip("BUG QA-10 (P2): F7 with an existing name in an SSH pane silently 'succeeds' (mkdirCmd uses Client.MkdirAll, model.go:5312); the local fix from 1.1 was not applied to remote")
|
||||
rdir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(rdir, "taken"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d := newRemoteDriver(t, rdir, t.TempDir())
|
||||
d.Press("f7")
|
||||
d.Type("taken")
|
||||
d.Press("enter")
|
||||
d.Settle(settle)
|
||||
if classifyStatus(cur(t, d).status) != statusError {
|
||||
t.Fatalf("existing remote dir not reported: %q", cur(t, d).status)
|
||||
}
|
||||
}
|
||||
|
||||
// Every local-file action is refused in an SSH pane; none touches the local
|
||||
// file with the same path (adjacent to N-P0-1/N-P0-2: edit, open, view,
|
||||
// archive, unpack, rename, move-within).
|
||||
func TestQARemoteLocalActionsRefused(t *testing.T) {
|
||||
rdir := t.TempDir()
|
||||
conf := filepath.Join(rdir, "app.conf")
|
||||
writeFile(t, conf, "x=1\n")
|
||||
writeFile(t, filepath.Join(rdir, "a.zip"), "PK")
|
||||
t.Setenv("VISUAL", "true")
|
||||
started := recordProcesses(t)
|
||||
d := newRemoteDriver(t, rdir, t.TempDir())
|
||||
selectName(t, d, "app.conf")
|
||||
for _, k := range []string{"f4", "a", "f2", "r", "enter"} {
|
||||
d.Press(k)
|
||||
d.Settle(settle)
|
||||
if mk := cur(t, d).modal.kind; mk != modalNone {
|
||||
t.Fatalf("%s opened modal %d in an SSH pane", k, mk)
|
||||
}
|
||||
}
|
||||
selectName(t, d, "a.zip")
|
||||
for _, k := range []string{"f11", "e", "enter"} {
|
||||
d.Press(k)
|
||||
d.Settle(settle)
|
||||
if mk := cur(t, d).modal.kind; mk != modalNone {
|
||||
t.Fatalf("%s opened modal %d on a remote archive", k, mk)
|
||||
}
|
||||
if activeOf(t, d).InArchive() {
|
||||
t.Fatal("entered a remote archive through the local path")
|
||||
}
|
||||
}
|
||||
if len(*started) != 0 || len(d.Execs()) != 0 {
|
||||
t.Fatalf("local processes started: %v execs=%d", *started, len(d.Execs()))
|
||||
}
|
||||
if readFile(t, conf) != "x=1\n" {
|
||||
t.Fatal("file changed")
|
||||
}
|
||||
}
|
||||
|
||||
// N-P0-8 / N-P1-12 in the UI: a remote copy sent to the background keeps
|
||||
// working after the pane leaves the host; the connection is closed only
|
||||
// when the job is done.
|
||||
func TestQARemoteBackgroundCopyThenLeaveHost(t *testing.T) {
|
||||
rdir, local := t.TempDir(), t.TempDir()
|
||||
data := sshtest.WriteRandom(t, filepath.Join(rdir, "big.bin"), 2<<20, 0o644)
|
||||
|
||||
m := newTestModel(t, local, local) // isolates HOME before connecting
|
||||
srv := sshtest.Start(t, sshtest.Options{})
|
||||
proxy := sshtest.NewProxy(t, srv.Addr)
|
||||
c, err := remote.Connect(remote.SSHHost{Name: "testhost", HostName: "127.0.0.1", Port: proxy.Port(), User: "u", Password: srv.Password})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { c.Close() })
|
||||
|
||||
mountRemote(t, &m, PaneLeft, c, "/")
|
||||
p := m.paneByID(PaneLeft)
|
||||
p.Path = rdir
|
||||
if err := m.reloadRemotePane(PaneLeft, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d := teadriver.New(t, m, 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
selectName(t, d, "big.bin")
|
||||
proxy.SetDelay(2 * time.Millisecond)
|
||||
d.Press("f5")
|
||||
d.Settle(settle)
|
||||
d.Press("enter") // job starts: holds its own client reference
|
||||
if cur(t, d).modal.kind != modalCopyProgress {
|
||||
t.Fatalf("no progress dialog (modal %d)", cur(t, d).modal.kind)
|
||||
}
|
||||
d.Press("b") // background
|
||||
// leave the host: walk up to "/" and once more
|
||||
for i := 0; i < 20 && activeOf(t, d).InRemote(); i++ {
|
||||
d.Press("backspace")
|
||||
}
|
||||
if activeOf(t, d).InRemote() {
|
||||
t.Fatal("could not leave the host")
|
||||
}
|
||||
if !c.IsConnected() {
|
||||
t.Fatal("leaving the host closed the client under the background job")
|
||||
}
|
||||
d.Settle(30 * time.Second)
|
||||
got, err := os.ReadFile(filepath.Join(local, "big.bin"))
|
||||
if err != nil || len(got) != len(data) || string(got) != string(data) {
|
||||
t.Fatalf("background copy incomplete: %d/%d bytes, err %v, status %q", len(got), len(data), err, cur(t, d).status)
|
||||
}
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for c.IsConnected() && time.Now().Before(deadline) {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
if c.IsConnected() {
|
||||
t.Fatal("client not closed after the last user (job) finished")
|
||||
}
|
||||
}
|
||||
|
||||
// Mirror an SSH pane, start a remote delete job, leave the host in both
|
||||
// panes while it runs: no panic or race, the job finishes.
|
||||
func TestQARemoteMirrorDeleteJobAndLeave(t *testing.T) {
|
||||
rdir := t.TempDir()
|
||||
for i := 0; i < 30; i++ {
|
||||
writeFile(t, filepath.Join(rdir, "victim", fmt.Sprintf("f%02d", i)), "x")
|
||||
}
|
||||
writeFile(t, filepath.Join(rdir, "keep.txt"), "k")
|
||||
m := newTestModel(t, t.TempDir(), t.TempDir())
|
||||
c := connectTestHost(t)
|
||||
mountRemote(t, &m, PaneLeft, c, "/")
|
||||
p := m.paneByID(PaneLeft)
|
||||
p.Path = rdir
|
||||
if err := m.reloadRemotePane(PaneLeft, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d := teadriver.New(t, m, 160, 40, teadriver.WithLongCmd(300*time.Millisecond))
|
||||
d.Settle(settle)
|
||||
d.Press("p") // mirror
|
||||
d.Settle(settle)
|
||||
selectName(t, d, "victim")
|
||||
d.Press("f8", "enter", "b") // job holds a reference; send it to the background
|
||||
for i := 0; i < 20 && activeOf(t, d).InRemote(); i++ {
|
||||
d.Press("backspace")
|
||||
}
|
||||
d.Press("tab")
|
||||
for i := 0; i < 20 && activeOf(t, d).InRemote(); i++ {
|
||||
d.Press("backspace")
|
||||
}
|
||||
d.Settle(20 * time.Second)
|
||||
if exists(filepath.Join(rdir, "victim")) {
|
||||
t.Fatalf("delete job did not finish (status %q)", cur(t, d).status)
|
||||
}
|
||||
if !exists(filepath.Join(rdir, "keep.txt")) {
|
||||
t.Fatal("keep.txt removed")
|
||||
}
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for c.IsConnected() && time.Now().Before(deadline) {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
if c.IsConnected() {
|
||||
t.Fatalf("client still open after both panes left and the job ended (users=%d)", c.Users())
|
||||
}
|
||||
}
|
||||
|
||||
// A single known_hosts line with a key type x/crypto/ssh does not know
|
||||
// (OpenSSH 10 post-quantum "ssh-mldsa44-ed25519", present on the
|
||||
// maintainer's machine) makes every connection fail with "parse known_hosts".
|
||||
func TestQAKnownHostsUnknownAlgorithm(t *testing.T) {
|
||||
t.Skip("BUG QA-11 (P1, since v0.2.7): an unknown key algorithm anywhere in ~/.ssh/known_hosts aborts every SSH connection (knownhosts.New parse error is fatal, internal/fs/remote/client.go:174-176)")
|
||||
isolateEnv(t)
|
||||
kh := filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts")
|
||||
writeFile(t, kh, "otherhost ssh-mldsa44-ed25519 AAAAFHNzaC1tbGRzYTQ0LWVkMjU1MTkAAAAA\n")
|
||||
srv := sshtest.Start(t, sshtest.Options{})
|
||||
c, err := remote.Connect(remote.SSHHost{Name: "h", HostName: "127.0.0.1", Port: srv.Port(), User: "u", Password: srv.Password})
|
||||
if err != nil {
|
||||
t.Fatalf("connect fails because of an unrelated known_hosts line: %v", err)
|
||||
}
|
||||
c.Close()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue