Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cli/bash/commands/basectl/subcommands/setup_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2069,15 +2069,19 @@ setup_run_check_json() {

if setup_profiles_enabled; then
if ! profile_json="$(setup_run_base_dev_layer check --format json)"; then
[[ -n "$profile_json" ]] || profile_json='{"schema_version":1,"status":"error","profiles":[],"checks":[]}'
if [[ -z "$profile_json" ]]; then
return 1
fi
fi
profile_status="$(setup_json_payload_status "$profile_json")"
status="$(setup_merge_diagnostic_status "$status" "$profile_status")"
fi

if [[ -n "$project" ]]; then
if ! project_json="$(setup_run_project_artifact_check_json "$remote_network")"; then
[[ -n "$project_json" ]] || project_json='{"schema_version":1,"status":"error","checks":[]}'
if [[ -z "$project_json" ]]; then
return 1
fi
fi
project_status="$(setup_json_payload_status "$project_json")"
status="$(setup_merge_diagnostic_status "$status" "$project_status")"
Expand Down
27 changes: 27 additions & 0 deletions cli/bash/commands/basectl/tests/check.bats
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,33 @@ load ./setup_helpers.bash
[ "${stderr:-}" = "" ]
}

@test "basectl check project --format json fails fast on runtime directory errors" {
local venv_dir="$TEST_HOME/.base.d/base/.venv"
local workspace="$TEST_TMPDIR/workspace"

create_brew_stub
create_xcode_stubs
touch "$TEST_STATE_DIR/xcode-installed"
mkdir -p "$TEST_TMPDIR/CommandLineTools" "$workspace/demo"
touch "$TEST_STATE_DIR/python-installed"
touch "$TEST_STATE_DIR/bats-installed"
touch "$TEST_STATE_DIR/pyyaml-installed"
touch "$TEST_STATE_DIR/click-installed"
printf 'project:\n name: demo\nartifacts: []\n' > "$workspace/demo/base_manifest.yaml"
BASE_SETUP_TEST_WORKSPACE="$workspace" create_project_setup_venv_stub "$venv_dir"
BASE_SETUP_TEST_WORKSPACE="$workspace" create_project_setup_venv_stub "$TEST_HOME/.base.d/demo/.venv" 1
touch "$TEST_STATE_DIR/project-setup-fail-before-output"
printf "Error: Unable to create Base runtime directory '%s'.\n" "$TEST_TMPDIR/unwritable-cache/cli/base_setup/logs" > "$TEST_STATE_DIR/project-setup-stderr"

run_base_command_separate_stderr BASE_SETUP_TEST_WORKSPACE="$workspace" check demo --format json

[ "$status" -eq 1 ]
[ "$output" = "" ]
[[ "$stderr" == *"Error: Unable to create Base runtime directory"* ]]
[[ "$stderr" != *'"project_checks"'* ]]
[[ "$stderr" != *"Project artifact check passed."* ]]
}

@test "basectl check project --format json reports broken project virtualenv integrity" {
local missing_home="$TEST_TMPDIR/missing-project-python-home"
local venv_dir="$TEST_HOME/.base.d/base/.venv"
Expand Down
6 changes: 6 additions & 0 deletions cli/bash/commands/basectl/tests/setup_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ if [[ "${1:-}" == "-m" && "${2:-}" == "base_setup" ]]; then
if [[ "$action" == "bootstrap" ]]; then
printf '%s\n' "${BASE_SETUP_RECREATE_PROJECT_VENV:-}" > "$BASE_SETUP_TEST_STATE_DIR/project-bootstrap-recreate-venv"
fi
if [[ -f "$BASE_SETUP_TEST_STATE_DIR/project-setup-fail-before-output" ]]; then
if [[ -f "$BASE_SETUP_TEST_STATE_DIR/project-setup-stderr" ]]; then
cat "$BASE_SETUP_TEST_STATE_DIR/project-setup-stderr" >&2
fi
exit "$(cat "$BASE_SETUP_TEST_STATE_DIR/project-setup-exit-code")"
fi
if [[ "$action" == "precheck" && "$output_format" == "json" ]]; then
if [[ "$remote_network" == true ]]; then
printf '[{"id":"BASE-P080","status":"ok","name":"git_repository","message":"Project is inside a Git repository.","fix":""},{"id":"BASE-P083","status":"ok","name":"git_origin_reachability","message":"Project Git origin remote is reachable.","fix":""}]\n'
Expand Down
Loading