Skip to content

Commit 7b3cb43

Browse files
committed
tests: update tests
1 parent 1807c0e commit 7b3cb43

14 files changed

+2638
-308
lines changed

Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ DIST_SUBDIRS = include src converters assessment tools python ruby wic \
1818
EXTRA_DIST = LICENSE depcomp
1919

2020
EXTRA_DIST += converters/t/common.t \
21-
converters/t/test_0001_invalid_option.t \
21+
converters/t/test_0001_01_invalid_positional.t \
22+
converters/t/test_0001_02_invalid_option_arguments.t \
23+
converters/t/test_0001_03_invalid_option_combinations.t \
2224
converters/t/test_0002_stdin.t \
2325
converters/t/test_0003_information.t \
2426
converters/t/test_0004_conversion_options.t \

converters/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ CONVERTER_TEST_LIST =
2424
if WANT_IMG2SIXEL
2525
if HAVE_BASH
2626
CONVERTER_TEST_LIST += \
27-
$(top_srcdir)/converters/t/test_0001_invalid_option.t \
27+
$(top_srcdir)/converters/t/test_0001_01_invalid_positional.t \
28+
$(top_srcdir)/converters/t/test_0001_02_invalid_option_arguments.t \
29+
$(top_srcdir)/converters/t/test_0001_03_invalid_option_combinations.t \
2830
$(top_srcdir)/converters/t/test_0002_stdin.t \
2931
$(top_srcdir)/converters/t/test_0003_information.t \
3032
$(top_srcdir)/converters/t/test_0004_conversion_options.t \

converters/Makefile.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ build_triplet = @build@
9292
host_triplet = @host@
9393
bin_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
9494
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@am__append_1 = \
95-
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0001_invalid_option.t \
95+
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0001_01_invalid_positional.t \
96+
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0001_02_invalid_option_arguments.t \
97+
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0001_03_invalid_option_combinations.t \
9698
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0002_stdin.t \
9799
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0003_information.t \
98100
@HAVE_BASH_TRUE@@WANT_IMG2SIXEL_TRUE@ $(top_srcdir)/converters/t/test_0004_conversion_options.t \

converters/meson.build

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ if img2sixel_opt.enabled()
9999
endif
100100

101101
test_scripts = [
102-
'test_0001_invalid_option.t',
102+
'test_0001_01_invalid_positional.t',
103+
'test_0001_02_invalid_option_arguments.t',
104+
'test_0001_03_invalid_option_combinations.t',
103105
'test_0002_stdin.t',
104106
'test_0003_information.t',
105107
'test_0004_conversion_options.t',
@@ -133,7 +135,9 @@ if img2sixel_opt.enabled()
133135
# larger budget while keeping the remaining tests at the standard
134136
# limit.
135137
slow_test_timeouts = {
136-
'test_0001_invalid_option.t': 300,
138+
'test_0001_01_invalid_positional.t': 300,
139+
'test_0001_02_invalid_option_arguments.t': 300,
140+
'test_0001_03_invalid_option_combinations.t': 300,
137141
}
138142
order = 0
139143
foreach script : test_scripts
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
# Verify error handling for invalid img2sixel positional inputs.
3+
set -euo pipefail
4+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
5+
# shellcheck source=converters/t/common.t
6+
source "${SCRIPT_DIR}/common.t"
7+
8+
echo '[test1] invalid positional input handling'
9+
10+
expect_failure() {
11+
local output_file
12+
local label
13+
14+
output_file=$(mktemp "${TMP_DIR}/capture.invalid.XXXXXX")
15+
label="$*"
16+
# Windows builds may fall back to stdin when an input path is rejected.
17+
# Redirect /dev/null so the executable cannot block while waiting for
18+
# console input once argument validation fails.
19+
if run_img2sixel "$@" </dev/null >"${output_file}" 2>/dev/null; then
20+
:
21+
fi
22+
if [[ -s ${output_file} ]]; then
23+
printf 'img2sixel unexpectedly produced output: %s\n' \
24+
"${label}" >&2
25+
rm -f "${output_file}"
26+
exit 1
27+
fi
28+
rm -f "${output_file}"
29+
}
30+
31+
# Ensure an unreadable input file does not leave stray output.
32+
invalid_file="${TMP_DIR}/invalid-input"
33+
rm -f "${invalid_file}"
34+
touch "${invalid_file}"
35+
chmod a-r "${invalid_file}"
36+
expect_failure "${invalid_file}"
37+
rm -f "${invalid_file}"
38+
rm -f "${TMP_DIR}/invalid_filename"
39+
40+
# Reject a missing input path.
41+
expect_failure "${TMP_DIR}/invalid_filename"
42+
43+
# Reject a directory as input.
44+
expect_failure "."

converters/t/test_0001_invalid_option.t renamed to converters/t/test_0001_02_invalid_option_arguments.t

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
2-
# Verify error handling for invalid img2sixel options.
2+
# Verify error handling for img2sixel options with invalid arguments.
33
set -euo pipefail
44
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
55
# shellcheck source=converters/t/common.t
66
source "${SCRIPT_DIR}/common.t"
77

8-
echo '[test1] invalid option handling'
8+
echo '[test2] invalid option argument handling'
99

1010
# Ensure reference inputs exist for option validation checks that need them.
1111
for name in map8.png snake.jpg snake.png; do
@@ -33,19 +33,6 @@ expect_failure() {
3333
rm -f "${output_file}"
3434
}
3535

36-
# Ensure an unreadable input file does not leave stray output.
37-
invalid_file="${TMP_DIR}/invalid-input"
38-
rm -f "${invalid_file}"
39-
touch "${invalid_file}"
40-
chmod a-r "${invalid_file}"
41-
expect_failure "${invalid_file}"
42-
rm -f "${invalid_file}"
43-
rm -f "${TMP_DIR}/invalid_filename"
44-
45-
# Reject a missing input path.
46-
expect_failure "${TMP_DIR}/invalid_filename"
47-
# Reject a directory as input.
48-
expect_failure "."
4936
# Report an unknown dither option.
5037
expect_failure -d invalid_option
5138
# Report an unknown resize filter.
@@ -84,13 +71,5 @@ expect_failure -B 'rgb:11/11'
8471
expect_failure '-%'
8572
# Reject a palette file that does not exist.
8673
expect_failure -m "${TMP_DIR}/invalid_filename" "${IMAGES_DIR}/snake.jpg"
87-
# Reject mutually exclusive palette and encode flags.
88-
expect_failure -p16 -e "${IMAGES_DIR}/snake.jpg"
8974
# Reject an invalid colour space index.
9075
expect_failure -I -C0 "${IMAGES_DIR}/snake.png"
91-
# Reject incompatible inspect and palette options.
92-
expect_failure -I -p8 "${IMAGES_DIR}/snake.png"
93-
# Reject conflicting palette size and terminal preset.
94-
expect_failure -p64 -bxterm256 "${IMAGES_DIR}/snake.png"
95-
# Reject 8-bit output when palette dump is requested.
96-
expect_failure -8 -P "${IMAGES_DIR}/snake.png"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# Verify error handling for incompatible img2sixel option combinations.
3+
set -euo pipefail
4+
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
5+
# shellcheck source=converters/t/common.t
6+
source "${SCRIPT_DIR}/common.t"
7+
8+
echo '[test3] invalid option combination handling'
9+
10+
# Ensure reference inputs exist for option validation checks that need them.
11+
for name in snake.jpg snake.png; do
12+
require_file "${IMAGES_DIR}/${name}"
13+
done
14+
15+
expect_failure() {
16+
local output_file
17+
local label
18+
19+
output_file=$(mktemp "${TMP_DIR}/capture.invalid.XXXXXX")
20+
label="$*"
21+
# Windows builds may fall back to stdin when an input path is rejected.
22+
# Redirect /dev/null so the executable cannot block while waiting for
23+
# console input once argument validation fails.
24+
if run_img2sixel "$@" </dev/null >"${output_file}" 2>/dev/null; then
25+
:
26+
fi
27+
if [[ -s ${output_file} ]]; then
28+
printf 'img2sixel unexpectedly produced output: %s\n' \
29+
"${label}" >&2
30+
rm -f "${output_file}"
31+
exit 1
32+
fi
33+
rm -f "${output_file}"
34+
}
35+
36+
# Reject mutually exclusive palette and encode flags.
37+
expect_failure -p16 -e "${IMAGES_DIR}/snake.jpg"
38+
# Reject incompatible inspect and palette options.
39+
expect_failure -I -p8 "${IMAGES_DIR}/snake.png"
40+
# Reject conflicting palette size and terminal preset.
41+
expect_failure -p64 -bxterm256 "${IMAGES_DIR}/snake.png"
42+
# Reject 8-bit output when palette dump is requested.
43+
expect_failure -8 -P "${IMAGES_DIR}/snake.png"

meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ loader_helper_sources = files(
766766
'src/scale.c',
767767
'src/status.c',
768768
'src/tty.c',
769+
'src/fillrun.c',
769770
)
770771

771772
if have_threads
@@ -775,6 +776,7 @@ if have_threads
775776
'src/decoder-prescan.c',
776777
'src/decoder-parallel.c',
777778
]
779+
loader_helper_sources += files('src/fillrun.c')
778780
endif
779781

780782
if have_quicklook_thumbnailing

src/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ libsixel_la_SOURCES += \
110110
$(srcdir)/decoder-prescan.c \
111111
$(srcdir)/decoder-prescan.h \
112112
$(srcdir)/decoder-parallel.c \
113-
$(srcdir)/decoder-parallel.h
113+
$(srcdir)/decoder-parallel.h \
114+
$(srcdir)/fillrun.c \
115+
$(srcdir)/fillrun.h
114116
endif
115117
if HAVE_QUICKLOOK_THUMBNAILING
116118
libsixel_la_SOURCES += \

src/Makefile.in

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ host_triplet = @host@
9898
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/decoder-prescan.c \
9999
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/decoder-prescan.h \
100100
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/decoder-parallel.c \
101-
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/decoder-parallel.h
101+
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/decoder-parallel.h \
102+
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/fillrun.c \
103+
@SIXEL_ENABLE_THREADS_TRUE@ $(srcdir)/fillrun.h
102104

103105
@HAVE_QUICKLOOK_THUMBNAILING_TRUE@am__append_2 = \
104106
@HAVE_QUICKLOOK_THUMBNAILING_TRUE@ $(srcdir)/quicklook_thumbnailing.m
@@ -203,18 +205,20 @@ am__libsixel_la_SOURCES_DIST = $(srcdir)/output.c $(srcdir)/output.h \
203205
$(srcdir)/malloc_stub.c $(srcdir)/malloc_stub.h \
204206
$(srcdir)/allocator.c $(srcdir)/allocator.h $(srcdir)/tty.c \
205207
$(srcdir)/tty.h $(srcdir)/sixel_threads_config.h \
206-
$(srcdir)/sixel_atomic.h $(srcdir)/rgblookup.h \
207-
$(srcdir)/lso2.h $(srcdir)/sixel_threading.c \
208-
$(srcdir)/sixel_threading.h $(srcdir)/threadpool.c \
209-
$(srcdir)/threadpool.h $(srcdir)/decoder-prescan.c \
210-
$(srcdir)/decoder-prescan.h $(srcdir)/decoder-parallel.c \
211-
$(srcdir)/decoder-parallel.h \
212-
$(srcdir)/quicklook_thumbnailing.m $(srcdir)/clipboard_macos.m
208+
$(srcdir)/sixel_atomic.h $(srcdir)/rgblookup.h \
209+
$(srcdir)/lso2.h $(srcdir)/sixel_threading.c \
210+
$(srcdir)/sixel_threading.h $(srcdir)/threadpool.c \
211+
$(srcdir)/threadpool.h $(srcdir)/decoder-prescan.c \
212+
$(srcdir)/decoder-prescan.h $(srcdir)/decoder-parallel.c \
213+
$(srcdir)/decoder-parallel.h $(srcdir)/fillrun.c \
214+
$(srcdir)/fillrun.h \
215+
$(srcdir)/quicklook_thumbnailing.m $(srcdir)/clipboard_macos.m
213216
@SIXEL_ENABLE_THREADS_TRUE@am__objects_1 = \
214217
@SIXEL_ENABLE_THREADS_TRUE@ libsixel_la-sixel_threading.lo \
215218
@SIXEL_ENABLE_THREADS_TRUE@ libsixel_la-threadpool.lo \
216219
@SIXEL_ENABLE_THREADS_TRUE@ libsixel_la-decoder-prescan.lo \
217-
@SIXEL_ENABLE_THREADS_TRUE@ libsixel_la-decoder-parallel.lo
220+
@SIXEL_ENABLE_THREADS_TRUE@ libsixel_la-decoder-parallel.lo \
221+
@SIXEL_ENABLE_THREADS_TRUE@ libsixel_la-fillrun.lo
218222
@HAVE_QUICKLOOK_THUMBNAILING_TRUE@am__objects_2 = libsixel_la-quicklook_thumbnailing.lo
219223
@HAVE_CLIPBOARD_MACOS_TRUE@am__objects_3 = \
220224
@HAVE_CLIPBOARD_MACOS_TRUE@ libsixel_la-clipboard_macos.lo
@@ -280,10 +284,11 @@ am__depfiles_remade = ./$(DEPDIR)/libsixel_la-allocator.Plo \
280284
./$(DEPDIR)/libsixel_la-clipboard.Plo \
281285
./$(DEPDIR)/libsixel_la-clipboard_macos.Plo \
282286
./$(DEPDIR)/libsixel_la-colorspace.Plo \
283-
./$(DEPDIR)/libsixel_la-compat_stub.Plo \
284-
./$(DEPDIR)/libsixel_la-decoder-parallel.Plo \
285-
./$(DEPDIR)/libsixel_la-decoder-prescan.Plo \
286-
./$(DEPDIR)/libsixel_la-decoder.Plo \
287+
./$(DEPDIR)/libsixel_la-compat_stub.Plo \
288+
./$(DEPDIR)/libsixel_la-decoder-parallel.Plo \
289+
./$(DEPDIR)/libsixel_la-decoder-prescan.Plo \
290+
./$(DEPDIR)/libsixel_la-fillrun.Plo \
291+
./$(DEPDIR)/libsixel_la-decoder.Plo \
287292
./$(DEPDIR)/libsixel_la-dither-common-pipeline.Plo \
288293
./$(DEPDIR)/libsixel_la-dither-fixed-8bit.Plo \
289294
./$(DEPDIR)/libsixel_la-dither-fixed-float32.Plo \
@@ -768,6 +773,7 @@ distclean-compile:
768773
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-compat_stub.Plo@am__quote@ # am--include-marker
769774
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-decoder-parallel.Plo@am__quote@ # am--include-marker
770775
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-decoder-prescan.Plo@am__quote@ # am--include-marker
776+
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-fillrun.Plo@am__quote@ # am--include-marker
771777
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-decoder.Plo@am__quote@ # am--include-marker
772778
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-dither-common-pipeline.Plo@am__quote@ # am--include-marker
773779
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libsixel_la-dither-fixed-8bit.Plo@am__quote@ # am--include-marker
@@ -1144,6 +1150,13 @@ libsixel_la-decoder-parallel.lo: decoder-parallel.c
11441150
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='decoder-parallel.c' object='libsixel_la-decoder-parallel.lo' libtool=yes @AMDEPBACKSLASH@
11451151
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
11461152
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsixel_la_CPPFLAGS) $(CPPFLAGS) $(libsixel_la_CFLAGS) $(CFLAGS) -c -o libsixel_la-decoder-parallel.lo `test -f 'decoder-parallel.c' || echo '$(srcdir)/'`decoder-parallel.c
1153+
libsixel_la-fillrun.lo: fillrun.c
1154+
# $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsixel_la_CPPFLAGS) $(CPPFLAGS) $(libsixel_la_CFLAGS) $(CFLAGS) -MT libsixel_la-fillrun.lo -MD -MP -MF $(DEPDIR)/libsixel_la-fillrun.Tpo -c -o libsixel_la-fillrun.lo `test -f 'fillrun.c' || echo '$(srcdir)/'`fillrun.c
1155+
# $(AM_V_at)$(am__mv) $(DEPDIR)/libsixel_la-fillrun.Tpo $(DEPDIR)/libsixel_la-fillrun.Plo
1156+
# $(AM_V_CC)source='fillrun.c' object='libsixel_la-fillrun.lo' libtool=yes
1157+
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp)
1158+
$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libsixel_la_CPPFLAGS) $(CPPFLAGS) $(libsixel_la_CFLAGS) $(CFLAGS) -c -o libsixel_la-fillrun.lo `test -f 'fillrun.c' || echo '$(srcdir)/'`fillrun.c
1159+
11471160

11481161
tests-tests.o: tests.c
11491162
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tests_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT tests-tests.o -MD -MP -MF $(DEPDIR)/tests-tests.Tpo -c -o tests-tests.o `test -f 'tests.c' || echo '$(srcdir)/'`tests.c

0 commit comments

Comments
 (0)