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

Commit

Permalink
Merge pull request #1393 from MartinNowak/coverage_no_code
Browse files Browse the repository at this point in the history
print filename in coverage reports for modules w/o code
  • Loading branch information
DmitryOlshansky committed Oct 3, 2015
2 parents 53d3955 + 93043bf commit e49df27
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/rt/cover.d
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ shared static ~this()
exit(EXIT_FAILURE);
}
}
else
{
fprintf(flst, "%.*s has no code\n", cast(int)c.filename.length, c.filename.ptr);
}

version (Windows)
SetEndOfFile(handle(fileno(flst)));
Expand Down
14 changes: 12 additions & 2 deletions test/coverage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include ../common.mak

DFLAGS+=-cov

NORMAL_TESTS:=$(addprefix $(ROOT)/,$(addsuffix .done,basic))
NORMAL_TESTS:=$(addprefix $(ROOT)/,$(addsuffix .done,basic no_code))
MERGE_TESTS:=$(addprefix $(ROOT)/,$(addsuffix .done,merge merge_true))

DIFF:=diff
Expand All @@ -25,8 +25,18 @@ $(MERGE_TESTS): $(ROOT)/%.done: $(ROOT)/%
$(QUIET)$(DIFF) src-$*.lst.exp $(ROOT)/src-$*.lst
@touch $@

$(ROOT)/no_code.done: $(ROOT)/%.done: $(ROOT)/%
@echo Testing $*
@rm -f $(ROOT)/src-$*.lst
$(QUIET)$(ROOT)/$* $(ROOT) $(RUN_ARGS)
$(QUIET)$(ROOT)/$* $(ROOT) $(RUN_ARGS)
$(QUIET)$(DIFF) src-$*.lst.exp $(ROOT)/src-$*.lst
$(QUIET)$(DIFF) src-$*_imp.lst.exp $(ROOT)/src-$*_imp.lst
@touch $@

$(ROOT)/no_code: $(SRC)/no_code_imp.d
$(ROOT)/%: $(SRC)/%.d
$(QUIET)$(DMD) $(DFLAGS) -of$(ROOT)/$* $<
$(QUIET)$(DMD) $(DFLAGS) -of$(ROOT)/$* $^

clean:
rm -rf $(ROOT) *.lst
7 changes: 7 additions & 0 deletions test/coverage/src-no_code.lst.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
|import core.runtime;
|
|void main(string[] args)
|{
1| dmd_coverDestPath(args[1]);
|}
src/no_code.d is 100% covered
2 changes: 2 additions & 0 deletions test/coverage/src-no_code_imp.lst.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
|enum NO_CODE_IMP = 0;
src/no_code_imp.d has no code
6 changes: 6 additions & 0 deletions test/coverage/src/no_code.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import core.runtime;

void main(string[] args)
{
dmd_coverDestPath(args[1]);
}
1 change: 1 addition & 0 deletions test/coverage/src/no_code_imp.d
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enum NO_CODE_IMP = 0;

0 comments on commit e49df27

Please sign in to comment.