update tests
authorShane Jaroch <chown_tee@proton.me>
Sat, 17 Jan 2026 02:32:05 +0000 (21:32 -0500)
committerShane Jaroch <chown_tee@proton.me>
Sat, 17 Jan 2026 02:32:30 +0000 (21:32 -0500)
12 files changed:
Makefile
git-remote-gcrypt
tests/broken-test-gc.sh [moved from tests/test-gc.sh with 100% similarity]
tests/coverage_report.py
tests/installer-test-completions.sh [moved from tests/test-completions.sh with 100% similarity]
tests/installer-test-logic.sh [moved from tests/test-install-logic.sh with 100% similarity]
tests/installer-test-verify.sh [moved from tests/verify-system-install.sh with 100% similarity]
tests/system-test-clean-cmd.sh [deleted file]
tests/system-test-clean-command.sh [moved from tests/test-clean-command.sh with 92% similarity]
tests/system-test-privacy-leaks.sh [moved from tests/test-privacy-leaks.sh with 99% similarity]
tests/system-test-rsync-simple.sh [moved from tests/test_rsync_simple.sh with 100% similarity]
tests/system-test-safety-check.sh [moved from tests/test-safety-check.sh with 100% similarity]

index 230644dce5b2de11828be7332992745d856e8b69..0ba4d0a8590adb76ff65c4857519d6f29936dd58 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -110,11 +110,13 @@ test/installer:   ##H Test installer logic
        @rm -rf $(COV_INSTALL)
        @mkdir -p $(COV_INSTALL)
        @export COV_DIR=$(COV_INSTALL); \
-        kcov --bash-dont-parse-binary-dir \
-            --include-pattern=install.sh \
-            --exclude-path=$(PWD)/.git,$(PWD)/tests \
-            $(COV_INSTALL) \
-            ./tests/test-install-logic.sh 2>&1 | tee .tmp/kcov.log; \
+        for test_script in tests/installer-test*.sh; do \
+            kcov --bash-dont-parse-binary-dir \
+                --include-pattern=install.sh \
+                --exclude-path=$(PWD)/.git,$(PWD)/tests \
+                $(COV_INSTALL) \
+                "$$test_script" 2>&1 | tee -a .tmp/kcov.log; \
+        done; \
         if grep -q 'kcov: error:' .tmp/kcov.log; then \
             echo "FAIL: kcov errors detected (see above)"; exit 1; \
         fi
index 9490aeb275c7db1a2e0708af0a3a3df7194c5ca5..91e526bcfdd2d721763869ef0982cbe7361c0390 100755 (executable)
@@ -792,7 +792,9 @@ early_safety_check()
                        return 0
                fi
 
-               if [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
+
+               if [ "$(git config --bool remote."$NAME".gcrypt-allow-unencrypted-remote)" = "true" ] || \
+                  [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
                        return 0
                fi
 
@@ -823,7 +825,9 @@ early_safety_check()
                return 0
        fi
 
-       if [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
+
+       if [ "$(git config --bool remote."$NAME".gcrypt-allow-unencrypted-remote)" = "true" ] || \
+          [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
                return 0
        fi
 
@@ -1153,9 +1157,10 @@ check_safety()
                if [ "$(line_count "$bad_files")" -gt 5 ]; then
                        echo_info "  ... (and others)"
                fi
-               
+
                # Check config to see if we should ignore
-               if [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
+               if [ "$(git config --bool remote."$NAME".gcrypt-allow-unencrypted-remote)" = "true" ] || \
+                  [ "$(git config --bool gcrypt.allow-unencrypted-remote)" = "true" ]; then
                        echo_info "WARNING: Proceeding because gcrypt.allow-unencrypted-remote is set."
                        return 0
                fi
similarity index 100%
rename from tests/test-gc.sh
rename to tests/broken-test-gc.sh
index 0dc89782a5ec013cc97e7342a08172ca0c0c9ef3..3a0234b5cfcc30ca25bfe8edb160a7eb132cf99b 100644 (file)
@@ -51,11 +51,33 @@ else:
 
 
 if missed:
-    missed.sort(key=int)  # Sort for deterministic output
+    missed.sort(key=int)
+    # Group consecutive lines
+    ranges = []
+    if missed:
+        start = int(missed[0])
+        prev = start
+        for x in missed[1:]:
+            curr = int(x)
+            if curr == prev + 1:
+                prev = curr
+            else:
+                if start == prev:
+                    ranges.append(str(start))
+                else:
+                    ranges.append(f"{start}-{prev}")
+                start = curr
+                prev = curr
+        # Append the last range
+        if start == prev:
+            ranges.append(str(start))
+        else:
+            ranges.append(f"{start}-{prev}")
+
     print(f"\033[31;1m{len(missed)} missing lines\033[0m in {patt}:")
     print(
         textwrap.fill(
-            ", ".join(missed), width=72, initial_indent="  ", subsequent_indent="  "
+            ", ".join(ranges), width=72, initial_indent="  ", subsequent_indent="  "
         )
     )
 
diff --git a/tests/system-test-clean-cmd.sh b/tests/system-test-clean-cmd.sh
deleted file mode 100644 (file)
index 930bd3e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-# tests/test-clean-complex.sh
-# Verifies clean command on filenames with spaces and parentheses.
-
-TEST_DIR=$(dirname "$0")
-BIN="$TEST_DIR/../git-remote-gcrypt"
-git_remote_gcrypt() {
-       bash "$BIN" "$@"
-}
-
-# Setup temp environment
-TMPDIR=$(mktemp -d)
-trap 'rm -rf "$TMPDIR"' EXIT
-
-# Create a "remote" bare repo to simulate git backend
-REMOTE_REPO="$TMPDIR/remote.git"
-git init --bare "$REMOTE_REPO" >/dev/null
-
-# Create a commit in the remote with "garbage" files
-# We need to simulate how git-remote-gcrypt stores files (in refs/gcrypt/...)
-# or just in master if it's a raw repo being cleaned?
-# If we run clean --init, we are cleaning a raw repo. So files are in HEAD (or master/main).
-
-# Helper to create commit
-(
-       cd "$TMPDIR" || exit 1
-       mkdir worktree
-       cd worktree || exit 1
-       git init >/dev/null
-       git remote add origin "$REMOTE_REPO"
-
-       # Create files with spaces and parens
-       mkdir -p ".csv"
-       touch ".csv/sheet-shanes-secondary-sheets-Univ Grades (OU).csv"
-       touch "normal.txt"
-
-       git add .
-       git commit -m "Initial commit with garbage" >/dev/null
-       git push origin master >/dev/null
-)
-
-URL="file://$REMOTE_REPO"
-
-echo "--- Status before clean ---"
-# We can use git ls-tree on remote to verify
-git --git-dir="$REMOTE_REPO" ls-tree -r master --name-only
-
-echo "--- Running clean --init --force ---"
-OUTPUT=$(git_remote_gcrypt clean --init --force "$URL" 2>&1)
-EXIT_CODE=$?
-echo "$OUTPUT"
-
-if [ $EXIT_CODE -ne 0 ]; then
-       echo "FAIL: clean command failed."
-       exit 1
-fi
-
-echo "--- Status after clean ---"
-FILES=$(git --git-dir="$REMOTE_REPO" ls-tree -r master --name-only)
-echo "$FILES"
-
-if [[ $FILES == *".csv"* ]]; then
-       # We expect the file to be GONE.
-       # Note: clean --init --force deletes ALL files (because map is not found)
-       # So if there are ANY files left, it's a fail.
-       # But clean command actually updates the refs (typically master or refs/gcrypt/...).
-       # Wait, git-remote-gcrypt clean cleans "refs/heads/master" or "refs/heads/main" if mapped?
-       # No, it checks what files are there.
-       # If standard remote, it might be cleaning HEAD?
-
-       # Let's check if the file persists.
-       if echo "$FILES" | grep -q "Univ Grades"; then
-               echo "FAIL: The complex filename was NOT removed."
-               exit 1
-       fi
-fi
-
-if [ -z "$FILES" ]; then
-       echo "PASS: All files removed."
-else
-       # It might leave an empty tree or commit?
-       echo "FAIL: Files persist: $FILES"
-       exit 1
-fi
similarity index 92%
rename from tests/test-clean-command.sh
rename to tests/system-test-clean-command.sh
index 84de92b336b3a1b072506a795f06d7e287c20f84..7b486de14dbbcf823347b07beb179c0ebeddd73d 100755 (executable)
@@ -22,6 +22,7 @@ export PATH="$SCRIPT_DIR:$PATH"
 # Isolate git config from user environment
 export GIT_CONFIG_SYSTEM=/dev/null
 export GIT_CONFIG_GLOBAL=/dev/null
+unset GIT_CONFIG_PARAMETERS
 
 # Suppress git advice messages
 # Note: git-remote-gcrypt reads actual config files, not just CLI -c options
@@ -84,11 +85,13 @@ mkdir -p "$tempdir/subdir"
 echo "NESTED=123" >"$tempdir/subdir/nested.txt"
 
 echo "SPACE=789" >"$tempdir/Has Space.txt"
+echo "PARENS=ABC" >"$tempdir/Has (Parens).txt"
 
 BLOB1=$($GIT hash-object -w "$tempdir/secret1.txt")
 BLOB2=$($GIT hash-object -w "$tempdir/secret2.txt")
 BLOB3=$($GIT hash-object -w "$tempdir/subdir/nested.txt")
 BLOB4=$($GIT hash-object -w "$tempdir/Has Space.txt")
+BLOB5=$($GIT hash-object -w "$tempdir/Has (Parens).txt")
 
 # Create root tree using index
 export GIT_INDEX_FILE=index.dirty
@@ -96,6 +99,7 @@ $GIT update-index --add --cacheinfo 100644 "$BLOB1" "secret1.txt"
 $GIT update-index --add --cacheinfo 100644 "$BLOB2" "secret2.txt"
 $GIT update-index --add --cacheinfo 100644 "$BLOB3" "subdir/nested.txt"
 $GIT update-index --add --cacheinfo 100644 "$BLOB4" "Has Space.txt"
+$GIT update-index --add --cacheinfo 100644 "$BLOB5" "Has (Parens).txt"
 TREE=$($GIT write-tree)
 rm index.dirty
 
@@ -129,10 +133,10 @@ assert_grep "Usage: git-remote-gcrypt clean" "$output" "clean shows usage when n
 # --------------------------------------------------
 # Test 2: Safety Check (Abort on non-gcrypt)
 # --------------------------------------------------
-print_info "Test 2: Safety Check (Abort on non-gcrypt)..."
+print_info "Test 2: Safety Check (Abort on non-gcrypt --force)..."
 cd "$tempdir/remote.git"
-output=$("$SCRIPT_DIR/git-remote-gcrypt" clean "$tempdir/remote.git" 2>&1 || :)
-assert_grep "Error: No gcrypt manifest found" "$output" "clean aborts on non-gcrypt repo"
+output=$("$SCRIPT_DIR/git-remote-gcrypt" clean --force "$tempdir/remote.git" 2>&1 || :)
+assert_grep "Error: No gcrypt manifest found" "$output" "clean --force aborts on non-gcrypt repo"
 
 if $GIT ls-tree HEAD | grep -q "secret1.txt"; then
        print_success "Files preserved (Safety check passed)"
@@ -249,9 +253,10 @@ print_info "Test 7: clean --init (Bypass manifest check)..."
 
 # Reuse the dirty remote from earlier ($tempdir/remote.git) which has secret1.txt and secret2.txt
 
-# 1. Standard clean should fail (as tested in Test 2)
+# 2. Standard clean should warn and list files (dry-run)
 output=$("$SCRIPT_DIR/git-remote-gcrypt" clean "gcrypt::$tempdir/remote.git" 2>&1 || :)
-assert_grep "Error: No gcrypt manifest found" "$output" "standard clean fails on dirty remote"
+assert_grep "WARNING: No gcrypt manifest found" "$output" "clean warns on dirty remote"
+assert_grep "Listing all files as potential garbage" "$output" "clean lists files on dirty remote"
 
 # 2. Clean with --init should succeed (scan only)
 output=$("$SCRIPT_DIR/git-remote-gcrypt" clean --init "gcrypt::$tempdir/remote.git" 2>&1 || :)
@@ -260,6 +265,7 @@ assert_grep "Found the following files to remove" "$output" "--init scan found f
 assert_grep "secret1.txt" "$output" "--init found secret1.txt"
 assert_grep "subdir/nested.txt" "$output" "--init found nested file in subdir"
 assert_grep "Has Space.txt" "$output" "--init found file with spaces"
+assert_grep "Has (Parens).txt" "$output" "--init found file with parens"
 
 # 3. Clean with --init --force should remove files
 "$SCRIPT_DIR/git-remote-gcrypt" clean --init --force "gcrypt::$tempdir/remote.git" >/dev/null 2>&1
similarity index 99%
rename from tests/test-privacy-leaks.sh
rename to tests/system-test-privacy-leaks.sh
index 9fce02956f5e73cf70457848f1060b01fc2563a4..1d7929511fafa920b0e215507e6d6dd278b65281 100755 (executable)
@@ -48,6 +48,7 @@ gpg --batch --generate-key "${tempdir}/key_params" >/dev/null 2>&1
 # Git config
 export GIT_CONFIG_SYSTEM=/dev/null
 export GIT_CONFIG_GLOBAL="${tempdir}/gitconfig"
+unset GIT_CONFIG_PARAMETERS
 git config --global user.name "Test User"
 git config --global user.email "test@example.com"
 git config --global init.defaultBranch "master"