Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit f98e980

Browse files
committed
add coverage tests
1 parent f240777 commit f98e980

File tree

8 files changed

+77
-1
lines changed

8 files changed

+77
-1
lines changed

posix.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ $(DRUNTIME): $(OBJS) $(SRCS)
193193
UT_MODULES:=$(patsubst src/%.d,$(OBJDIR)/%,$(SRCS))
194194
HAS_ADDITIONAL_TESTS:=$(shell test -d test && echo 1)
195195
ifeq ($(HAS_ADDITIONAL_TESTS),1)
196-
ADDITIONAL_TESTS:=test/init_fini test/exceptions
196+
ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage
197197
ADDITIONAL_TESTS+=$(if $(SHARED),test/shared,)
198198
endif
199199

test/coverage/Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# set from top makefile
2+
OS:=
3+
MODEL:=
4+
DMD:=
5+
DRUNTIME:=
6+
DRUNTIMESO:=
7+
QUIET:=
8+
LINKDL:=
9+
10+
SRC:=src
11+
ROOT:=./obj/$(OS)/$(MODEL)
12+
NORMAL_TESTS:=$(addprefix $(ROOT)/,$(addsuffix .done,basic))
13+
MERGE_TESTS:=$(addprefix $(ROOT)/,$(addsuffix .done,merge merge_false))
14+
15+
DIFF:=diff
16+
17+
ifneq (default,$(MODEL))
18+
MODEL_FLAG:=-m$(MODEL)
19+
endif
20+
CFLAGS:=$(MODEL_FLAG) -Wall
21+
DFLAGS:=$(MODEL_FLAG) -w -I../../src -I../../import -I$(SRC) -L$(DRUNTIME) -defaultlib= -debuglib= -cov
22+
23+
.PHONY: all clean
24+
all: $(NORMAL_TESTS) $(MERGE_TESTS)
25+
26+
$(NORMAL_TESTS): $(ROOT)/%.done: $(ROOT)/%
27+
@echo Testing $*
28+
@rm -f src-$*.lst
29+
$(QUIET)$(ROOT)/$* $(RUN_ARGS)
30+
$(QUIET)$(DIFF) src-$*.lst.exp src-$*.lst
31+
@touch $@
32+
33+
$(MERGE_TESTS): $(ROOT)/%.done: $(ROOT)/%
34+
@echo Testing $*
35+
@rm -f src-$*.lst
36+
$(QUIET)$(ROOT)/$* $(RUN_ARGS)
37+
$(QUIET)$(ROOT)/$* $(RUN_ARGS)
38+
$(QUIET)$(DIFF) src-$*.lst.exp src-$*.lst
39+
@touch $@
40+
41+
$(ROOT)/%: $(SRC)/%.d
42+
$(QUIET)$(DMD) $(DFLAGS) -of$(ROOT)/$* $<
43+
44+
clean:
45+
rm -rf obj *.lst

test/coverage/src-basic.lst.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
|int main()
2+
|{
3+
1| return 0;
4+
|}
5+
src/basic.d is 100% covered

test/coverage/src-merge.lst.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
|int main()
2+
|{
3+
2| return 0;
4+
|}
5+
src/merge.d is 100% covered
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
|extern(C) void dmd_coverSetMerge(bool);
2+
|
3+
|void main()
4+
|{
5+
1| dmd_coverSetMerge(false);
6+
|}
7+
src/merge_false.d is 100% covered

test/coverage/src/basic.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int main()
2+
{
3+
return 0;
4+
}

test/coverage/src/merge.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int main()
2+
{
3+
return 0;
4+
}

test/coverage/src/merge_false.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extern(C) void dmd_coverSetMerge(bool);
2+
3+
void main()
4+
{
5+
dmd_coverSetMerge(false);
6+
}

0 commit comments

Comments
 (0)