diff --git a/scripts/smoke-test.sh.test b/scripts/smoke-test.sh.test new file mode 100644 index 0000000..8694d2f --- /dev/null +++ b/scripts/smoke-test.sh.test @@ -0,0 +1,135 @@ +#!/bin/bash +# Smoke Test Verification Script +# Validates smoke-test.sh output format matches verification-report-template.json + +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +PROJECT_ROOT=$(cd "$SCRIPT_DIR/.." && pwd) +TEST_PASSED=true + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +pass() { + echo -e "${GREEN}[PASS]${NC} $1" +} + +fail() { + echo -e "${RED}[FAIL]${NC} $1" + TEST_PASSED=false +} + +echo "==========================================" +echo " Smoke Test Script Verification" +echo "==========================================" + +# Test 1: Script exists and is executable +if [ -x "$SCRIPT_DIR/smoke-test.sh" ]; then + pass "smoke-test.sh exists and is executable" +else + fail "smoke-test.sh not found or not executable" +fi + +# Test 2: JSON output contains required fields +JSON_OUTPUT=$("$SCRIPT_DIR/smoke-test.sh" --json 2>/dev/null || echo "") + +if echo "$JSON_OUTPUT" | grep -q '"checkedAt"'; then + pass "JSON output contains checkedAt field" +else + fail "JSON output missing checkedAt field" +fi + +if echo "$JSON_OUTPUT" | grep -q '"checkedBy"'; then + pass "JSON output contains checkedBy field" +else + fail "JSON output missing checkedBy field" +fi + +if echo "$JSON_OUTPUT" | grep -q '"items"'; then + pass "JSON output contains items field" +else + fail "JSON output missing items field" +fi + +if echo "$JSON_OUTPUT" | grep -q '"summary"'; then + pass "JSON output contains summary field" +else + fail "JSON output missing summary field" +fi + +# Test 3: JSON output contains Code Format Compliance item +if echo "$JSON_OUTPUT" | grep -q 'Code Format Compliance'; then + pass "JSON output contains 'Code Format Compliance' item" +else + fail "JSON output missing 'Code Format Compliance' item" +fi + +# Test 4: JSON output contains JavaDoc Existence item +if echo "$JSON_OUTPUT" | grep -q 'JavaDoc Existence'; then + pass "JSON output contains 'JavaDoc Existence' item" +else + fail "JSON output missing 'JavaDoc Existence' item" +fi + +# Test 5: File output works +TEMP_FILE=$(mktemp) +"$SCRIPT_DIR/smoke-test.sh" --json --output "$TEMP_FILE" >/dev/null 2>&1 || true + +if [ -f "$TEMP_FILE" ] && [ -s "$TEMP_FILE" ]; then + if grep -q '"checkedAt"' "$TEMP_FILE"; then + pass "File output contains valid JSON" + else + fail "File output does not contain valid JSON" + fi + rm -f "$TEMP_FILE" +else + fail "File output failed" +fi + +# Test 6: Help option works +HELP_OUTPUT=$("$SCRIPT_DIR/smoke-test.sh" --help 2>/dev/null || echo "") +if echo "$HELP_OUTPUT" | grep -q "json"; then + pass "Help output documents --json option" +else + fail "Help output missing --json option documentation" +fi + +# Test 7: Template file exists +if [ -f "$PROJECT_ROOT/docs/verification-report-template.json" ]; then + pass "verification-report-template.json exists" +else + fail "verification-report-template.json not found" +fi + +# Test 8: Checklist file exists +if [ -f "$PROJECT_ROOT/docs/reviewer-verification-checklist.md" ]; then + pass "reviewer-verification-checklist.md exists" +else + fail "reviewer-verification-checklist.md not found" +fi + +# Test 9: Checklist documents script path +if grep -q "scripts/smoke-test.sh" "$PROJECT_ROOT/docs/reviewer-verification-checklist.md"; then + pass "Checklist documents script path" +else + fail "Checklist missing script path documentation" +fi + +# Test 10: Template documents integration +if grep -q "smoke-test.sh" "$PROJECT_ROOT/docs/verification-report-template.json"; then + pass "Template documents smoke-test.sh integration" +else + fail "Template missing smoke-test.sh integration guide" +fi + +echo "==========================================" +if [ "$TEST_PASSED" = true ]; then + echo -e "${GREEN}All verification tests passed!${NC}" + exit 0 +else + echo -e "${RED}Some verification tests failed!${NC}" + exit 1 +fi