Files
drharness/tests/test_skill_unreadable_dir.sh
darthrubik 62739d7fcb Issue 56: Remove try/catch from skill module directory scanning
Replace the try/catch block in collect_paths() lambda with explicit
std::error_code-based error handling using recursive_directory_iterator
constructor and increment() methods that don't throw exceptions.

Error messages include the path that failed and the underlying error
message from the filesystem operation.

Added test_skill_unreadable_dir.sh to verify proper error handling when
a directory is unreadable.
2026-05-27 18:14:25 -05:00

42 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# test_skill_unreadable_dir.sh - Verifies that unreadable directories produce proper error messages
# Create a skill directory with proper content
mkdir -p skills
cat > skills/SKILL.md << 'SKILL'
---
name: test-skill
---
# Test Skill
SKILL
# Create a nested directory and make it unreadable
mkdir -p skills/unreadable_subdir
chmod 000 skills/unreadable_subdir
# Run drharness with -D flag and capture stderr
set +e
OUTPUT=$("${DRHARNESS}" -D -F dummy.chat 2>&1)
EXIT_CODE=$?
set -e
# Verify that it exits with non-zero code due to permission error
if [ "$EXIT_CODE" -eq 0 ]; then
echo "FAIL: Expected non-zero exit code for unreadable directory, got 0"
chmod 755 skills/unreadable_subdir
exit 1
fi
# Verify the error message mentions the directory path
if ! echo "$OUTPUT" | grep -q "Could not scan directory"; then
echo "FAIL: Expected 'Could not scan directory' in error output"
echo "Got: $OUTPUT"
chmod 755 skills/unreadable_subdir
exit 1
fi
# Clean up (restore permissions before removing)
chmod 755 skills/unreadable_subdir
echo "PASS: test_skill_unreadable_dir"