Refine tests, CLI
This commit is contained in:
@@ -14,6 +14,7 @@ ALIAS_BLOCK_END="# <<< ffx alias <<<"
|
||||
ALIAS_LINE="alias ffx=\"${VENV_FFX}\""
|
||||
|
||||
CHECK_ONLY=0
|
||||
WITH_TESTS=0
|
||||
READINESS_FAILURES=0
|
||||
INSTALL_FAILURES=0
|
||||
|
||||
@@ -31,19 +32,25 @@ fi
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $(basename "$0") [--check] [--help]
|
||||
Usage: $(basename "$0") [--check] [--with-tests] [--help]
|
||||
|
||||
Prepare the persistent FFX bundle virtualenv at:
|
||||
Prepare the persistent FFX bundle installation at:
|
||||
${VENV_DIR}
|
||||
|
||||
Actions:
|
||||
- create or reuse ${VENV_DIR}
|
||||
- install this repository into the venv with pip --editable
|
||||
- ensure ${BASHRC_FILE} exposes alias ffx -> ${VENV_FFX}
|
||||
- optionally install Python packages required for modern tests
|
||||
|
||||
Options:
|
||||
--check Report readiness only. Do not create or modify anything.
|
||||
--help Show this help text.
|
||||
--check Report readiness only. Do not create or modify anything.
|
||||
--with-tests Also install and verify Python packages required for modern tests.
|
||||
--help Show this help text.
|
||||
|
||||
Notes:
|
||||
- This is the first installation step.
|
||||
- tools/configure_workstation.sh is the second step and configures system dependencies plus local user files.
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -100,6 +107,10 @@ check_venv_ffx() {
|
||||
[ -x "${VENV_FFX}" ]
|
||||
}
|
||||
|
||||
check_venv_pytest() {
|
||||
check_venv_dir && "${VENV_PYTHON}" -m pytest --version >/dev/null 2>&1
|
||||
}
|
||||
|
||||
check_bashrc_file() {
|
||||
[ -f "${BASHRC_FILE}" ]
|
||||
}
|
||||
@@ -136,6 +147,14 @@ detail_venv_ffx() {
|
||||
fi
|
||||
}
|
||||
|
||||
detail_venv_pytest() {
|
||||
if check_venv_pytest; then
|
||||
"${VENV_PYTHON}" -m pytest --version 2>/dev/null | head -n 1
|
||||
else
|
||||
printf 'missing pytest in %s' "${VENV_DIR}"
|
||||
fi
|
||||
}
|
||||
|
||||
detail_bashrc_file() {
|
||||
if check_bashrc_file; then
|
||||
printf '%s' "${BASHRC_FILE}"
|
||||
@@ -186,6 +205,17 @@ print_status_report() {
|
||||
READINESS_FAILURES=$((READINESS_FAILURES + 1))
|
||||
fi
|
||||
|
||||
if [ "${WITH_TESTS}" -eq 1 ]; then
|
||||
echo
|
||||
echo "Bundle test package status:"
|
||||
if check_venv_pytest; then
|
||||
report_component ok "bundle pytest" "$(detail_venv_pytest)"
|
||||
else
|
||||
report_component failed "bundle pytest" "$(detail_venv_pytest)"
|
||||
READINESS_FAILURES=$((READINESS_FAILURES + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Shell exposure status:"
|
||||
if check_bashrc_file; then
|
||||
@@ -220,11 +250,23 @@ ensure_bundle_venv() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf 'Installing FFX package into %s...\n' "${VENV_DIR}"
|
||||
if ! "${VENV_PIP}" install --editable "${ROOT_DIR}"; then
|
||||
printf 'Failed to install FFX package into %s.\n' "${VENV_DIR}" >&2
|
||||
INSTALL_FAILURES=$((INSTALL_FAILURES + 1))
|
||||
return 1
|
||||
if [ "${WITH_TESTS}" -eq 1 ]; then
|
||||
printf 'Installing FFX package and test extras into %s...\n' "${VENV_DIR}"
|
||||
if ! (
|
||||
cd "${ROOT_DIR}" &&
|
||||
"${VENV_PIP}" install --editable '.[test]'
|
||||
); then
|
||||
printf 'Failed to install FFX package and test extras into %s.\n' "${VENV_DIR}" >&2
|
||||
INSTALL_FAILURES=$((INSTALL_FAILURES + 1))
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
printf 'Installing FFX package into %s...\n' "${VENV_DIR}"
|
||||
if ! "${VENV_PIP}" install --editable "${ROOT_DIR}"; then
|
||||
printf 'Failed to install FFX package into %s.\n' "${VENV_DIR}" >&2
|
||||
INSTALL_FAILURES=$((INSTALL_FAILURES + 1))
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
@@ -300,6 +342,9 @@ parse_args() {
|
||||
--check)
|
||||
CHECK_ONLY=1
|
||||
;;
|
||||
--with-tests)
|
||||
WITH_TESTS=1
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user