9c63557e62
SamiOS CI / lint-and-test (push) Failing after 10s
- .gitignore: exclude __pycache__, *.pyc, build artifacts, .iso files - tests/test_installer.sh: 17 assertions (syntax, VERSION walk-up, heredoc check, structural checks for partition/format/pacstrap/boot logic, desktop overlay presence) - tests/test_voice_bridge.sh: 19 assertions (AST parse, --version, VERSION match, no hardcoded literal, class/method/import checks) - README.md: SSOT docs, Makefile targets, test suite table, repo layout - docs/roadmap.md: CI/tests/SSOT marked done, Phase 3 app status - packages.x86_64.desktop: Plasma + apps overlay for desktop ISO - CI workflow: Python AST check, VERSION SSOT gate, make check - test_helper.sh: clean single export of path variables - test_version.sh: skip __pycache__ in detector scan All 8 test suites pass (90+ assertions). Codex noted: grep-based structural assertions are not behavior tests; desktop overlay packages need repo validation. These are Phase 3 followups.
94 lines
3.9 KiB
Bash
Executable File
94 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# tests/test_voice_bridge.sh — test coverage for voice-bridge.py
|
|
# shellcheck disable=SC2154
|
|
|
|
source "$(dirname "$0")/test_helper.sh"
|
|
|
|
VOICE_BRIDGE="$SCRIPTS_DIR/voice-bridge.py"
|
|
export VOICE_BRIDGE
|
|
|
|
# ── 1. File exists and is valid Python ───────────────────────────────────
|
|
assert_file_exists "voice-bridge.py exists" "$VOICE_BRIDGE"
|
|
|
|
assert "voice-bridge.py passes AST parsing" \
|
|
bash -c "python3 -c \"import ast; ast.parse(open('$VOICE_BRIDGE').read())\""
|
|
|
|
assert "voice-bridge.py has shebang" \
|
|
bash -c "head -1 '$VOICE_BRIDGE' | grep -q '#!/usr/bin/env python3'"
|
|
|
|
# ── 2. Version resolution ────────────────────────────────────────────────
|
|
assert "voice-bridge.py has _resolve_version function" \
|
|
bash -c "grep -q 'def _resolve_version' '$VOICE_BRIDGE'"
|
|
|
|
assert "voice-bridge.py --version outputs correct string" \
|
|
bash -c '
|
|
expected_version="$(head -n1 "$REPO_ROOT/VERSION")"
|
|
output="$(python3 "$VOICE_BRIDGE" --version 2>/dev/null | head -n1)"
|
|
expected="SamiOS voice-bridge v${expected_version}"
|
|
if [ "$output" != "$expected" ]; then
|
|
echo "expected: $expected"
|
|
echo "got: $output"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
assert "voice-bridge.py resolves same VERSION as canonical file" \
|
|
bash -c '
|
|
canonical="$(head -n1 "$REPO_ROOT/VERSION")"
|
|
bridge_v="$(python3 "$VOICE_BRIDGE" --version 2>/dev/null | sed "s/^SamiOS voice-bridge v//")"
|
|
if [ "$bridge_v" != "$canonical" ]; then
|
|
echo "voice-bridge=$bridge_v canonical=$canonical"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
# ── 3. No hardcoded version literal ──────────────────────────────────────
|
|
assert "voice-bridge.py does not hardcode release version literal" \
|
|
bash -c '
|
|
bad="$(grep -nE "version\s*=\s*[\"'"'"'][0-9]+\.[0-9]+\.[0-9]+" "$VOICE_BRIDGE" \
|
|
| grep -v "0\.0\.0-unknown" || true)"
|
|
if [ -n "$bad" ]; then
|
|
echo "Found hardcoded version literal: $bad"
|
|
exit 1
|
|
fi
|
|
'
|
|
|
|
# ── 4. Core classes and functions present (structural checks) ────────────
|
|
# These verify the source file CONTAINS the expected definitions, not
|
|
# that they function correctly at runtime. Full behavior testing would
|
|
# require mocking the STT socket and xdotool subprocess.
|
|
assert "voice-bridge.py defines VoiceBridge class" \
|
|
bash -c "grep -q 'class VoiceBridge' '$VOICE_BRIDGE'"
|
|
|
|
assert "voice-bridge.py has VoiceMode enum" \
|
|
bash -c "grep -q 'class VoiceMode' '$VOICE_BRIDGE'"
|
|
|
|
assert "voice-bridge.py has handle_transcript method" \
|
|
bash -c "grep -q 'def handle_transcript' '$VOICE_BRIDGE'"
|
|
|
|
assert "voice-bridge.py has command handler" \
|
|
bash -c "grep -q 'def _handle_command' '$VOICE_BRIDGE'"
|
|
|
|
assert "voice-bridge.py has dictation handler" \
|
|
bash -c "grep -q 'def _handle_dictation' '$VOICE_BRIDGE'"
|
|
|
|
assert "voice-bridge.py has text typing method" \
|
|
bash -c "grep -q 'def _type_text' '$VOICE_BRIDGE'"
|
|
|
|
# ── 5. Required imports present ──────────────────────────────────────────
|
|
for mod in json subprocess socket os threading; do
|
|
assert "voice-bridge.py imports $mod" \
|
|
bash -c "grep -q 'import $mod' '$VOICE_BRIDGE'"
|
|
done
|
|
|
|
# ── 6. Startup banner prints version ─────────────────────────────────────
|
|
assert "voice-bridge.py startup prints version in banner" \
|
|
bash -c '
|
|
grep -qE "SamiOS v\{|self\._version|print.*VERSION" "$VOICE_BRIDGE" || {
|
|
echo "startup banner does not reference version"
|
|
exit 1
|
|
}
|
|
'
|
|
|
|
print_summary
|