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:
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bats
|
||||
# tests/test_logs.bats — Tests for 'fs5 logs' command (US5)
|
||||
|
||||
bats_require_minimum_version 1.5.0
|
||||
|
||||
SCRIPT="${BATS_TEST_DIRNAME}/../fs5"
|
||||
|
||||
setup() {
|
||||
export DEVICE_SERIAL="RD51QE202392"
|
||||
export LOG_FILE="/tmp/fs5-test-$$.log"
|
||||
LOG_OUTPUT="/tmp/fs5-logcap-$$.txt"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
rm -f "${LOG_FILE}" "${LOG_OUTPUT}"
|
||||
}
|
||||
|
||||
@test "logs --lines: outputs exactly N lines" {
|
||||
run "${SCRIPT}" logs --lines 5
|
||||
[ "${status}" -eq 0 ]
|
||||
local line_count
|
||||
line_count=$(echo "${output}" | wc -l)
|
||||
[ "${line_count}" -ge 1 ]
|
||||
[ "${line_count}" -le 10 ]
|
||||
}
|
||||
|
||||
@test "logs --lines: exits after printing lines (non-streaming)" {
|
||||
# Should complete within 15 seconds (not hang)
|
||||
run timeout 15 "${SCRIPT}" logs --lines 3
|
||||
[ "${status}" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "logs --output: writes to file" {
|
||||
run "${SCRIPT}" logs --lines 5 --output "${LOG_OUTPUT}"
|
||||
[ "${status}" -eq 0 ]
|
||||
[ -f "${LOG_OUTPUT}" ]
|
||||
[ -s "${LOG_OUTPUT}" ]
|
||||
}
|
||||
|
||||
@test "logs --filter: filters by tag" {
|
||||
run "${SCRIPT}" logs --lines 20 --filter "System"
|
||||
[ "${status}" -eq 0 ]
|
||||
# Output may be empty if tag not present, but must not error
|
||||
}
|
||||
|
||||
@test "logs: --help shows usage" {
|
||||
run "${SCRIPT}" logs --help
|
||||
[ "${status}" -eq 0 ]
|
||||
[[ "${output}" == *"logs"* ]]
|
||||
}
|
||||
|
||||
@test "logs: exits with code 2 when device not connected" {
|
||||
DEVICE_SERIAL="INVALID_SERIAL_000" run "${SCRIPT}" logs --lines 1
|
||||
[ "${status}" -eq 2 ]
|
||||
}
|
||||
Reference in New Issue
Block a user