1+ #! /bin/bash
2+ # Complete installer test in isolated environment
3+
4+ set -e
5+
6+ echo " 🧪 CCNotify Complete Installer Test"
7+ echo " ==================================="
8+
9+ # Create temporary directory
10+ TEMP_DIR=$( mktemp -d)
11+ echo " 📁 Test directory: $TEMP_DIR "
12+
13+ # Create virtual environment
14+ echo " 🐍 Creating virtual environment..."
15+ python3 -m venv " $TEMP_DIR /venv"
16+ source " $TEMP_DIR /venv/bin/activate"
17+
18+ # Install dependencies
19+ echo " 📦 Installing dependencies..."
20+ pip install --quiet --upgrade pip
21+ pip install --quiet requests tqdm rich pytest
22+
23+ # Set up test home
24+ export TEST_HOME=" $TEMP_DIR /home"
25+ mkdir -p " $TEST_HOME /.claude"
26+
27+ # Create fake settings.json
28+ cat > " $TEST_HOME /.claude/settings.json" << 'EOF '
29+ {
30+ "version": "1.0",
31+ "hooks": {
32+ "preToolUse": [],
33+ "postToolUse": []
34+ }
35+ }
36+ EOF
37+
38+ # Set HOME to test directory
39+ export HOME=" $TEST_HOME "
40+ export PYTHONPATH=" $( pwd) /src:$PYTHONPATH "
41+
42+ echo " 📍 Test HOME: $HOME "
43+ echo " 📍 Python: $( which python) "
44+ echo " 📍 PYTHONPATH: $PYTHONPATH "
45+
46+ # Test 1: KokoroProvider fix
47+ echo -e " \n🧪 Test 1: KokoroProvider initialization"
48+ echo " ----------------------------------------"
49+
50+ python3 << 'EOF '
51+ import sys
52+ import tempfile
53+ from pathlib import Path
54+
55+ # Test the fix
56+ try:
57+ from ccnotify.tts.kokoro import KokoroProvider
58+
59+ with tempfile.TemporaryDirectory() as tmpdir:
60+ models_dir = Path(tmpdir) / "models"
61+ models_dir.mkdir()
62+
63+ # Create dummy files
64+ (models_dir / "kokoro-v1.0.onnx").write_text("dummy")
65+ (models_dir / "voices-v1.0.bin").write_text("dummy")
66+
67+ # Test with config dict (should work)
68+ config = {
69+ "models_dir": str(models_dir),
70+ "voice": "af_sarah",
71+ "speed": 1.0
72+ }
73+
74+ provider = KokoroProvider(config)
75+ print("✅ KokoroProvider created successfully with config dict")
76+
77+ except Exception as e:
78+ print(f"❌ Error: {e}")
79+ import traceback
80+ traceback.print_exc()
81+ EOF
82+
83+ # Test 2: Setup script
84+ echo -e " \n🧪 Test 2: setup.py --kokoro"
85+ echo " ----------------------------"
86+
87+ cd " $HOME /.claude"
88+ mkdir -p ccnotify
89+ cd ccnotify
90+
91+ # Run setup with force to test the fix
92+ python " $( pwd) /src/ccnotify/setup.py" --kokoro --force 2>&1 | grep -E " (Testing installation|Installation test|Error|Failed|Success)" || true
93+
94+ # Test 3: Full installer flow
95+ echo -e " \n🧪 Test 3: Full installer flow"
96+ echo " -------------------------------"
97+
98+ python3 << 'EOF '
99+ import os
100+ os.environ['HOME'] = os.environ['TEST_HOME']
101+
102+ from ccnotify.cli import execute_install_command
103+
104+ # Test quiet installation
105+ success = execute_install_command(quiet=True, force=True)
106+ print(f"Installation success: {success}")
107+
108+ # Check what was created
109+ ccnotify_dir = os.path.join(os.environ['HOME'], '.claude', 'ccnotify')
110+ if os.path.exists(ccnotify_dir):
111+ print(f"✅ Created: {ccnotify_dir}")
112+ for item in os.listdir(ccnotify_dir):
113+ print(f" - {item}")
114+ else:
115+ print("❌ CCNotify directory not created")
116+ EOF
117+
118+ # Cleanup
119+ deactivate
120+ rm -rf " $TEMP_DIR "
121+
122+ echo -e " \n✅ All tests completed"
0 commit comments