From 731e553d6cb33c06dd6b450c36a2927dca103c22 Mon Sep 17 00:00:00 2001 From: liquidaty Date: Sat, 9 Nov 2024 10:59:51 -0800 Subject: [PATCH] enable CI tests on all native OS builds (#273) * enable CI tests on all native OS builds except for macos-13 CI which still fails in test-sheet-1 for unknown reasons --- .github/workflows/ci.yml | 6 +++--- app/benchmark/Makefile | 10 +++++----- app/ext_example/Makefile | 6 +++--- app/ext_template/Makefile | 2 +- app/sheet/read-data.c | 4 ++-- app/test/Makefile | 29 +++++++++++++++++------------ app/utils/index.c | 3 +-- scripts/ci-freebsd-setup.sh | 2 +- 8 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 079f91f0..8d33298f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 --- @@ -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 --- @@ -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' diff --git a/app/benchmark/Makefile b/app/benchmark/Makefile index 9157b308..9f344f27 100644 --- a/app/benchmark/Makefile +++ b/app/benchmark/Makefile @@ -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 diff --git a/app/ext_example/Makefile b/app/ext_example/Makefile index 1a9ddce6..dacbcba4 100644 --- a/app/ext_example/Makefile +++ b/app/ext_example/Makefile @@ -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 @@ -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 "$@"` diff --git a/app/ext_template/Makefile b/app/ext_template/Makefile index 8763ea4a..bdeca458 100644 --- a/app/ext_template/Makefile +++ b/app/ext_template/Makefile @@ -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" diff --git a/app/sheet/read-data.c b/app/sheet/read-data.c index 0ee24dca..735a6a49 100644 --- a/app/sheet/read-data.c +++ b/app/sheet/read-data.c @@ -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; @@ -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 { diff --git a/app/test/Makefile b/app/test/Makefile index c70fba0a..2be835ba 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -84,10 +84,12 @@ 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: @@ -95,7 +97,7 @@ clean: 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} @@ -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 @@ -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} @@ -577,7 +579,10 @@ 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}/$@.out10 && \ ${CMP} ${TMP_DIR}/$@.out10 expected/$@.out10 && ${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}) @@ -585,11 +590,11 @@ test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 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} diff --git a/app/utils/index.c b/app/utils/index.c index 5e9a2213..23257006 100644 --- a/app/utils/index.c +++ b/app/utils/index.c @@ -5,8 +5,7 @@ #include #include #include - -#include "zsv/utils/index.h" +#include struct zsv_index *zsv_index_new(void) { struct zsv_index *ix = malloc(sizeof(*ix)); diff --git a/scripts/ci-freebsd-setup.sh b/scripts/ci-freebsd-setup.sh index cc0c5d0e..4de6fac6 100755 --- a/scripts/ci-freebsd-setup.sh +++ b/scripts/ci-freebsd-setup.sh @@ -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