forked from blevesearch/bleve
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding scripts for new code coverage
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
|
||
modeline := "" | ||
blocks := map[string]int{} | ||
scanner := bufio.NewScanner(os.Stdin) | ||
for scanner.Scan() { | ||
line := scanner.Text() | ||
if !strings.HasPrefix(line, "mode:") { | ||
lastSpace := strings.LastIndex(line, " ") | ||
prefix := line[0:lastSpace] | ||
suffix := line[lastSpace+1:] | ||
count, err := strconv.Atoi(suffix) | ||
if err != nil { | ||
fmt.Errorf("error parsing count: %v", err) | ||
continue | ||
} | ||
existingCount, exists := blocks[prefix] | ||
if exists { | ||
blocks[prefix] = existingCount + count | ||
} else { | ||
blocks[prefix] = count | ||
} | ||
} else if modeline == "" { | ||
modeline = line | ||
} | ||
} | ||
if err := scanner.Err(); err != nil { | ||
fmt.Fprintln(os.Stderr, "reading standard input:", err) | ||
} | ||
|
||
fmt.Println(modeline) | ||
for k, v := range blocks { | ||
fmt.Printf("%s %d\n", k, v) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
echo "mode: count" > acc.out | ||
for Dir in . $(find ./* -maxdepth 10 -type d ); | ||
do | ||
if ls $Dir/*.go &> /dev/null; | ||
then | ||
returnval=`go test -coverprofile=profile.out -covermode=count $Dir` | ||
echo ${returnval} | ||
if [[ ${returnval} != *FAIL* ]] | ||
then | ||
if [ -f profile.out ] | ||
then | ||
cat profile.out | grep -v "mode: count" >> acc.out | ||
fi | ||
else | ||
exit 1 | ||
fi | ||
fi | ||
done | ||
|
||
# collect integration test coverage | ||
echo "mode: count" > integration-acc.out | ||
INTPACKS=`go list ./... | grep -v utils | xargs | sed 's/ /,/g'` | ||
returnval=`go test -coverpkg=$INTPACKS -coverprofile=profile.out -covermode=count ./test` | ||
if [[ ${returnval} != *FAIL* ]] | ||
then | ||
if [ -f profile.out ] | ||
then | ||
cat profile.out | grep -v "mode: count" >> integration-acc.out | ||
fi | ||
else | ||
exit 1 | ||
fi | ||
|
||
cat acc.out integration-acc.out | go run docs/merge-coverprofile.go > merged.out | ||
|
||
if [ -n "$COVERALLS" ] | ||
then | ||
goveralls -service drone.io -coverprofile=merged.out -repotoken $COVERALLS | ||
fi | ||
|
||
rm -rf ./profile.out | ||
rm -rf ./acc.out | ||
rm -rf ./integration-acc.out | ||
rm -rf ./merged.out |