forked from Shinonome/dots-hyprland
Fixed the test and update script
This commit is contained in:
@@ -155,13 +155,14 @@ DRY_RUN=false
|
|||||||
FORCE_CHECK=false
|
FORCE_CHECK=false
|
||||||
VERBOSE=false
|
VERBOSE=false
|
||||||
NON_INTERACTIVE=true
|
NON_INTERACTIVE=true
|
||||||
|
SOURCE_ONLY=true
|
||||||
|
|
||||||
source "$ORIGINAL_DIR/sdata/step/exp-update.sh"
|
source "$ORIGINAL_DIR/sdata/step/exp-update.sh"
|
||||||
detected_dirs=$(detect_repo_structure)
|
detected_dirs=\$(detect_repo_structure)
|
||||||
if [[ -n "$detected_dirs" ]]; then
|
if [[ -n "\$detected_dirs" ]]; then
|
||||||
read -ra MONITOR_DIRS <<<"$detected_dirs"
|
read -ra MONITOR_DIRS <<<"\$detected_dirs"
|
||||||
fi
|
fi
|
||||||
echo "Structure: ${MONITOR_DIRS[*]}"
|
echo "Structure: \${MONITOR_DIRS[*]}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x test_detection.sh
|
chmod +x test_detection.sh
|
||||||
@@ -214,13 +215,14 @@ DRY_RUN=false
|
|||||||
FORCE_CHECK=false
|
FORCE_CHECK=false
|
||||||
VERBOSE=false
|
VERBOSE=false
|
||||||
NON_INTERACTIVE=true
|
NON_INTERACTIVE=true
|
||||||
|
SOURCE_ONLY=true
|
||||||
|
|
||||||
source "$ORIGINAL_DIR/sdata/step/exp-update.sh"
|
source "$ORIGINAL_DIR/sdata/step/exp-update.sh"
|
||||||
detected_dirs=$(detect_repo_structure)
|
detected_dirs=\$(detect_repo_structure)
|
||||||
if [[ -n "$detected_dirs" ]]; then
|
if [[ -n "\$detected_dirs" ]]; then
|
||||||
read -ra MONITOR_DIRS <<<"$detected_dirs"
|
read -ra MONITOR_DIRS <<<"\$detected_dirs"
|
||||||
fi
|
fi
|
||||||
echo "Structure: ${MONITOR_DIRS[*]}"
|
echo "Structure: \${MONITOR_DIRS[*]}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x test_detection.sh
|
chmod +x test_detection.sh
|
||||||
@@ -515,15 +517,17 @@ test_lock_file() {
|
|||||||
echo "99999" > .update-lock
|
echo "99999" > .update-lock
|
||||||
|
|
||||||
# Try to run update - should fail due to lock
|
# Try to run update - should fail due to lock
|
||||||
if ./install.sh exp-update --skip-notice --non-interactive 2>&1 | grep -q "stale lock"; then
|
if ./install.sh exp-update --skip-notice --non-interactive > lock_test_output.txt 2>&1; then
|
||||||
log_pass "Lock file mechanism works (detected stale lock)"
|
if grep -q "stale lock" lock_test_output.txt; then
|
||||||
cd "$ORIGINAL_DIR"
|
log_pass "Lock file mechanism works (detected stale lock)"
|
||||||
return 0
|
cd "$ORIGINAL_DIR"
|
||||||
else
|
return 0
|
||||||
log_fail "Lock file mechanism did not work as expected"
|
fi
|
||||||
cd "$ORIGINAL_DIR"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
log_fail "Lock file mechanism did not work as expected"
|
||||||
|
cat lock_test_output.txt # Show output for debugging
|
||||||
|
cd "$ORIGINAL_DIR"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test 13: Test ** substring ignore patterns - FIXED
|
# Test 13: Test ** substring ignore patterns - FIXED
|
||||||
@@ -657,6 +661,7 @@ DRY_RUN=false
|
|||||||
FORCE_CHECK=false
|
FORCE_CHECK=false
|
||||||
VERBOSE=false
|
VERBOSE=false
|
||||||
NON_INTERACTIVE=true
|
NON_INTERACTIVE=true
|
||||||
|
SOURCE_ONLY=true
|
||||||
|
|
||||||
source "$ORIGINAL_DIR/sdata/step/exp-update.sh" 2>/dev/null
|
source "$ORIGINAL_DIR/sdata/step/exp-update.sh" 2>/dev/null
|
||||||
|
|
||||||
@@ -825,6 +830,7 @@ cleanup() {
|
|||||||
cleanup_test_env
|
cleanup_test_env
|
||||||
rm -f test_detection.sh test_ignore.sh test_safe_read.sh test_fresh_clone.sh test_substring_ignore.sh dry_run_output.txt 2>/dev/null || true
|
rm -f test_detection.sh test_ignore.sh test_safe_read.sh test_fresh_clone.sh test_substring_ignore.sh dry_run_output.txt 2>/dev/null || true
|
||||||
rm -f test_caching.sh test_dir_cache.sh 2>/dev/null || true
|
rm -f test_caching.sh test_dir_cache.sh 2>/dev/null || true
|
||||||
|
rm -f lock_test_output.txt 2>/dev/null || true
|
||||||
rm -rf "${HOME}/.config/test-app" 2>/dev/null || true
|
rm -rf "${HOME}/.config/test-app" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,10 +160,16 @@ load_ignore_patterns() {
|
|||||||
[[ -z "$pattern" ]] && continue
|
[[ -z "$pattern" ]] && continue
|
||||||
|
|
||||||
# Separate substring patterns from regular patterns
|
# Separate substring patterns from regular patterns
|
||||||
if [[ "$pattern" == \*\** ]]; then
|
if [[ "${pattern:0:2}" == "**" ]]; then
|
||||||
local cleaned_pattern="${pattern#\*\*}"
|
local cleaned_pattern="${pattern#\*\*}"
|
||||||
cleaned_pattern="${cleaned_pattern%%*}"
|
# Strip trailing asterisks
|
||||||
IGNORE_SUBSTRING_PATTERNS+=("$cleaned_pattern")
|
while [[ "$cleaned_pattern" == *"*" ]] && [[ "${cleaned_pattern: -1}" == "*" ]]; do
|
||||||
|
cleaned_pattern="${cleaned_pattern%\*}"
|
||||||
|
done
|
||||||
|
# Ensure we have a non-empty pattern
|
||||||
|
if [[ -n "$cleaned_pattern" ]]; then
|
||||||
|
IGNORE_SUBSTRING_PATTERNS+=("$cleaned_pattern")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
IGNORE_PATTERNS+=("$pattern")
|
IGNORE_PATTERNS+=("$pattern")
|
||||||
fi
|
fi
|
||||||
@@ -716,12 +722,13 @@ cleanup_on_exit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Set up signal handling and lock file
|
# Set up signal handling and lock file
|
||||||
|
if [[ "${SOURCE_ONLY:-false}" != true ]]; then
|
||||||
trap cleanup_on_exit EXIT INT TERM
|
trap cleanup_on_exit EXIT INT TERM
|
||||||
|
|
||||||
# Check for concurrent runs
|
# Check for concurrent runs
|
||||||
if [[ -f "${REPO_ROOT}/.update-lock" ]]; then
|
if [[ -f "${REPO_ROOT}/.update-lock" ]]; then
|
||||||
# Check if the process is still running
|
# Check if the process is still running
|
||||||
if kill -0 $(cat "${REPO_ROOT}/.update-lock" 2>/dev/null) 2>/dev/null; then
|
if kill -0 "$(cat "${REPO_ROOT}/.update-lock" 2>/dev/null)" 2>/dev/null; then
|
||||||
log_die "Another update is already running (PID: $(cat "${REPO_ROOT}/.update-lock"))"
|
log_die "Another update is already running (PID: $(cat "${REPO_ROOT}/.update-lock"))"
|
||||||
else
|
else
|
||||||
log_warning "Found stale lock file, removing..."
|
log_warning "Found stale lock file, removing..."
|
||||||
@@ -1138,4 +1145,6 @@ if [[ -d "${REPO_ROOT}/.update-backups" ]] && [[ "$DRY_RUN" != true ]]; then
|
|||||||
log_info "Backups stored in: ${REPO_ROOT}/.update-backups/"
|
log_info "Backups stored in: ${REPO_ROOT}/.update-backups/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
Reference in New Issue
Block a user