Skip to content

Commit

Permalink
enable CI tests on all native OS builds (#273)
Browse files Browse the repository at this point in the history
* enable CI tests on all native OS builds except for macos-13 CI which still fails in test-sheet-1 for unknown reasons
  • Loading branch information
liquidaty authored Nov 9, 2024
1 parent 225d52e commit 731e553
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
- name: Set up macOS (AMD64 and ARM64)
if: runner.os == 'macOS'
run: |
brew install --quiet coreutils tree autoconf automake libtool
brew install --quiet coreutils tree autoconf automake libtool tmux sqlite3
brew uninstall jq
# --- Build ---
Expand Down Expand Up @@ -185,7 +185,7 @@ jobs:
PREFIX: ${{ env.ARM64_MACOSX_GCC }}
CC: gcc-13
MAKE: make
RUN_TESTS: false
RUN_TESTS: true
run: ./scripts/ci-build.sh

# --- Upload build artifacts ---
Expand Down Expand Up @@ -364,7 +364,7 @@ jobs:
PREFIX: ${{ env.AMD64_FREEBSD_GCC }}
CC: gcc
MAKE: gmake
RUN_TESTS: false
RUN_TESTS: true
with:
operating_system: freebsd
version: '13.2'
Expand Down
10 changes: 5 additions & 5 deletions app/benchmark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ ZSVBIN=../../build/${BUILD_SUBDIR}/${CCBN}/bin/zsv_

QUICK=1

MAKE_BIN=$(notdir ${MAKE})

help:
@echo "To run all tests (set QUICK to skip mlr and csvcut):"
@echo " make all [QUICK=0] [PULL=1]"
@echo " make CLI"
@echo " ${MAKE_BIN} all [QUICK=0] [PULL=1]"
@echo " ${MAKE_BIN} CLI"

CLI: ZSVBIN="zsv "

CLI:
make all QUICK=${QUICK} ZSVBIN=${ZSVBIN} -n | sed 's/[.]*\/.*\/bin\/zsv_/zsv /g' | sh


${MAKE} all QUICK=${QUICK} ZSVBIN=${ZSVBIN} -n | sed 's/[.]*\/.*\/bin\/zsv_/zsv /g' | sh

all: count select tsv

Expand Down
6 changes: 3 additions & 3 deletions app/ext_example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ CLI=${BUILD_DIR}/bin/cli
RUN_CLI=ZSV_CONFIG_DIR=/tmp ${CLI}

${BUILD_DIR}/bin/cli:
make -C .. build-cli CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG}
${MAKE} -C .. build-cli CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG}

${BUILD_DIR}/objs/utils/%.o:
(cd .. && make CONFIGFILE=${CONFIGFILEPATH} CC=${CC} DEBUG=${DEBUG} $@ )
(cd .. && ${MAKE} CONFIGFILE=${CONFIGFILEPATH} CC=${CC} DEBUG=${DEBUG} $@ )

test: test-1 test-2 test-3 test-4 test-5 test-thirdparty

Expand Down Expand Up @@ -156,7 +156,7 @@ clean:
@rm -f ${TARGET} /tmp/zsvext-test*.out

${BUILD_DIR}/objs/%.o : ${THIS_LIB_BASE}/src/%.c ${PARSER_DEPS}
make -C ${THIS_LIB_BASE}/src CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG} WIN=${WIN} $@
${MAKE} -C ${THIS_LIB_BASE}/src CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG} WIN=${WIN} $@

${TARGET}: my_extension.c ${UTILS}
@mkdir -p `dirname "$@"`
Expand Down
2 changes: 1 addition & 1 deletion app/ext_template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ all: ${TARGET}

# zsv utils
${BUILD_DIR}/objs/utils/%.o:
(cd .. && make CONFIGFILE=${CONFIGFILEPATH} CC=${CC} DEBUG=${DEBUG} $@ )
(cd .. && ${MAKE} CONFIGFILE=${CONFIGFILEPATH} CC=${CC} DEBUG=${DEBUG} $@ )

install: ${TARGET}
@echo "To install, copy ${TARGET} to a system path or the same dir"
Expand Down
4 changes: 2 additions & 2 deletions app/sheet/read-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static int read_data(struct zsvsheet_ui_buffer **uibufferp, // a new zsvsheet_
opts.stream = fp;
}

enum zsv_index_status zst;
enum zsv_index_status zst = zsv_index_status_ok;
if (uibuff->index_ready) {
opts.header_span = 0;
opts.rows_to_ignore = 0;
Expand Down Expand Up @@ -234,7 +234,7 @@ static void *get_data_index(void *gdi) {
if (d->row_filter != NULL) {
if (d->uib->index->row_count > 0) {
d->uib->dimensions.row_count = d->uib->index->row_count + 1;
asprintf(&d->uib->status, "(%zu filtered rows) ", d->uib->index->row_count);
asprintf(&d->uib->status, "(%" PRIu64 " filtered rows) ", d->uib->index->row_count);
} else
d->uib->status = NULL;
} else {
Expand Down
29 changes: 17 additions & 12 deletions app/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ else
CMP=cmp
endif

MAKE_BIN=$(notdir ${MAKE})

help:
@echo "To run all tests: make test [LEAKS=1]"
@echo "To run individual test: make test-xxx"
@echo "To run on cli: make CLI"
@echo "To run all tests: ${MAKE_BIN} test [LEAKS=1]"
@echo "To run individual test: ${MAKE_BIN} test-xxx"
@echo "To run on cli: ${MAKE_BIN} CLI"
@echo " where xxx can be: blank-leading-rows ${SOURCES}"

clean:
rm -rf ${TMP_DIR}

CLI:
@echo "Testing CLI..."
@make CLI1=1 test -n | sed 's/\/[^ ]*\/bin\/zsv_/zsv /g' | sh
@${MAKE} CLI1=1 test -n | sed 's/\/[^ ]*\/bin\/zsv_/zsv /g' | sh

test: ${TESTS}

Expand All @@ -107,10 +109,10 @@ test-paste:
.PHONY: help test test-% test-stack clean

test-prop:
EXE=${BUILD_DIR}/bin/zsv_prop${EXE} make -C prop test
EXE=${BUILD_DIR}/bin/zsv_prop${EXE} ${MAKE} -C prop test

test-overwrite: ${BUILD_DIR}/bin/zsv_overwrite${EXE} ${BUILD_DIR}/bin/zsv_echo${EXE}
EXE=${BUILD_DIR}/bin/zsv_overwrite${EXE} ECHO_EXE=${BUILD_DIR}/bin/zsv_echo${EXE} CMP=$(CMP) make -C overwrite test
EXE=${BUILD_DIR}/bin/zsv_overwrite${EXE} ECHO_EXE=${BUILD_DIR}/bin/zsv_echo${EXE} CMP=$(CMP) ${MAKE} -C overwrite test

test-echo : test-echo1 test-echo-overwrite-all test-echo-eol test-echo-chars test-echo-trim test-echo-skip-until test-echo-contiguous test-echo-trim-columns test-echo-trim-columns-2 test-echo-buffsize

Expand Down Expand Up @@ -464,7 +466,7 @@ test-sql5: ${BUILD_DIR}/bin/zsv_sql${EXE} # test blank rows
@${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || ${TEST_FAIL}

${BUILD_DIR}/bin/zsv_%${EXE}:
make -C .. $@ CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG}
${MAKE} -C .. $@ CONFIGFILE=${CONFIGFILEPATH} DEBUG=${DEBUG}

test-2db: test-%: ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv ${BUILD_DIR}/bin/zsv_2json${EXE} ${BUILD_DIR}/bin/zsv_select${EXE}
@${TEST_INIT}
Expand Down Expand Up @@ -577,19 +579,22 @@ test-compare: test-%: ${BUILD_DIR}/bin/zsv_%${EXE}
@(${PREFIX} $< ../../data/compare/t1.csv ../../data/compare/t2.csv --add AccentCity --sort -k country -k city ${REDIRECT1} ${TMP_DIR}/[email protected] && \
${CMP} ${TMP_DIR}/[email protected] expected/[email protected] && ${TEST_PASS} || ${TEST_FAIL})

test-sheet: test-%: ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv test-sheet-all
test-sheet: test-%: ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv test-sheet-cleanup test-sheet-all

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
@(for SESSION in $^; do ! tmux kill-session -t "$$SESSION" 2>/dev/null; done && ${TEST_PASS} || ${TEST_FAIL})

test-sheet-1: ${BUILD_DIR}/bin/zsv_sheet${EXE}
@${TEST_INIT}
@echo 'set-option default-terminal "tmux-256color"' > ~/.tmux.conf
@(tmux new-session -x 80 -y 5 -d -s $@ "${PREFIX} $< worldcitiespop_mil.csv" && \
@(tmux -v new-session -x 80 -y 5 -d -s $@ "${PREFIX} $< worldcitiespop_mil.csv" && \
sleep 0.5 && \
tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/$@.out && \
tmux send-keys -t $@ "q" && \
${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || ${TEST_FAIL})
tmux -v capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/$@.out && \
tmux -v send-keys -t $@ "q" && \
${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || (for x in `ls tmux-*.log` ; do echo "Log $$x:" && cat $$x ; done && ${TEST_FAIL}))

test-sheet-2: ${BUILD_DIR}/bin/zsv_sheet${EXE}
@${TEST_INIT}
Expand Down
3 changes: 1 addition & 2 deletions app/utils/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#include <unistd.h>
#include <zsv.h>
#include <zsv/utils/prop.h>

#include "zsv/utils/index.h"
#include <zsv/utils/index.h>

struct zsv_index *zsv_index_new(void) {
struct zsv_index *ix = malloc(sizeof(*ix));
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci-freebsd-setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

sudo pkg install -y tree zip git autotools gmake lang/gcc
sudo pkg install -y tree zip git autotools gmake lang/gcc tmux sqlite3 terminfo-db

0 comments on commit 731e553

Please sign in to comment.