From fbd0ea356929c18516268e98ebe8e778db612af9 Mon Sep 17 00:00:00 2001 From: "John K. Luebs" Date: Mon, 26 Feb 2024 13:16:01 -0600 Subject: [PATCH] Add gcov --- .github/workflows/busted.yml | 33 +++++++++++++++++++++++++-------- .gitignore | 5 +++++ .luacov | 5 +++++ Makefile | 20 ++++++++++++-------- 4 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 .luacov diff --git a/.github/workflows/busted.yml b/.github/workflows/busted.yml index d8d0da0..e3b8e82 100644 --- a/.github/workflows/busted.yml +++ b/.github/workflows/busted.yml @@ -35,19 +35,36 @@ jobs: - name: Setup dependencies run: | luarocks install busted - luarocks install luacov-coveralls - - name: Build C library + luarocks install luacov-reporter-lcov + - name: Build C++ library run: | - ${{ matrix.os == 'ubuntu-latest' && 'FSANITIZE=1' || '' }} luarocks make --no-install + luarocks make --no-install + env: + LJKIWI_LUA: ${{ startsWith(matrix.lua_version, 'luajit-') && '0' || '1' }} + LJKIWI_CFFI: ${{ startsWith(matrix.lua_version, 'luajit-') && '1' || '0' }} + FCOV: ${{ startsWith(matrix.os, 'ubuntu-') && '1' || '' }} + # Can't assume so versions, have to update this manually below + FSANITIZE: ${{ matrix.os == 'ubuntu-latest' && '1' || '' }} + - name: Run busted tests run: | - ${{ matrix.os == 'ubuntu-latest' && 'LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.6:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libubsan.so.1' || '' }} busted -c -v - - name: Report test coverage + busted -c -v + env: + LD_PRELOAD: ${{ matrix.os == 'ubuntu-latest' && '/usr/lib/x86_64-linux-gnu/libasan.so.6:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libubsan.so.1' || '' }} + + - name: Run gcov + if: ${{ startsWith(matrix.os, 'ubuntu-') }} + run: | + gcov -p -b -s"$(pwd)" -r *.gcda + + - name: generate Lua lcov test reports if: success() && !startsWith(matrix.os, 'windows-') && startsWith(matrix.lua_version, 'luajit-') + run: luacov + + - name: Report test coverage + if: success() && !startsWith(matrix.os, 'windows-') && (startsWith(matrix.lua_version, 'luajit-') || startsWith(matrix.os, 'ubuntu-')) continue-on-error: true - run: luacov-coveralls -e .luarocks -e spec - env: - COVERALLS_REPO_TOKEN: ${{ github.token }} + uses: coverallsapp/github-action@v2 finish: if: always() diff --git a/.gitignore b/.gitignore index 0aecd58..35e2c35 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,11 @@ /lua_modules /.luarocks /config.mk +*.gcda +*.gcno +*.gcov +*.lcov +*.out *.pch *.gch *.lib diff --git a/.luacov b/.luacov new file mode 100644 index 0000000..2ae2880 --- /dev/null +++ b/.luacov @@ -0,0 +1,5 @@ +modules = { + kiwi = "kiwi.lua", +} +reporter = "lcov" +reportfile = "luacov.lcov" diff --git a/Makefile b/Makefile index 7edd6cd..8a8fec2 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ SANITIZE_FLAGS := -fsanitize=undefined -fsanitize=address -fsanitize=alignment - -fsanitize=shift -fsanitize=unreachable -fsanitize=bool \ -fsanitize=enum +COVERAGE_FLAGS := -fprofile-arcs -ftest-coverage LTO_FLAGS := -flto=auto -include config.mk @@ -52,10 +53,13 @@ endif CCFLAGS += -Wall -fvisibility=hidden -Wformat=2 -Wconversion -Wimplicit-fallthrough +ifdef FCOV + CCFLAGS += $(COVERAGE_FLAGS) +endif ifdef FSANITIZE CCFLAGS += $(SANITIZE_FLAGS) endif -ifndef FNOLTO +ifdef FLTO CCFLAGS += $(LTO_FLAGS) endif @@ -80,11 +84,9 @@ ifdef LUA LUA_VERSION ?= $(lastword $(shell "$(LUA)" -e "print(_VERSION)")) endif -ifndef LUA_VERSION - LJKIWI_CKIWI := 1 -else -ifeq ($(LUA_VERSION),5.1) - LJKIWI_CKIWI := 1 +ifdef LUA_VERSION +ifneq ($(LUA_VERSION),5.1) + LJKIWI_CFFI ?= 0 endif endif @@ -92,8 +94,10 @@ kiwi_lib_srcs := AssocVector.h constraint.h debug.h errors.h expression.h kiwi.h row.h shareddata.h solver.h solverimpl.h strength.h symbol.h symbolics.h term.h \ util.h variable.h version.h -objs := luakiwi.o -ifdef LJKIWI_CKIWI +ifneq ($(LJKIWI_LUA),0) + objs += luakiwi.o +endif +ifneq ($(LJKIWI_CFFI),0) objs += ckiwi.o endif