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
50 changes: 43 additions & 7 deletions demo/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ demo_project_root() {

BASE_DEMO_ROOT="$(demo_project_root)"

demo_workspace_root() {
cd -- "$BASE_DEMO_ROOT/.." && pwd -P
}

BASE_DEMO_WORKSPACE="$(demo_workspace_root)"

usage() {
cat <<'EOF'
Usage:
Expand Down Expand Up @@ -129,19 +135,46 @@ manifest_step() {
}

activation_step() {
step 3 "Project Activation Source"
step 5 "Project Activation Source"
# shellcheck source=/dev/null
source "$BASE_DEMO_ROOT/.base/activate.sh"
printf 'BASE_DEMO_ENV=%s\n' "${BASE_DEMO_ENV:-unset}"
require_contains "activation" "${BASE_DEMO_ENV:-}" "baseline"
pause
}

discovery_step() {
local output

step 3 "Workspace Discovery"
output="$(capture_command "$BASE_DEMO_BASECTL" projects list --workspace "$BASE_DEMO_WORKSPACE")"
printf '%s\n' "$output"
require_contains "projects list" "$output" "$BASE_DEMO_PROJECT"
pause
}

diagnostics_step() {
step 4 "Project Diagnostics"
run_command "$BASE_DEMO_BASECTL" check "$BASE_DEMO_PROJECT"
run_command "$BASE_DEMO_BASECTL" doctor "$BASE_DEMO_PROJECT"
pause
}

command_discovery_step() {
local output

step 6 "Declared Commands"
output="$(capture_command "$BASE_DEMO_BASECTL" run "$BASE_DEMO_PROJECT" --workspace "$BASE_DEMO_WORKSPACE" --list)"
printf '%s\n' "$output"
require_contains "run command list" "$output" "hello"
pause
}

run_step() {
local output

step 4 "Declared Command"
output="$(capture_command "$BASE_DEMO_BASECTL" run "$BASE_DEMO_PROJECT" hello)"
step 7 "Declared Command Execution"
output="$(capture_command "$BASE_DEMO_BASECTL" run "$BASE_DEMO_PROJECT" --workspace "$BASE_DEMO_WORKSPACE" hello)"
printf '%s\n' "$output"
require_contains "run command" "$output" "hello from base-demo"
pause
Expand All @@ -150,8 +183,8 @@ run_step() {
test_step() {
local output

step 5 "Test Contract"
output="$(capture_command "$BASE_DEMO_BASECTL" test "$BASE_DEMO_PROJECT")"
step 8 "Test Contract"
output="$(capture_command "$BASE_DEMO_BASECTL" test "$BASE_DEMO_PROJECT" --workspace "$BASE_DEMO_WORKSPACE")"
printf '%s\n' "$output"
require_contains "test command" "$output" "Repository baseline is present."
pause
Expand All @@ -160,8 +193,8 @@ test_step() {
demo_step() {
local output

step 6 "Demo Contract"
output="$(capture_command "$BASE_DEMO_BASECTL" demo "$BASE_DEMO_PROJECT" --dry-run -- --non-interactive)"
step 9 "Demo Contract"
output="$(capture_command "$BASE_DEMO_BASECTL" demo "$BASE_DEMO_PROJECT" --workspace "$BASE_DEMO_WORKSPACE" --dry-run -- --non-interactive)"
printf '%s\n' "$output"
require_contains "demo command" "$output" "Would run demo"
pause
Expand All @@ -178,7 +211,10 @@ main() {
intro
project_shape_step
manifest_step
discovery_step
diagnostics_step
activation_step
command_discovery_step
run_step
test_step
demo_step
Expand Down
33 changes: 27 additions & 6 deletions tests/demo_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,29 @@ teardown() {
#!/usr/bin/env bash
printf 'basectl %s\n' "$*" >> "${BASE_DEMO_TEST_STATE:?}"
case "$*" in
run\ base-demo\ hello)
projects\ list\ --workspace\ *)
printf 'PROJECT PATH\n'
printf 'base-demo %s\n' "${BASE_PROJECT_ROOT:?}"
;;
check\ base-demo)
printf 'Base CLI environment check passed.\n'
;;
doctor\ base-demo)
printf 'Base doctor\n'
printf 'ok project base-demo is healthy.\n'
;;
run\ base-demo\ --workspace\ *\ --list)
printf 'hello ./src/hello.sh\n'
;;
run\ base-demo\ --workspace\ *\ hello)
printf 'hello from base-demo\n'
printf 'BASE_PROJECT=base-demo\n'
printf 'BASE_DEMO_ENV=%s\n' "${BASE_DEMO_ENV:-unset}"
;;
test\ base-demo)
test\ base-demo\ --workspace\ *)
printf 'Repository baseline is present.\n'
;;
demo\ base-demo\ --dry-run\ --\ --non-interactive)
demo\ base-demo\ --workspace\ *\ --dry-run\ --\ --non-interactive)
printf '[DRY-RUN] Would run demo for project base-demo.\n'
;;
*)
Expand All @@ -58,11 +72,18 @@ EOF

[ "$status" -eq 0 ]
[[ "$output" == *"base-demo Walkthrough"* ]]
[[ "$output" == *"Workspace Discovery"* ]]
[[ "$output" == *"Project Diagnostics"* ]]
[[ "$output" == *"Declared Commands"* ]]
[[ "$output" == *"BASE_DEMO_ENV=baseline"* ]]
[[ "$output" == *"hello from base-demo"* ]]
[[ "$output" == *"Repository baseline is present."* ]]
[[ "$output" == *"base-demo walkthrough complete."* ]]
grep -Fqx "basectl run base-demo hello" "$state_file"
grep -Fqx "basectl test base-demo" "$state_file"
grep -Fqx "basectl demo base-demo --dry-run -- --non-interactive" "$state_file"
grep -Fq "basectl projects list --workspace " "$state_file"
grep -Fqx "basectl check base-demo" "$state_file"
grep -Fqx "basectl doctor base-demo" "$state_file"
grep -Eq "^basectl run base-demo --workspace .+ --list$" "$state_file"
grep -Eq "^basectl run base-demo --workspace .+ hello$" "$state_file"
grep -Eq "^basectl test base-demo --workspace .+$" "$state_file"
grep -Eq "^basectl demo base-demo --workspace .+ --dry-run -- --non-interactive$" "$state_file"
}
Loading