Skip to content

Commit

Permalink
fix zsvopts not passed on when generating first-level filter result f…
Browse files Browse the repository at this point in the history
…ile (#286)

* fix zsvopts not passed on when generating first-level filter result file
* add test-sheet-10
  • Loading branch information
liquidaty authored Nov 13, 2024
1 parent dd4a72c commit f6ca8a4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/sheet/read-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ static int read_data(struct zsvsheet_ui_buffer **uibufferp, // a new zsvsheet_
if (uibuff->index_ready) {
opts.header_span = 0;
opts.rows_to_ignore = 0;

if (uibuff->data_filename) {
struct zsv_opts filter_opts = {0};
filter_opts.stream = opts.stream;
filter_opts.max_columns = opts.max_columns;
filter_opts.max_row_size = opts.max_row_size;
filter_opts.max_rows = opts.max_rows;
opts = filter_opts;
}
zst = zsv_index_seek_row(uibuff->index, &opts, start_row);

zsv_delete(parser);
Expand Down
17 changes: 16 additions & 1 deletion app/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ test-echo-overwrite-csv: ${BUILD_DIR}/bin/zsv_echo${EXE} ${TEST_DATA_DIR}/loans_
worldcitiespop_mil.csv:
curl -LOk 'https://burntsushi.net/stuff/worldcitiespop_mil.csv'

worldcitiespop_mil.tsv: worldcitiespop_mil.csv ${BUILD_DIR}/bin/zsv_2tsv
${BUILD_DIR}/bin/zsv_2tsv $< > $@

test-count test-count-pull: test-% : test-1-% test-2-%

test-cli: ${CLI}
Expand Down Expand Up @@ -584,7 +587,7 @@ test-sheet: test-%: ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv test-she
test-sheet-cleanup:
@rm -f tmux-*.log

test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9
test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 test-sheet-10
@(for SESSION in $^; do ! tmux kill-session -t "$$SESSION" 2>/dev/null; done && ${TEST_PASS} || ${TEST_FAIL})

TMUX_TERM=xterm-256color
Expand Down Expand Up @@ -684,3 +687,15 @@ test-sheet-9: ${BUILD_DIR}/bin/zsv_sheet${EXE}
tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/$@.out && \
tmux send-keys -t $@ "q" && \
${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || (echo 'Incorrect output:' && cat ${TMP_DIR}/$@.out && ${TEST_FAIL}))

test-sheet-10: ${BUILD_DIR}/bin/zsv_sheet${EXE} worldcitiespop_mil.tsv
@${TEST_INIT}
@echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf
@(tmux new-session -x 80 -y 6 -d -s $@ "${PREFIX} $< -t worldcitiespop_mil.tsv" && \
sleep 0.5 && \
tmux send-keys -t $@ "f" "e" "Enter" && \
sleep 1 && \
tmux send-keys -t $@ "G" && \
tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/$@.out && \
tmux send-keys -t $@ "q" && \
${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || (echo 'Incorrect output:' && cat ${TMP_DIR}/$@.out && ${TEST_FAIL}))
6 changes: 6 additions & 0 deletions app/test/expected/test-sheet-10.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Row # Country City AccentCit Region Populatio Latitude Longitude
493036 gb rutupiae Rutupiæ G5 51.283333 1.333333
493037 lv briezucie Briezucie 03 56.95 27.583333
493038 gw quenem Quenem 04 12.228333 -15.64444
493039 gb ryde Ryde G2 24107 50.716667 -1.166667
(493039 filtered rows) 493039

0 comments on commit f6ca8a4

Please sign in to comment.