diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-20 13:02:09 +0000 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-20 13:02:09 +0000 |
| commit | 1c93c88a3f79cfce68ee6d8c4cd85156aaad1101 (patch) | |
| tree | b42fdba0e6719168388e01a34d5d3c18db7c7446 /spec/cli/cli_test_helper.sh | |
| parent | abe6859edcc85c2b2da1d6c5bdae9ac5ee2e94c5 (diff) | |
| download | yuescript-1c93c88a3f79cfce68ee6d8c4cd85156aaad1101.tar.gz yuescript-1c93c88a3f79cfce68ee6d8c4cd85156aaad1101.tar.bz2 yuescript-1c93c88a3f79cfce68ee6d8c4cd85156aaad1101.zip | |
Add test suite for reserve comments feature
- Add assert_output_not_contains helper function for negative assertions
- Add reserve_comments_spec test with Yue and Lua files
- Integrate new test suite into run_all_tests.sh
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'spec/cli/cli_test_helper.sh')
| -rwxr-xr-x | spec/cli/cli_test_helper.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/cli/cli_test_helper.sh b/spec/cli/cli_test_helper.sh index ade1546..0f46969 100755 --- a/spec/cli/cli_test_helper.sh +++ b/spec/cli/cli_test_helper.sh | |||
| @@ -123,6 +123,33 @@ assert_output_equals() { | |||
| 123 | fi | 123 | fi |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | # Assert that output does NOT contain expected string | ||
| 127 | assert_output_not_contains() { | ||
| 128 | local description="$1" | ||
| 129 | local unexpected="$2" | ||
| 130 | shift 2 | ||
| 131 | TESTS_RUN=$((TESTS_RUN + 1)) | ||
| 132 | |||
| 133 | if "$@" > /tmp/test_stdout.txt 2> /tmp/test_stderr.txt; then | ||
| 134 | if grep -qF -- "$unexpected" /tmp/test_stdout.txt || grep -qF -- "$unexpected" /tmp/test_stderr.txt; then | ||
| 135 | echo -e "${RED}✗${NC} $description (output contains '$unexpected')" | ||
| 136 | echo -e " ${YELLOW}STDOUT:$(cat /tmp/test_stdout.txt)${NC}" | ||
| 137 | echo -e " ${YELLOW}STDERR:$(cat /tmp/test_stderr.txt)${NC}" | ||
| 138 | TESTS_FAILED=$((TESTS_FAILED + 1)) | ||
| 139 | return 1 | ||
| 140 | else | ||
| 141 | echo -e "${GREEN}✓${NC} $description" | ||
| 142 | TESTS_PASSED=$((TESTS_PASSED + 1)) | ||
| 143 | return 0 | ||
| 144 | fi | ||
| 145 | else | ||
| 146 | echo -e "${RED}✗${NC} $description (command failed)" | ||
| 147 | echo -e " ${YELLOW}Exit code: $?${NC}" | ||
| 148 | TESTS_FAILED=$((TESTS_FAILED + 1)) | ||
| 149 | return 1 | ||
| 150 | fi | ||
| 151 | } | ||
| 152 | |||
| 126 | # Assert file exists | 153 | # Assert file exists |
| 127 | assert_file_exists() { | 154 | assert_file_exists() { |
| 128 | local description="$1" | 155 | local description="$1" |
