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/test_basic_options.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 spec/cli/test_basic_options.sh (limited to 'spec/cli/test_basic_options.sh') diff --git a/spec/cli/test_basic_options.sh b/spec/cli/test_basic_options.sh new file mode 100755 index 0000000..81cfaf7 --- /dev/null +++ b/spec/cli/test_basic_options.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Test Basic Options for YueScript CLI +# Tests: -h, --help, -v, --version + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/cli_test_helper.sh" + +# Check binary +check_yue_binary + +echo "========================================" +echo "Testing Basic Options" +echo "========================================" +echo "" + +# Test 1: Help flag -h +echo "Testing -h flag..." +assert_output_contains "Help flag -h should show usage" "Usage: yue" $YUE_BIN -h + +# Test 2: Help flag --help +assert_output_contains "Help flag --help should show usage" "Usage: yue" $YUE_BIN --help + +# Test 3: Version flag -v +assert_output_contains "Version flag -v should show version" "Yuescript version:" $YUE_BIN -v + +# Test 4: Version flag --version +assert_output_contains "Version flag --version should show version" "Yuescript version:" $YUE_BIN --version + +# Test 5: Verify help contains expected sections +echo "" +echo "Testing help content..." +# Use grep -F to search for fixed strings without interpreting special characters +assert_output_contains "Help should show compile options" "output-to" $YUE_BIN --help +assert_output_contains "Help should show minify option" "minify" $YUE_BIN --help +assert_output_contains "Help should show execute option" "execute" $YUE_BIN --help + +echo "" +print_summary -- cgit v1.2.3-55-g6feb