mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
Merge pull request #4587 from wilzbach/test-codecov
show code coverage with Codecov.io
This commit is contained in:
commit
aa017e5001
2 changed files with 26 additions and 14 deletions
28
.travis.yml
28
.travis.yml
|
@ -2,23 +2,35 @@ sudo: false
|
|||
os: linux
|
||||
language: d
|
||||
d: dmd-2.071.0
|
||||
git:
|
||||
depth: 1
|
||||
install:
|
||||
- wget "https://raw.githubusercontent.com/dlang/dmd/master/src/checkwhitespace.d" -O ../checkwhitespace.d
|
||||
- mkdir phobos
|
||||
- ls -1 | grep -v ^phobos | xargs -I{} mv {} phobos
|
||||
- git clone --depth=1 https://github.com/dlang/dmd
|
||||
- git clone --depth=1 https://github.com/dlang/druntime
|
||||
# whitespace check
|
||||
- wget "https://raw.githubusercontent.com/dlang/dmd/master/src/checkwhitespace.d" -O checkwhitespace.d
|
||||
# dscanner
|
||||
- git clone https://github.com/Hackerpilot/Dscanner
|
||||
- (cd Dscanner && git checkout tags/v0.4.0-alpha6)
|
||||
- (cd Dscanner && git submodule update --init --recursive)
|
||||
# debug build is faster, but disable 'missing import' messages (missing core from druntime)
|
||||
- (cd Dscanner && sed 's/dparse_verbose/StdLoggerDisableWarning/' -i makefile && make githash debug)
|
||||
# avoid checking it's dscanner's directory
|
||||
- mv Dscanner/dsc .
|
||||
- rm -rf Dscanner
|
||||
script:
|
||||
- (cd .. && rdmd ./checkwhitespace.d $(find phobos -name '*.d'))
|
||||
- rdmd ./checkwhitespace.d $(find phobos -name '*.d')
|
||||
# enforce whitespace between statements
|
||||
- grep -nE "(for|foreach|foreach_reverse|if|while|switch|catch)\(" $(find . -name '*.d'); test $? -eq 1
|
||||
- (cd phobos && grep -nE "(for|foreach|foreach_reverse|if|while|switch|catch)\(" $(find . -name '*.d'); test $? -eq 1)
|
||||
# enforce whitespace between colon(:) for import statements (doesn't catch everything)
|
||||
- grep -n 'import [^/,=]*:.*;' $(find . -name '*.d') | grep -vE "import ([^ ]+) :\s"; test $? -eq 1
|
||||
- (cd phobos && grep -n 'import [^/,=]*:.*;' $(find . -name '*.d') | grep -vE "import ([^ ]+) :\s"; test $? -eq 1)
|
||||
# enforce all-man style
|
||||
- grep -nE '(if|for|foreach|foreach_reverse|while|unittest|switch|else|version) .*{$' $(find . -name '*.d'); test $? -eq 1
|
||||
- (cd phobos && grep -nE '(if|for|foreach|foreach_reverse|while|unittest|switch|else|version) .*{$' $(find . -name '*.d'); test $? -eq 1)
|
||||
# at the moment libdparse has problems to parse some modules (->excludes)
|
||||
- ./dsc --config .dscanner.ini --styleCheck $(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d|std/conv.d') -I.
|
||||
- (cd phobos && ../Dscanner/dsc --config ../.dscanner.ini --styleCheck $(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d|std/conv.d') -I.)
|
||||
# test code coverage
|
||||
- (cd dmd && make -f posix.mak)
|
||||
- (cd druntime && make -f posix.mak)
|
||||
- (cd phobos && make -f posix.mak $(find std etc -name "*.d" | sed "s/[.]d$/.test/" | grep -vE '(std.algorithm.sorting|std.encoding|net.curl)' ))
|
||||
after_success:
|
||||
- (cd phobos && bash <(curl -s https://codecov.io/bash))
|
||||
|
|
|
@ -1934,10 +1934,10 @@ result is greater than or equal to $(D max).
|
|||
ElementType!Range entropy(Range)(Range r) if (isInputRange!Range)
|
||||
{
|
||||
Unqual!(typeof(return)) result = 0.0;
|
||||
foreach (e; r)
|
||||
for (;!r.empty; r.popFront)
|
||||
{
|
||||
if (!e) continue;
|
||||
result -= e * log2(e);
|
||||
if (!r.front) continue;
|
||||
result -= r.front * log2(r.front);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1948,10 +1948,10 @@ if (isInputRange!Range &&
|
|||
!is(CommonType!(ElementType!Range, F) == void))
|
||||
{
|
||||
Unqual!(typeof(return)) result = 0.0;
|
||||
foreach (e; r)
|
||||
for (;!r.empty; r.popFront)
|
||||
{
|
||||
if (!e) continue;
|
||||
result -= e * log2(e);
|
||||
if (!r.front) continue;
|
||||
result -= r.front * log2(r.front);
|
||||
if (result >= max) break;
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue