<commit_before>#!/usr/bin/env bash
set -e

rm -f test.out
rm -f fail.out
touch test.out
rm -f coverage.tmp
mkdir -p ./coverage
rm -f ./coverage/*.out

start=`date +%s`
COVER_PKGS=$(glide novendor | grep -v "test/..." | \
	grep -v "main/..." | grep -v "benchmarks/..." | \
	awk -v ORS=, '{ print $1 }' | sed $'s/,$/\\\n/')

FILES=$(go list ./... | grep -v "vendor" | grep "test\|examples")
FILES_ARR=($FILES)

for file in "${FILES_ARR[@]}"; do
	RAND=$(hexdump -n 8 -v -e '/1 "%02X"' /dev/urandom)
	echo "Running coverage test : $file"
	COVER_ON=1 go test -cover -coverpkg $COVER_PKGS \
		-coverprofile coverage.tmp $file >>test.out 2>&1 && \
		mv coverage.tmp "./coverage/cover-unit-$RAND.out" 2>/dev/null || true
	end=`date +%s`
	runtime=$((end-start))
	echo "Finished coverage test : $file : +$runtime"
done

cat test.out | grep -v "warning: no packages" | grep -v "\[no test files\]" || true
rm -f coverage.tmp
grep "FAIL" test.out | tee -a fail.out
[ ! -s fail.out ]

go get github.com/wadey/gocovmerge
bash ./scripts/concat-coverage.sh

end=`date +%s`
runtime=$((end-start))
echo "Finished concatting coverage : +$runtime"

make generate-istanbul-json<commit_msg>Add coverage check for individual test files<commit_after>#!/usr/bin/env bash
set -e

rm -f test.out
rm -f fail.out
touch test.out
rm -f coverage.tmp
mkdir -p ./coverage
rm -f ./coverage/*.out

start=`date +%s`
COVER_PKGS=$(glide novendor | grep -v "test/..." | \
	grep -v "main/..." | grep -v "benchmarks/..." | \
	awk -v ORS=, '{ print $1 }' | sed $'s/,$/\\\n/')

if [ $# -eq 0 ]
then
    FILES=$(go list ./... | grep -v "vendor" | grep "test\|examples")
else
    FILES="$@"
fi

FILES_ARR=($FILES)

for file in "${FILES_ARR[@]}"; do
	RAND=$(hexdump -n 8 -v -e '/1 "%02X"' /dev/urandom)
	echo "Running coverage test : $file"
	COVER_ON=1 go test -cover -coverpkg $COVER_PKGS \
		-coverprofile coverage.tmp $file >>test.out 2>&1 && \
		mv coverage.tmp "./coverage/cover-unit-$RAND.out" 2>/dev/null || true
	end=`date +%s`
	runtime=$((end-start))
	echo "Finished coverage test : $file : +$runtime"
done

cat test.out | grep -v "warning: no packages" | grep -v "\[no test files\]" || true
rm -f coverage.tmp
grep "FAIL" test.out | tee -a fail.out
[ ! -s fail.out ]

go get github.com/wadey/gocovmerge
bash ./scripts/concat-coverage.sh

end=`date +%s`
runtime=$((end-start))
echo "Finished concatting coverage : +$runtime"

make generate-istanbul-json
{'fraction_non_alphanumeric': 0.20049710024855014, 'fraction_numerical': 0.007870753935376968, 'mean_word_length': 3.2, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1306299', 'n_tokens_mistral': 998, 'n_tokens_neox': 934, 'n_words': 276}