update tests
This commit is contained in:
+131
@@ -0,0 +1,131 @@
|
||||
(ns e2e
|
||||
"E2E test utilities and runner for VHS tape tests."
|
||||
(:require [babashka.fs :as fs]
|
||||
[babashka.process :refer [shell]]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn sh
|
||||
"Run shell command, return exit code."
|
||||
[& args]
|
||||
(:exit (apply shell {:continue true :out :inherit :err :inherit} args)))
|
||||
|
||||
(defn sh-quiet
|
||||
"Run shell command quietly, return exit code."
|
||||
[& args]
|
||||
(:exit (apply shell {:continue true :out nil :err nil} args)))
|
||||
|
||||
(defn setup-test-repo
|
||||
"Setup a test git repository for e2e tests.
|
||||
Usage: (setup-test-repo) or (setup-test-repo \"/tmp/my-repo\")"
|
||||
([] (setup-test-repo "/tmp/lazygitclj-e2e-test"))
|
||||
([repo-dir]
|
||||
(fs/delete-tree repo-dir)
|
||||
(fs/create-dirs repo-dir)
|
||||
|
||||
;; Initialize repo
|
||||
(shell {:dir repo-dir} "git" "init" "-b" "main")
|
||||
(shell {:dir repo-dir} "git" "config" "user.email" "test@example.com")
|
||||
(shell {:dir repo-dir} "git" "config" "user.name" "Test User")
|
||||
|
||||
;; Create initial files
|
||||
(spit (fs/file repo-dir "README.md") "# Test Project\n")
|
||||
(spit (fs/file repo-dir "file1.txt") "line1\n")
|
||||
(spit (fs/file repo-dir "file2.txt") "line2\n")
|
||||
(shell {:dir repo-dir} "git" "add" ".")
|
||||
(shell {:dir repo-dir} "git" "commit" "-m" "Initial commit")
|
||||
|
||||
;; Create feature branch with changes
|
||||
(shell {:dir repo-dir} "git" "checkout" "-b" "feature-branch")
|
||||
(spit (fs/file repo-dir "feature.txt") "feature content\n")
|
||||
(shell {:dir repo-dir} "git" "add" ".")
|
||||
(shell {:dir repo-dir} "git" "commit" "-m" "Add feature")
|
||||
|
||||
;; Go back to main and make uncommitted changes
|
||||
(shell {:dir repo-dir} "git" "checkout" "main")
|
||||
(spit (fs/file repo-dir "file1.txt") "line1\nmodified\n")
|
||||
(spit (fs/file repo-dir "new-file.txt") "new file\n")
|
||||
|
||||
(println "Test repo created at" repo-dir)
|
||||
repo-dir))
|
||||
|
||||
(defn setup-cursor-test-repo
|
||||
"Setup test repo with many files for cursor navigation tests."
|
||||
([] (setup-cursor-test-repo "/tmp/lazygitclj-e2e-cursor"))
|
||||
([repo-dir]
|
||||
(fs/delete-tree repo-dir)
|
||||
(fs/create-dirs repo-dir)
|
||||
|
||||
;; Initialize repo
|
||||
(shell {:dir repo-dir} "git" "init" "-b" "main")
|
||||
(shell {:dir repo-dir} "git" "config" "user.email" "test@test.com")
|
||||
(shell {:dir repo-dir} "git" "config" "user.name" "Test")
|
||||
|
||||
;; Create 20 files
|
||||
(doseq [i (range 1 21)]
|
||||
(spit (fs/file repo-dir (str "file" i ".txt")) (str "content " i "\n")))
|
||||
|
||||
(shell {:dir repo-dir} "git" "add" ".")
|
||||
(shell {:dir repo-dir} "git" "commit" "-m" "Initial")
|
||||
|
||||
;; Modify all files to create unstaged changes
|
||||
(doseq [i (range 1 21)]
|
||||
(spit (fs/file repo-dir (str "file" i ".txt"))
|
||||
(str "content " i "\nmodified " i "\n")))
|
||||
|
||||
(println "Cursor test repo created at" repo-dir)
|
||||
repo-dir))
|
||||
|
||||
(def tests
|
||||
"List of e2e test tapes."
|
||||
["test/e2e/navigation.tape"
|
||||
"test/e2e/cursor-navigation.tape"
|
||||
"test/e2e/staging.tape"
|
||||
"test/e2e/commit.tape"
|
||||
"test/e2e/commit-verify.tape"
|
||||
"test/e2e/branches.tape"
|
||||
"test/e2e/branch-operations.tape"
|
||||
"test/e2e/branches-tabs.tape"
|
||||
"test/e2e/commits-tabs.tape"
|
||||
"test/e2e/stash-operations.tape"
|
||||
"test/e2e/stash-menu.tape"
|
||||
"test/e2e/help-panel.tape"
|
||||
"test/e2e/reset-menu.tape"
|
||||
"test/e2e/undo-redo.tape"])
|
||||
|
||||
(defn run-tape
|
||||
"Run a single VHS tape, return true if passed."
|
||||
[tape]
|
||||
(println)
|
||||
(println "Running:" tape)
|
||||
(println "---")
|
||||
(let [exit-code (sh-quiet "timeout" "60" "vhs" tape)]
|
||||
(if (zero? exit-code)
|
||||
(do (println "PASSED:" tape) true)
|
||||
(do (println "FAILED:" tape) false))))
|
||||
|
||||
(defn run-all
|
||||
"Run all VHS e2e tests."
|
||||
[]
|
||||
(println "Running lazygitclj VHS e2e tests...")
|
||||
(println "=================================")
|
||||
|
||||
(let [results (map run-tape tests)
|
||||
passed (count (filter true? results))
|
||||
failed (count (filter false? results))]
|
||||
|
||||
(println)
|
||||
(println "=================================")
|
||||
(println (str "Results: " passed " passed, " failed " failed"))
|
||||
(println "=================================")
|
||||
|
||||
(when (pos? failed)
|
||||
(System/exit 1))))
|
||||
|
||||
;; Allow running from command line
|
||||
(when (= *file* (System/getProperty "babashka.file"))
|
||||
(let [args *command-line-args*]
|
||||
(case (first args)
|
||||
"setup" (setup-test-repo (or (second args) "/tmp/lazygitclj-e2e-test"))
|
||||
"setup-cursor" (setup-cursor-test-repo (or (second args) "/tmp/lazygitclj-e2e-cursor"))
|
||||
"run" (run-all)
|
||||
(run-all))))
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Run all VHS e2e tests
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
echo "Running lazygitclj VHS e2e tests..."
|
||||
echo "================================="
|
||||
|
||||
# List of test tapes (relative to repo root)
|
||||
TESTS=(
|
||||
"test/e2e/navigation.tape"
|
||||
"test/e2e/cursor-navigation.tape"
|
||||
"test/e2e/staging.tape"
|
||||
"test/e2e/commit.tape"
|
||||
"test/e2e/commit-verify.tape"
|
||||
"test/e2e/branches.tape"
|
||||
"test/e2e/branch-operations.tape"
|
||||
"test/e2e/branches-tabs.tape"
|
||||
"test/e2e/commits-tabs.tape"
|
||||
"test/e2e/stash-operations.tape"
|
||||
"test/e2e/stash-menu.tape"
|
||||
"test/e2e/help-panel.tape"
|
||||
"test/e2e/reset-menu.tape"
|
||||
"test/e2e/undo-redo.tape"
|
||||
)
|
||||
|
||||
PASSED=0
|
||||
FAILED=0
|
||||
|
||||
for tape in "${TESTS[@]}"; do
|
||||
echo ""
|
||||
echo "Running: $tape"
|
||||
echo "---"
|
||||
|
||||
if timeout 60 vhs "$tape" 2>&1; then
|
||||
echo "PASSED: $tape"
|
||||
((PASSED++))
|
||||
else
|
||||
echo "FAILED: $tape"
|
||||
((FAILED++))
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "================================="
|
||||
echo "Results: $PASSED passed, $FAILED failed"
|
||||
echo "================================="
|
||||
|
||||
if [ $FAILED -gt 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Setup test repo with many files for cursor navigation tests
|
||||
|
||||
REPO=/tmp/lazygitclj-e2e-cursor
|
||||
rm -rf "$REPO"
|
||||
mkdir -p "$REPO"
|
||||
cd "$REPO"
|
||||
|
||||
git init -b main
|
||||
git config user.email 'test@test.com'
|
||||
git config user.name 'Test'
|
||||
|
||||
# Create 20 files
|
||||
for i in $(seq 1 20); do
|
||||
echo "content $i" > "file$i.txt"
|
||||
done
|
||||
|
||||
git add .
|
||||
git commit -m 'Initial'
|
||||
|
||||
# Modify all files to create unstaged changes
|
||||
for i in $(seq 1 20); do
|
||||
echo "modified $i" >> "file$i.txt"
|
||||
done
|
||||
|
||||
echo "Cursor test repo created at $REPO"
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Setup a test git repository for e2e tests
|
||||
# Usage: ./setup-test-repo.sh /tmp/test-repo
|
||||
|
||||
REPO_DIR="${1:-/tmp/lazygitclj-e2e-test}"
|
||||
|
||||
# Remove existing repo if present
|
||||
rm -rf "$REPO_DIR"
|
||||
|
||||
# Create and initialize repo
|
||||
mkdir -p "$REPO_DIR"
|
||||
cd "$REPO_DIR"
|
||||
git init -b main
|
||||
|
||||
# Configure git
|
||||
git config user.email "test@example.com"
|
||||
git config user.name "Test User"
|
||||
|
||||
# Create initial files
|
||||
echo "# Test Project" > README.md
|
||||
echo "line1" > file1.txt
|
||||
echo "line2" > file2.txt
|
||||
git add .
|
||||
git commit -m "Initial commit"
|
||||
|
||||
# Create feature branch with changes
|
||||
git checkout -b feature-branch
|
||||
echo "feature content" > feature.txt
|
||||
git add .
|
||||
git commit -m "Add feature"
|
||||
|
||||
# Go back to main and make some uncommitted changes
|
||||
git checkout main
|
||||
echo "modified" >> file1.txt
|
||||
echo "new file" > new-file.txt
|
||||
|
||||
echo "Test repo created at $REPO_DIR"
|
||||
Reference in New Issue
Block a user