Skip to content

Commit 82cf326

Browse files
committed
Merge pull request #193 from jacobwilliams/codecov
Getting codecov working again
2 parents 0f1ebff + 45ea958 commit 82cf326

File tree

4 files changed

+179
-159
lines changed

4 files changed

+179
-159
lines changed

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ env:
4141
DEPLOY_DOCUMENTATION="no"
4242
4343
# build with build.sh, make documentation, run unit tests and perform coverage analysis
44-
# JW note: disabled coverage for testing purposes !!!! need to fix !!!!
4544
- >
46-
BUILD_SCRIPT="./build.sh --skip-documentation &&
47-
./build.sh --enable-unicode"
48-
CODE_COVERAGE="no"
45+
BUILD_SCRIPT="./build.sh --coverage --skip-documentation &&
46+
./build.sh --coverage --enable-unicode"
47+
CODE_COVERAGE="yes"
4948
DEPLOY_DOCUMENTATION="yes"
5049
5150
install:
@@ -102,8 +101,8 @@ after_success:
102101
- (yes | rm -r doc gh-pages) || true # wipe out doc dirs to avoid confusing codecov
103102
- |
104103
if [[ $CODE_COVERAGE == [yY]* ]]; then
105-
rm json_module-*unicode.F90.gcov || true
106-
mv json_module.F90.gcov src/
104+
rm json_*.F90-*unicode.gcov || true
105+
mv json_*.F90.gcov src/
107106
mv jf_test*.[fF]90.gcov src/tests/
108107
bash <(curl -s https://codecov.io/bash) -v -X gcov
109108
fi

build.sh

Lines changed: 156 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -117,122 +117,122 @@ while [ "$#" -ge "1" ]; do # Get command line arguments while there are more lef
117117
key="$1" # Command line args are key-value pairs or value-less keys
118118

119119
case $key in #find known keys
120-
--compiler) #pick the compiler. Defaults to gfortran, but intel or custom compilers can be used
121-
case "$2" in
122-
intel|Intel|INTEL|ifort)
123-
FCOMPILER='Intel'
124-
FCOMPILERFLAGS="$INTELCOMPILERFLAGS"
125-
shift
126-
;;
127-
gnu|Gnu|GNU|gfortran|Gfortran|GFortran|GFORTRAN)
128-
FCOMPILER='gnu'
129-
FCOMPILERFLAGS="$GNUCOMPILERFLAGS"
130-
shift
131-
;;
132-
*)
133-
FCOMPILER="custom"
134-
echo "Warning: Trying to build with unsupported compiler, $2." 1>&2
135-
echo "Please ensure you set appropriate --cflags and (single) quote them" 1>&2
136-
FC="$2"
137-
shift
138-
;;
139-
esac
140-
;;
141-
--cflags)
142-
FCOMPILERFLAGS="$2"
143-
# no good way to check that the user didn't do something questionable
144-
shift
145-
;;
146-
--enable-unicode)
147-
case $2 in
148-
yes|Yes|YES)
149-
TRY_UNICODE="yes"
150-
shift
151-
;;
152-
no|No|NO)
153-
TRY_UNICODE="no"
154-
shift
155-
;;
156-
*)
157-
TRY_UNICODE="yes"
158-
# don't shift; $2 is next arg
159-
;;
160-
esac
161-
;;
162-
--coverage) # enable coverage
163-
case $2 in
164-
yes|Yes|YES)
165-
CODE_COVERAGE="yes"
166-
shift
167-
;;
168-
no|No|NO)
169-
CODE_COVERAGE="no"
170-
shift
171-
;;
172-
*)
173-
CODE_COVERAGE="yes"
174-
# don't shift because $2 is some other flag
175-
;;
176-
esac
177-
;;
178-
--profile) #nable profiling
179-
case $2 in
180-
yes|Yes|YES)
181-
CODE_PROFILE="yes"
182-
shift
183-
;;
184-
no|No|NO)
185-
CODE_PROFILE="no"
186-
shift
187-
;;
188-
*)
189-
CODE_PROFILE="yes"
190-
# don't shift because $2 is some other flag
191-
;;
192-
esac
193-
;;
194-
--skip-tests) # skip tests
195-
case $2 in
196-
yes|Yes|YES)
197-
JF_SKIP_TESTS="yes"
198-
shift
199-
;;
200-
no|No|NO)
201-
JF_SKIP_TESTS="no"
202-
shift
203-
;;
204-
*)
205-
JF_SKIP_TESTS="yes"
206-
;;
207-
esac
208-
;;
209-
--skip-documentation)
210-
case $2 in
211-
yes|Yes|YES)
212-
JF_SKIP_DOCS="yes"
213-
shift
214-
;;
215-
no|No|NO)
216-
JF_SKIP_DOCSS="no"
217-
shift
218-
;;
219-
*)
220-
JF_SKIP_DOCS="yes"
221-
;;
222-
esac
223-
;;
224-
--help)
225-
print_usage
226-
exit 0
227-
;;
228-
--clean)
229-
rm -r src{,/tests}/*.o $DOCDIR* $LIBDIR* $BINDIR* *.gcov*
230-
;;
231-
*)
232-
echo "Unknown flag, \"$1\", passed to ${script_name}!" 2>&1
233-
print_usage
234-
exit 1
235-
;;
120+
--compiler) #pick the compiler. Defaults to gfortran, but intel or custom compilers can be used
121+
case "$2" in
122+
intel|Intel|INTEL|ifort)
123+
FCOMPILER='Intel'
124+
FCOMPILERFLAGS="$INTELCOMPILERFLAGS"
125+
shift
126+
;;
127+
gnu|Gnu|GNU|gfortran|Gfortran|GFortran|GFORTRAN)
128+
FCOMPILER='gnu'
129+
FCOMPILERFLAGS="$GNUCOMPILERFLAGS"
130+
shift
131+
;;
132+
*)
133+
FCOMPILER="custom"
134+
echo "Warning: Trying to build with unsupported compiler, $2." 1>&2
135+
echo "Please ensure you set appropriate --cflags and (single) quote them" 1>&2
136+
FC="$2"
137+
shift
138+
;;
139+
esac
140+
;;
141+
--cflags)
142+
FCOMPILERFLAGS="$2"
143+
# no good way to check that the user didn't do something questionable
144+
shift
145+
;;
146+
--enable-unicode)
147+
case $2 in
148+
yes|Yes|YES)
149+
TRY_UNICODE="yes"
150+
shift
151+
;;
152+
no|No|NO)
153+
TRY_UNICODE="no"
154+
shift
155+
;;
156+
*)
157+
TRY_UNICODE="yes"
158+
# don't shift; $2 is next arg
159+
;;
160+
esac
161+
;;
162+
--coverage) # enable coverage
163+
case $2 in
164+
yes|Yes|YES)
165+
CODE_COVERAGE="yes"
166+
shift
167+
;;
168+
no|No|NO)
169+
CODE_COVERAGE="no"
170+
shift
171+
;;
172+
*)
173+
CODE_COVERAGE="yes"
174+
# don't shift because $2 is some other flag
175+
;;
176+
esac
177+
;;
178+
--profile) #nable profiling
179+
case $2 in
180+
yes|Yes|YES)
181+
CODE_PROFILE="yes"
182+
shift
183+
;;
184+
no|No|NO)
185+
CODE_PROFILE="no"
186+
shift
187+
;;
188+
*)
189+
CODE_PROFILE="yes"
190+
# don't shift because $2 is some other flag
191+
;;
192+
esac
193+
;;
194+
--skip-tests) # skip tests
195+
case $2 in
196+
yes|Yes|YES)
197+
JF_SKIP_TESTS="yes"
198+
shift
199+
;;
200+
no|No|NO)
201+
JF_SKIP_TESTS="no"
202+
shift
203+
;;
204+
*)
205+
JF_SKIP_TESTS="yes"
206+
;;
207+
esac
208+
;;
209+
--skip-documentation)
210+
case $2 in
211+
yes|Yes|YES)
212+
JF_SKIP_DOCS="yes"
213+
shift
214+
;;
215+
no|No|NO)
216+
JF_SKIP_DOCSS="no"
217+
shift
218+
;;
219+
*)
220+
JF_SKIP_DOCS="yes"
221+
;;
222+
esac
223+
;;
224+
--help)
225+
print_usage
226+
exit 0
227+
;;
228+
--clean)
229+
rm -r src{,/tests}/*.o $DOCDIR* $LIBDIR* $BINDIR* *.gcov*
230+
;;
231+
*)
232+
echo "Unknown flag, \"$1\", passed to ${script_name}!" 2>&1
233+
print_usage
234+
exit 1
235+
;;
236236
esac
237237
shift # look at next argument
238238
done # with argument parsing loop
@@ -261,7 +261,7 @@ if [[ $TRY_UNICODE == [yY]* ]]; then
261261
echo "Trying to compile library with Unicode/UCS4 support"
262262
FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags "${FCOMPILERFLAGS}" -dbld "${BINDIR}" -s "${INTROSPECDIR}" -dmod ./ -dobj ./ -t ${UCS4TESTCODE} -o ${UCS4TESTCODE%.f90} -colors
263263
if "${BINDIR}/${UCS4TESTCODE%.f90}"; then
264-
DEFINES="-DUSE_UCS4 -Wunused-function"
264+
DEFINES="-DUSE_UCS4 -Wunused-function"
265265
fi
266266
fi
267267

@@ -280,9 +280,9 @@ if [[ $JF_SKIP_TESTS != [yY]* ]]; then
280280
[ -d "$BINDIR" ] || mkdir "$BINDIR"
281281

282282
for TEST in "${TESTDIR%/}"/jf_test_*.[fF]90; do
283-
THIS_TEST=${TEST##*/}
284-
echo "Build ${THIS_TEST%.[fF]90}"
285-
FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags "${FCOMPILERFLAGS} ${DEFINES}" ${COVERAGE} ${PROFILING} -dbld ${BINDIR} -s ${TESTDIR} -i ${LIBDIR} -libs ${LIBDIR}/${LIBOUT} -dmod ./ -dobj ./ -t ${THIS_TEST} -o ${THIS_TEST%.[fF]90} -colors
283+
THIS_TEST=${TEST##*/}
284+
echo "Build ${THIS_TEST%.[fF]90}"
285+
FoBiS.py build -ch -compiler ${FCOMPILER} ${CUSTOM} -cflags "${FCOMPILERFLAGS} ${DEFINES}" ${COVERAGE} ${PROFILING} -dbld ${BINDIR} -s ${TESTDIR} -i ${LIBDIR} -libs ${LIBDIR}/${LIBOUT} -dmod ./ -dobj ./ -t ${THIS_TEST} -o ${THIS_TEST%.[fF]90} -colors
286286
done
287287
else
288288
echo "Skip building the unit tests since \$JF_SKIP_TESTS has been set to 'true'."
@@ -297,37 +297,42 @@ if [[ $JF_SKIP_TESTS != [yY]* ]] ; then
297297
GLOBIGNORE='*.*'
298298
#
299299
for TEST in jf_test_*; do
300-
# It would be nice to run json output printed to stdout through jsonlint, however,
301-
# some tests output more than one json structure and these need to be split
302-
echo "Running ${TEST}"
303-
./${TEST}
300+
# It would be nice to run json output printed to stdout through jsonlint, however,
301+
# some tests output more than one json structure and these need to be split
302+
echo "Running ${TEST}"
303+
./${TEST}
304304
done
305305
cd -
306306
GLOBIGNORE="$OLD_IGNORES"
307307
if [[ $CODE_COVERAGE = [yY]* ]] ; then
308-
[ -f json_module.F90.gcov ] && rm json_module.F90.gcov
309-
gcov -o $LIBDIR ${SRCDIR}${MODCODE}
310-
if [[ $TRY_UNICODE = [yY]* ]] ; then
311-
# gcov/gfortran bug work around
312-
awk -F':' '{line=""; for(i=2;i<=NF;i++){line=line":"$i}; if (NR > 1) print $1 prevline; prevline=line}; END{print " -"prevline}' json_module.F90.gcov > json_module.F90.gcov.fixed && \
313-
mv json_module.F90.gcov{.fixed,}
314-
# rename so we can merge coverage info
315-
mv json_module.F90.gcov json_module-unicode.F90.gcov
316-
else
317-
# rename so we can merge coverage info
318-
mv json_module.F90.gcov json_module-no-unicode.F90.gcov
319-
fi
320-
if [ -f json_module-unicode.F90.gcov ] && [ -f json_module-no-unicode.F90.gcov ]; then
321-
# merge them
322-
./pages/development-resources/gccr.pl -n -c json_module-no-unicode.F90.gcov no-unicode \
323-
json_module-unicode.F90.gcov unicode > json_module.F90.gcov
324-
else
325-
cp json_module*-unicode.F90.gcov json_module.F90.gcov
326-
fi
327-
FoBiS.py rule -gcov_analyzer .
328-
sed -i"bak" -E 's; \*\*([a-zA-Z]+[a-zA-Z0-9_]*)\*\*; \*\*[[\1]]\*\*;' json_module.F90.gcov.md
329-
sed -i"bak" -E 's;, line ([0-9]+);, line [\1](https://github.com/jacobwilliams/json-fortran/blob/master/src/json_module.F90#L\1);' json_module.F90.gcov.md
330-
gcov -o $BINDIR ${TESTDIR}*.[Ff]90
308+
for SRCFILE in json_string_utilities.F90 json_value_module.F90 json_file_module.F90 ; do
309+
[ -f ${SRCDIR}${SRCFILE}.gcov ] && rm ${SRCDIR}${SRCFILE}.gcov
310+
gcov -o $LIBDIR ${SRCDIR}${SRCFILE}
311+
if [[ $TRY_UNICODE = [yY]* ]] ; then
312+
# gcov/gfortran bug work around
313+
awk -F':' '{line=""; for(i=2;i<=NF;i++){line=line":"$i}; if (NR > 1) print $1 prevline; prevline=line}; END{print " -"prevline}' ${SRCFILE}.gcov > ${SRCFILE}.gcov.fixed && \
314+
mv ${SRCFILE}.gcov{.fixed,}
315+
# rename so we can merge coverage info
316+
mv ${SRCFILE}.gcov ${SRCFILE}-unicode.gcov
317+
else
318+
# rename so we can merge coverage info
319+
mv ${SRCFILE}.gcov ${SRCFILE}-no-unicode.gcov
320+
fi
321+
if [ -f ${SRCFILE}-unicode.gcov ] && [ -f ${SRCFILE}-no-unicode.gcov ]; then
322+
# merge them
323+
./pages/development-resources/gccr.pl -n -c ${SRCFILE}-no-unicode.gcov no-unicode \
324+
${SRCFILE}-unicode.gcov unicode > ${SRCFILE}.gcov
325+
else
326+
cp ${SRCFILE}*-unicode.gcov ${SRCFILE}.gcov
327+
fi
328+
done
329+
330+
FoBiS.py rule -gcov_analyzer .
331+
for SRCFILE in json_string_utilities.F90 json_value_module.F90 json_file_module.F90 ; do
332+
sed -i"bak" -E 's; \*\*([a-zA-Z]+[a-zA-Z0-9_]*)\*\*; \*\*[[\1]]\*\*;' ${SRCFILE}.gcov.md
333+
sed -i"bak" -E "s;, line ([0-9]+);, line [\1](https://github.com/jacobwilliams/json-fortran/blob/master/src/${SRCFILE}#L\1);" ${SRCFILE}.gcov.md
334+
done
335+
gcov -o $BINDIR ${TESTDIR}*.[Ff]90
331336
fi
332337
else
333338
echo "Skip running the unit tests since \$JF_SKIP_TESTS has been set to ${JF_SKIP_TESTS}."
@@ -337,11 +342,11 @@ fi
337342
echo ""
338343
if [[ $JF_SKIP_DOCS != [yY]* ]]; then
339344
if hash ford 2>/dev/null; then
340-
echo "Building documentation..."
341-
[[ $TRY_UNICODE = [yY]* ]] && MACRO_FLAG="-m USE_UCS4"
342-
ford $MACRO_FLAG -p $PAGESDIR $FORDMD
345+
echo "Building documentation..."
346+
[[ $TRY_UNICODE = [yY]* ]] && MACRO_FLAG="-m USE_UCS4"
347+
ford $MACRO_FLAG -p $PAGESDIR $FORDMD
343348
else
344-
echo "FORD not found! Install using: sudo pip install ford"
349+
echo "FORD not found! Install using: sudo pip install ford"
345350
fi
346351
else
347352
echo "Skip building documentation since \$JF_SKIP_DOCS has been set to ${JF_SKIP_DOCS}."

codecov.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
comment:
2+
layout: header, changes, diff, sunburst
3+
coverage:
4+
fixes:
5+
- doc/src::src
6+
ignore:
7+
- src/tests
8+
- doc
9+
status:
10+
patch:
11+
target: 80%
12+
project:
13+
target: 80%

0 commit comments

Comments
 (0)