e62d63aa6f
- Fixed Bash redirection bug () that prevented capturing stderr output. - Replaced with which correctly captures stderr (since stdout is empty on failure). - Ensures validation checks for clean error messages and non-zero exit codes work as intended.
64 lines
1.4 KiB
Bash
64 lines
1.4 KiB
Bash
#!/bin/bash
|
|
# test_skill_validation.sh - Verifies that invalid SKILL.md files cause a fatal error
|
|
|
|
# Test 1: Invalid frontmatter (no closing ---) should crash
|
|
mkdir -p skills
|
|
cat > skills/SKILL.md << 'SKILL'
|
|
---
|
|
name: invalid-skill
|
|
description: No closing
|
|
|
|
# Invalid Skill
|
|
SKILL
|
|
|
|
set +e
|
|
STDERR_OUTPUT=$("${DRHARNESS}" -D -F dummy.chat 2>&1)
|
|
EXIT_CODE=$?
|
|
set -e
|
|
|
|
if [ $EXIT_CODE -eq 0 ]; then
|
|
echo "FAIL: Expected harness to crash on invalid YAML"
|
|
exit 1
|
|
fi
|
|
|
|
if ! echo "$STDERR_OUTPUT" | grep -q "Fatal: Malformed SKILL.md at"; then
|
|
echo "FAIL: Expected clean error message on stderr, got:"
|
|
echo "$STDERR_OUTPUT"
|
|
exit 1
|
|
fi
|
|
|
|
if echo "$STDERR_OUTPUT" | grep -q "terminate called\|stack trace\|terminate"; then
|
|
echo "FAIL: Harness crashed with C++ stack trace instead of clean error"
|
|
echo "$STDERR_OUTPUT"
|
|
exit 1
|
|
fi
|
|
|
|
# Clean up
|
|
rm -rf skills
|
|
|
|
# Test 2: File without frontmatter should crash
|
|
mkdir -p skills
|
|
cat > skills/SKILL.md << 'SKILL'
|
|
# No Frontmatter
|
|
|
|
This skill has no frontmatter.
|
|
SKILL
|
|
|
|
set +e
|
|
STDERR_OUTPUT=$("${DRHARNESS}" -D -F dummy.chat 2>&1)
|
|
EXIT_CODE=$?
|
|
set -e
|
|
|
|
if [ $EXIT_CODE -eq 0 ]; then
|
|
echo "FAIL: Expected harness to crash on file without frontmatter"
|
|
exit 1
|
|
fi
|
|
|
|
if ! echo "$STDERR_OUTPUT" | grep -q "Fatal: Malformed SKILL.md at"; then
|
|
echo "FAIL: Expected clean error message on stderr, got:"
|
|
echo "$STDERR_OUTPUT"
|
|
exit 1
|
|
fi
|
|
|
|
echo "All validation tests passed!"
|