Skip to content

Commit bb9ae86

Browse files
authored
generate code coverage report (#378)
1 parent 8f86d8b commit bb9ae86

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,14 @@ jobs:
5252
run: cd src && nmake.exe /F Makefile.windows.mk
5353
- name: Test
5454
run: ./loda.exe test
55+
code-coverage:
56+
runs-on: ubuntu-22.04
57+
steps:
58+
- uses: actions/checkout@v2
59+
- name: Generate
60+
run: sudo apt install lcov && cd src && make -f Makefile.linux-x86.mk coverage
61+
- name: Upload
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: code-coverage-report
65+
path: src/coverage/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.o
77
*.obj
88
*.pdb
9+
/src/coverage/
910
/src/loda
1011
/src/loda.exe
1112
/tests/programs/local/

src/Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CXXFLAGS += -I. -O2 -g -Wall -Werror -fmessage-length=0 -std=c++17
1+
CXXFLAGS += -I. -g -Wall -Werror -fmessage-length=0 -std=c++17
22

33
ifdef LODA_VERSION
44
CXXFLAGS += -DLODA_VERSION=$(LODA_VERSION)
@@ -17,10 +17,23 @@ OBJS = cmd/benchmark.o cmd/boinc.o cmd/commands.o cmd/main.o cmd/test.o \
1717
oeis/oeis_list.o oeis/oeis_manager.o oeis/oeis_program.o oeis/oeis_sequence.o \
1818
sys/file.o sys/git.o sys/jute.o sys/log.o sys/metrics.o sys/process.o sys/setup.o sys/util.o sys/web_client.o
1919

20+
loda: CXXFLAGS += -O2
2021
loda: $(OBJS)
2122
$(CXX) $(LDFLAGS) -o loda $(OBJS)
2223
[ -L ../loda ] || ( cd .. && ln -s src/loda loda )
2324
du -sh loda
2425

26+
coverage: CXXFLAGS += -O0 -fprofile-arcs -ftest-coverage
27+
coverage: LDFLAGS += --coverage
28+
coverage: $(OBJS)
29+
$(CXX) $(LDFLAGS) -o loda $(OBJS)
30+
[ -L ../loda ] || ( cd .. && ln -s src/loda loda )
31+
cd .. && ./loda test && cd src
32+
gcov $(OBJS:.o=.cpp)
33+
mkdir coverage
34+
lcov -c -d . -o coverage/coverage.info
35+
lcov -r coverage/coverage.info '/Library/*' '/usr/*' -o coverage/coverage-clean.info
36+
genhtml coverage/coverage-clean.info -o coverage
37+
2538
clean:
26-
rm -R -f $(OBJS) loda ../loda
39+
rm -R -f $(OBJS) $(OBJS:.o=.gcda) $(OBJS:.o=.gcno) *.gcov coverage loda ../loda

0 commit comments

Comments
 (0)