feat: add android-fs5 CLI toolset

- fs5 entrypoint with status, push, pull, app, shell, logs commands
- lib/adb.sh: ADB wrapper functions with idempotency and --force guards
- lib/output.sh: human + JSON output formatting via Python
- 33 bats tests (6 status, 9 transfer, 7 app, 5 shell, 6 logs) — all passing
- Zero shellcheck warnings
- .env-based config (device serial, log path)
- Spec-Driven Development artifacts in specs/001-android-fs5-management/

Device: exone GmbH FS5 (RD51QE202392, Android 9)
This commit is contained in:
Jane Alesi
2026-03-02 15:55:09 +01:00
commit e6e5f34455
15 changed files with 1713 additions and 0 deletions
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bats
# tests/test_status.bats — Tests for 'fs5 status' command (US1)
bats_require_minimum_version 1.5.0
SCRIPT="${BATS_TEST_DIRNAME}/../fs5"
setup() {
# Ensure .env exists for tests
export DEVICE_SERIAL="RD51QE202392"
export LOG_FILE="/tmp/fs5-test-$$.log"
}
teardown() {
rm -f "${LOG_FILE}"
}
@test "status: shows device info when connected" {
run "${SCRIPT}" status
[ "${status}" -eq 0 ]
[[ "${output}" == *"FS5"* ]] || [[ "${output}" == *"RD51QE202392"* ]]
}
@test "status: exits with code 2 when device serial is wrong" {
DEVICE_SERIAL="INVALID_SERIAL_000" run "${SCRIPT}" status
[ "${status}" -eq 2 ]
[[ "${output}" == *"Device not found"* ]]
}
@test "status: --json flag produces valid JSON" {
run "${SCRIPT}" status --json
[ "${status}" -eq 0 ]
echo "${output}" | python3 -m json.tool > /dev/null
}
@test "status: JSON output contains required fields" {
run "${SCRIPT}" status --json
[ "${status}" -eq 0 ]
echo "${output}" | python3 -c "
import json, sys
d = json.load(sys.stdin)
required = ['serial', 'model', 'android_version', 'battery_level', 'adb_state']
for f in required:
assert f in d, f'Missing field: {f}'
"
}
@test "status: --help shows usage" {
run "${SCRIPT}" status --help
[ "${status}" -eq 0 ]
[[ "${output}" == *"status"* ]]
}
@test "status: completes in under 10 seconds" {
local start end elapsed
start=$(date +%s)
run "${SCRIPT}" status
end=$(date +%s)
elapsed=$(( end - start ))
[ "${elapsed}" -lt 10 ]
}