mirror of
https://github.com/baketnk/frame-yap.git
synced 2026-10-06 04:04:07 +02:00
Initialize standalone Frame Dictation scaffold and install preflight
This commit is contained in:
commit
f79db54ca9
12 files changed
+758
No files matched your search
@@ -0,0 +1,35 @@
|
||||
if(NOT DEFINED APP OR NOT DEFINED EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "APP and EXPECTED_VERSION are required")
|
||||
endif()
|
||||
|
||||
foreach(mode IN ITEMS default help version invalid extra)
|
||||
set(args)
|
||||
set(expected_exit 0)
|
||||
if(mode STREQUAL "help")
|
||||
set(args --help)
|
||||
elseif(mode STREQUAL "version")
|
||||
set(args --version)
|
||||
elseif(mode STREQUAL "invalid")
|
||||
set(args --record)
|
||||
set(expected_exit 2)
|
||||
elseif(mode STREQUAL "extra")
|
||||
set(args --help --record)
|
||||
set(expected_exit 2)
|
||||
endif()
|
||||
execute_process(COMMAND "${APP}" ${args}
|
||||
RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error TIMEOUT 5)
|
||||
if(NOT "${result}" STREQUAL "${expected_exit}")
|
||||
message(FATAL_ERROR "${mode}: exit ${result}, expected ${expected_exit}: ${error}")
|
||||
endif()
|
||||
if(mode STREQUAL "version")
|
||||
if(NOT output STREQUAL "frame-dictation ${EXPECTED_VERSION} (scaffold)\n")
|
||||
message(FATAL_ERROR "Unexpected version: ${output}")
|
||||
endif()
|
||||
elseif(expected_exit EQUAL 2)
|
||||
if(NOT error MATCHES "Unsupported arguments")
|
||||
message(FATAL_ERROR "Missing rejection diagnostic")
|
||||
endif()
|
||||
elseif(NOT output MATCHES "Scaffold only")
|
||||
message(FATAL_ERROR "Missing scaffold status")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Offline, hardware-free contract test using a restricted PATH of fake host tools.
|
||||
set -eu
|
||||
script=$1
|
||||
tmp=$(/bin/mktemp -d)
|
||||
trap '/bin/rm -rf "$tmp"' EXIT HUP INT TERM
|
||||
/bin/mkdir "$tmp/bin"
|
||||
for dep in curl tar sha256sum mktemp mkdir mv; do
|
||||
printf '#!/bin/sh\nexit 0\n' > "$tmp/bin/$dep"
|
||||
/bin/chmod +x "$tmp/bin/$dep"
|
||||
done
|
||||
printf '#!/bin/sh\ncase "$1" in -s) printf "%%s\\n" "${MOCK_OS:-Linux}" ;; -m) printf "%%s\\n" "${MOCK_ARCH:-aarch64}" ;; esac\n' > "$tmp/bin/uname"
|
||||
printf '#!/bin/sh\nprintf "%%s\\n" "${MOCK_LIBC:-glibc 2.39}"\n' > "$tmp/bin/getconf"
|
||||
printf '#!/bin/sh\nprintf "%%s\\n" "${MOCK_PYTHON:-Python 3.12.3}"\n' > "$tmp/bin/python3"
|
||||
/bin/chmod +x "$tmp/bin/uname" "$tmp/bin/getconf" "$tmp/bin/python3"
|
||||
|
||||
check() {
|
||||
expected=$1
|
||||
needle=$2
|
||||
shift 2
|
||||
status=0
|
||||
output=$(PATH="$tmp/bin" "$@" /bin/sh "$script" 2>&1) || status=$?
|
||||
if [ "$status" -ne "$expected" ]; then
|
||||
printf 'Expected exit %s, got %s: %s\n' "$expected" "$status" "$output" >&2
|
||||
exit 1
|
||||
fi
|
||||
case "$output" in
|
||||
*"$needle"*) ;;
|
||||
*) printf 'Missing expected text %s: %s\n' "$needle" "$output" >&2; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check 0 'Git: missing (not required' /usr/bin/env
|
||||
check 0 'uv: missing (not required' /usr/bin/env
|
||||
check 0 'Preflight passed' /usr/bin/env
|
||||
check 0 'older than 3.12' /usr/bin/env MOCK_PYTHON='Python 3.11.9'
|
||||
check 1 'Linux AArch64 only' /usr/bin/env MOCK_ARCH=x86_64
|
||||
check 1 'require glibc' /usr/bin/env MOCK_LIBC=musl
|
||||
/bin/rm "$tmp/bin/curl"
|
||||
check 1 'curl MISSING' /usr/bin/env
|
||||
Reference in new issue
Block a user