From aacf6dd9ebdb4d55b432ea1d4213093fe35e0ad1 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 6 Feb 2026 06:18:58 +0000 Subject: test: add comprehensive CLI test suite Add 56 test cases across 4 test suites to verify the yue command line tool functionality: - Basic options test: -h, --help, -v, --version flags - Compilation test: file/directory compilation with various options - Error handling test: syntax errors, file not found, edge cases - Execution test: -e option, script arguments, macros The test framework includes helper functions for assertions and test environment setup. All tests can be run via `bash spec/cli/run_all_tests.sh`. Co-Authored-By: Claude Sonnet 4.5 --- spec/cli/run_all_tests.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 spec/cli/run_all_tests.sh (limited to 'spec/cli/run_all_tests.sh') diff --git a/spec/cli/run_all_tests.sh b/spec/cli/run_all_tests.sh new file mode 100755 index 0000000..0067bba --- /dev/null +++ b/spec/cli/run_all_tests.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# Main test runner for YueScript CLI +# Runs all CLI test suites + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo -e "${BLUE}======================================" +echo "YueScript CLI Test Suite" +echo "======================================${NC}" +echo "" + +# Check if yue binary exists +YUE_BIN="${YUE_BIN:-./bin/debug/yue}" +if [ ! -f "$YUE_BIN" ]; then + echo -e "${RED}Error: yue binary not found at $YUE_BIN${NC}" + echo "Please build the project first:" + echo " make debug" + echo "Or set YUE_BIN environment variable" + exit 1 +fi + +# Track overall results +TOTAL_SUITES=0 +PASSED_SUITES=0 +FAILED_SUITES=0 + +# Function to run a test suite +run_test_suite() { + local suite_name="$1" + local suite_file="$2" + + TOTAL_SUITES=$((TOTAL_SUITES + 1)) + echo "" + echo -e "${BLUE}Running: $suite_name${NC}" + echo "======================================" + + if bash "$suite_file"; then + echo -e "${GREEN}✓ $suite_name PASSED${NC}" + PASSED_SUITES=$((PASSED_SUITES + 1)) + return 0 + else + echo -e "${RED}✗ $suite_name FAILED${NC}" + FAILED_SUITES=$((FAILED_SUITES + 1)) + return 1 + fi +} + +# Run all test suites +run_test_suite "Basic Options Test" "$SCRIPT_DIR/test_basic_options.sh" +run_test_suite "Compilation Test" "$SCRIPT_DIR/test_compilation.sh" +run_test_suite "Error Handling Test" "$SCRIPT_DIR/test_error_handling.sh" +run_test_suite "Execution Test" "$SCRIPT_DIR/test_execution.sh" + +# Print final summary +echo "" +echo -e "${BLUE}======================================" +echo "Final Test Suite Summary" +echo "======================================${NC}" +echo "Total test suites: $TOTAL_SUITES" +echo -e "Passed: ${GREEN}$PASSED_SUITES${NC}" +echo -e "Failed: ${RED}$FAILED_SUITES${NC}" +echo "======================================" + +if [ $FAILED_SUITES -eq 0 ]; then + echo -e "${GREEN}All test suites passed!${NC}" + exit 0 +else + echo -e "${RED}Some test suites failed!${NC}" + exit 1 +fi -- cgit v1.2.3-55-g6feb