diff options
| author | Li Jin <dragon-fly@qq.com> | 2026-02-20 13:22:58 +0000 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2026-02-20 13:22:58 +0000 |
| commit | 28253ef50ffa976ed70e6635e4d0ccf7f1842fcd (patch) | |
| tree | e653776d8560e30b7885b9113defe7c073db5278 /spec/cli/cli_test_helper.sh | |
| parent | 635ce55c778eb0ccf0cb0f5d495402dbbb42deb1 (diff) | |
| parent | 1c93c88a3f79cfce68ee6d8c4cd85156aaad1101 (diff) | |
| download | yuescript-28253ef50ffa976ed70e6635e4d0ccf7f1842fcd.tar.gz yuescript-28253ef50ffa976ed70e6635e4d0ccf7f1842fcd.tar.bz2 yuescript-28253ef50ffa976ed70e6635e4d0ccf7f1842fcd.zip | |
Merge branch 'feature/reserve-comments-tests' into codex/remove-line-number-comments-from-empty-linesHEADmain
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" |
