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
13 changes: 10 additions & 3 deletions llvmup
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ log_error() {
}

usage() {
local previous_exit=$?
local exit_code="${1:-$previous_exit}"

if [ $# -eq 0 ] && [ "$exit_code" -eq 0 ]; then
exit_code=1
fi

cat <<EOF
Usage: llvmup [install] [OPTIONS] [VERSION]

Expand Down Expand Up @@ -262,7 +269,7 @@ Examples:
llvmup config init # Initialize project config
llvmup config activate # Activate from config
EOF
exit 1
exit "$exit_code"
}

# Parse command line arguments
Expand All @@ -288,7 +295,7 @@ fi
# Handle non-install commands early
case "$COMMAND" in
help)
usage
usage 0
;;
default)
if [ $# -eq 0 ]; then
Expand Down Expand Up @@ -373,7 +380,7 @@ while [[ $# -gt 0 ]]; do
shift
;;
-h|--help)
usage
usage 0
;;
--)
shift
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_enhanced_workflow.bats
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ EOF

@test "Help system shows all new options" {
run bash "$ORIGINAL_DIR/llvmup" --help
# Help exits with code 1, but shows the help correctly
[ "$status" -eq 1 ]
# Help exits successfully and shows the help correctly
assert_success

# Check for all new options
assert_output --partial "--cmake-flags"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_llvmup_config_activate.bats
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ EOF
@test "llvmup help - shows config command in usage" {
run "$LLVMUP_SCRIPT" help

[ "$status" -eq 1 ]
[ "$status" -eq 0 ]
[[ "$output" == *"config Manage project configuration"* ]]
[[ "$output" == *"llvmup config init"* ]]
[[ "$output" == *"llvmup config activate"* ]]
Expand Down
32 changes: 16 additions & 16 deletions tests/unit/test_llvmup_enhanced.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ teardown() {

@test "llvmup shows enhanced help with new options" {
run bash "$ORIGINAL_DIR/llvmup" --help
# The help command returns 1 (exit after showing help), but shows the help correctly
[ "$status" -eq 1 ]
# Help exits successfully and shows the enhanced options
assert_success
assert_output --partial "--cmake-flags"
assert_output --partial "--name"
assert_output --partial "--default"
Expand Down Expand Up @@ -82,32 +82,32 @@ teardown() {
@test "llvmup install accepts cmake-flags option" {
# Test that llvmup accepts the cmake-flags option (parsing test)
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--cmake-flags"
}

@test "llvmup install accepts name option" {
# Test that llvmup accepts the name option (parsing test)
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--name"
}

@test "llvmup install accepts default option" {
# Test that llvmup accepts the default option (parsing test)
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--default"
}

@test "llvmup install accepts profile option" {
# Test that llvmup accepts the profile option (parsing test)
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--profile"
}

Expand All @@ -120,25 +120,25 @@ teardown() {
@test "llvmup install accepts component option" {
# Test that llvmup accepts the component option (parsing test)
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--component"
}

@test "llvmup install passes multiple cmake-flags correctly" {
# Test that llvmup accepts multiple cmake-flags (parsing test)
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--cmake-flags"
assert_output --partial "can be repeated"
}

@test "llvmup install combines all options correctly" {
# Test that llvmup help shows all the new options
run bash "$ORIGINAL_DIR/llvmup" install --help
# Help exits with code 1, but shows the help
[ "$status" -eq 1 ]
# Help exits successfully but still shows the usage text
assert_success
assert_output --partial "--name"
assert_output --partial "--default"
assert_output --partial "--profile"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_llvmup_libc_wno_error.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ load "../fixtures/test_helpers.bash"
@test "llvmup help includes --disable-libc-wno-error option" {
run ./llvmup --help

# Help exits with code 1, but that's expected behavior
[ "$status" -eq 1 ]
# Help exits successfully when requested explicitly
assert_success
assert_output --partial "--disable-libc-wno-error"
assert_output --partial "Disable LIBC_WNO_ERROR=ON flag"
}
Expand Down
Loading