diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-06 06:18:58 +0000 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-06 06:18:58 +0000 |
| commit | aacf6dd9ebdb4d55b432ea1d4213093fe35e0ad1 (patch) | |
| tree | 25926b10c10bc36133cfd1a337190dd003088e2e /spec/cli/run_all_tests.sh | |
| parent | 1f83d504bc344ffd3c8b4120b3865fd6c11a9e2d (diff) | |
| download | yuescript-aacf6dd9ebdb4d55b432ea1d4213093fe35e0ad1.tar.gz yuescript-aacf6dd9ebdb4d55b432ea1d4213093fe35e0ad1.tar.bz2 yuescript-aacf6dd9ebdb4d55b432ea1d4213093fe35e0ad1.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'spec/cli/run_all_tests.sh')
| -rwxr-xr-x | spec/cli/run_all_tests.sh | 77 |
1 files changed, 77 insertions, 0 deletions
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 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # Main test runner for YueScript CLI | ||
| 3 | # Runs all CLI test suites | ||
| 4 | |||
| 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| 6 | |||
| 7 | # Colors | ||
| 8 | RED='\033[0;31m' | ||
| 9 | GREEN='\033[0;32m' | ||
| 10 | YELLOW='\033[1;33m' | ||
| 11 | BLUE='\033[0;34m' | ||
| 12 | NC='\033[0m' # No Color | ||
| 13 | |||
| 14 | echo -e "${BLUE}======================================" | ||
| 15 | echo "YueScript CLI Test Suite" | ||
| 16 | echo "======================================${NC}" | ||
| 17 | echo "" | ||
| 18 | |||
| 19 | # Check if yue binary exists | ||
| 20 | YUE_BIN="${YUE_BIN:-./bin/debug/yue}" | ||
| 21 | if [ ! -f "$YUE_BIN" ]; then | ||
| 22 | echo -e "${RED}Error: yue binary not found at $YUE_BIN${NC}" | ||
| 23 | echo "Please build the project first:" | ||
| 24 | echo " make debug" | ||
| 25 | echo "Or set YUE_BIN environment variable" | ||
| 26 | exit 1 | ||
| 27 | fi | ||
| 28 | |||
| 29 | # Track overall results | ||
| 30 | TOTAL_SUITES=0 | ||
| 31 | PASSED_SUITES=0 | ||
| 32 | FAILED_SUITES=0 | ||
| 33 | |||
| 34 | # Function to run a test suite | ||
| 35 | run_test_suite() { | ||
| 36 | local suite_name="$1" | ||
| 37 | local suite_file="$2" | ||
| 38 | |||
| 39 | TOTAL_SUITES=$((TOTAL_SUITES + 1)) | ||
| 40 | echo "" | ||
| 41 | echo -e "${BLUE}Running: $suite_name${NC}" | ||
| 42 | echo "======================================" | ||
| 43 | |||
| 44 | if bash "$suite_file"; then | ||
| 45 | echo -e "${GREEN}✓ $suite_name PASSED${NC}" | ||
| 46 | PASSED_SUITES=$((PASSED_SUITES + 1)) | ||
| 47 | return 0 | ||
| 48 | else | ||
| 49 | echo -e "${RED}✗ $suite_name FAILED${NC}" | ||
| 50 | FAILED_SUITES=$((FAILED_SUITES + 1)) | ||
| 51 | return 1 | ||
| 52 | fi | ||
| 53 | } | ||
| 54 | |||
| 55 | # Run all test suites | ||
| 56 | run_test_suite "Basic Options Test" "$SCRIPT_DIR/test_basic_options.sh" | ||
| 57 | run_test_suite "Compilation Test" "$SCRIPT_DIR/test_compilation.sh" | ||
| 58 | run_test_suite "Error Handling Test" "$SCRIPT_DIR/test_error_handling.sh" | ||
| 59 | run_test_suite "Execution Test" "$SCRIPT_DIR/test_execution.sh" | ||
| 60 | |||
| 61 | # Print final summary | ||
| 62 | echo "" | ||
| 63 | echo -e "${BLUE}======================================" | ||
| 64 | echo "Final Test Suite Summary" | ||
| 65 | echo "======================================${NC}" | ||
| 66 | echo "Total test suites: $TOTAL_SUITES" | ||
| 67 | echo -e "Passed: ${GREEN}$PASSED_SUITES${NC}" | ||
| 68 | echo -e "Failed: ${RED}$FAILED_SUITES${NC}" | ||
| 69 | echo "======================================" | ||
| 70 | |||
| 71 | if [ $FAILED_SUITES -eq 0 ]; then | ||
| 72 | echo -e "${GREEN}All test suites passed!${NC}" | ||
| 73 | exit 0 | ||
| 74 | else | ||
| 75 | echo -e "${RED}Some test suites failed!${NC}" | ||
| 76 | exit 1 | ||
| 77 | fi | ||
