Skip to content

Commit 280dfa5

Browse files
dilawarDilawar Singh
andauthored
Adds Test Coverage (#394)
* Don't run streamer multitab tests on OSX/Travis. * Disable all socket streamer tests. * no way to setup proxy yet. * Temp commit. * Some more changes but not complete. * local tests. * build was successful. * Added pytest compatible tests. Generates test report at the end. * Fixed hhfit tests. * test commit [seg fault] skip ci * Removed benchamark code. * Added dependencies to requirements.txt file. Set verbosity to 0. Minor cleanup. local tests are passing... Added test: rdesineur loads chan proto from a given file. * Fixed hhfit test. Added scipy to run hhfit test. * Fixed one more test. * test it on xcode10.3 * Some fixes to test_hhfit. The module selects a best function 'fuzzingly'. * - Removed getopt in pymoose code. It was causing segfault on OSX. Not sure why. `getopt` is no longer needed there. - Use scipy in tests as well. hhfit requires scipy. - Added target coverage for make. - Enabled coverage on travis. - Fixes to unicode/str issues b/w python2 and 3. * - Fixes to issue #393 - Don't let user use buggy gcc 4.8.x which does not proper regex support. See https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions * updated docker file for centos:7 . Install devtoolset-8. * Some more tweak to test_hhfit.py file. THe hhfit function does not always return the demanded function but could also return a function which is a better fit (it is designed this way). Without this fix, the test could fail on a separte run or on a separte platform. * Update writeKkit.py Fixed email id. Co-authored-by: Dilawar Singh <dilawars@ncbs.res.in>
1 parent 4de9cc7 commit 280dfa5

File tree

148 files changed

+1186
-3697
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+1186
-3697
lines changed

.ci/coverage.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
python3 -m trace --count \
3+
--ignore-dir=/usr/lib64 \
4+
--ignore-module=libsbml \
5+
--ignore-module=numpy \
6+
--ignore-module=neuroml \
7+
"$@"
8+

.ci/travis_build_linux.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ PYTHON2="/usr/bin/python2"
1616
PYTHON3="/usr/bin/python3"
1717

1818
$PYTHON2 -m pip install pip --upgrade --user
19-
$PYTHON2 -m pip install libNeuroML pyNeuroML python-libsbml --upgrade --user
19+
$PYTHON2 -m pip install libNeuroML numpy==1.14 scipy==1.2 \
20+
pyNeuroML python-libsbml --upgrade --user
2021

2122
$PYTHON3 -m pip install pip --upgrade --user
2223
$PYTHON3 -m pip install libNeuroML pyNeuroML python-libsbml --upgrade --user
2324

2425
# sympy is only needed for pretty-priting for one test.
25-
$PYTHON3 -m pip install sympy --upgrade --user
26+
$PYTHON3 -m pip install numpy sympy scipy --upgrade --user
2627

28+
# pytest requirements.
29+
$PYTHON3 -m pip install -r ./tests/requirements.txt --user
30+
2731
NPROC=$(nproc)
2832
MAKE="make -j$NPROC"
2933

@@ -47,11 +51,23 @@ $PYTHON3 -m compileall -q .
4751

4852
# Run all tests in debug mode.
4953
MOOSE_NUM_THREADS=$NPROC ctest -j$NPROC --output-on-failure
54+
55+
5056
make install || sudo make install
5157
cd /tmp
5258
$PYTHON3 -c 'import moose;print(moose.__file__);print(moose.version())'
5359
)
5460

61+
# BOOST and python3
62+
(
63+
mkdir -p $BUILDDIR && cd $BUILDDIR && \
64+
cmake -DWITH_BOOST_ODE=ON -DPYTHON_EXECUTABLE="$PYTHON3" \
65+
-DCMAKE_INSTALL_PREFIX=/usr ..
66+
# Run coverage
67+
export MOOSE_NUM_THREADS=3
68+
make coverage
69+
)
70+
5571
# GSL and python2, failure is allowed
5672
set +e
5773
(
@@ -61,13 +77,4 @@ set +e
6177
)
6278
set -e
6379

64-
65-
# BOOST and python3
66-
(
67-
mkdir -p $BUILDDIR && cd $BUILDDIR && \
68-
cmake -DWITH_BOOST_ODE=ON -DPYTHON_EXECUTABLE="$PYTHON3" \
69-
-DCMAKE_INSTALL_PREFIX=/usr ..
70-
$MAKE && MOOSE_NUM_THREADS=$NPROC ctest -j$NPROC --output-on-failure
71-
)
72-
7380
echo "All done"

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ build:
1414
- apt -y install python-numpy python-matplotlib python-pip python-dev
1515
script:
1616
- python3 -m pip install setuptools pip --user --upgrade
17+
- python3 -m pip install python-libsbml --user --upgrade
1718
- python3 -m pip install pyneuroml --user --upgrade
19+
- python3 -m pip install sympy scipy --user --upgrade
1820
- python3 setup.py build test
1921
- python3 setup.py install --user
2022
- python3 -c "import moose; moose.test()"

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ matrix:
88
services:
99
- xvfb
1010
- os: osx
11-
osx_image: xcode11.3
11+
osx_image:
12+
- xcode11.3
1213

1314
notifications:
1415
email:

CMakeLists.txt

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,18 @@ add_subdirectory(ksolve)
228228
add_subdirectory(hsolve)
229229
add_subdirectory(diffusion)
230230
add_subdirectory(device)
231-
add_subdirectory(benchmarks)
232231
add_subdirectory(kinetics)
233232
add_subdirectory(synapse)
234233
add_subdirectory(intfire)
235234
add_subdirectory(external/libsoda)
236235

236+
# development related.
237+
add_subdirectory(devel)
238+
237239
###################################### LINKING #################################
238240
list(APPEND MOOSE_LIBRARIES
239241
moose_builtins
240242
msg
241-
benchmarks
242243
shell
243244
randnum
244245
scheduling
@@ -364,21 +365,33 @@ if(DEBUG OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
364365
add_test(NAME moose.bin-raw-run COMMAND moose.bin -u -q)
365366
endif()
366367

367-
# PyMOOSE tests. These tests complete in reasonable time and should run by
368-
# default.
368+
# Core tests.
369369
set(PYMOOSE_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/py_moose)
370370
file(GLOB PY_TEST_SCRIPTS "${PYMOOSE_TEST_DIRECTORY}/test_*.py" )
371371
foreach(_test_script ${PY_TEST_SCRIPTS} )
372372
get_filename_component(_name_we ${_test_script} NAME_WE)
373-
set(_test_name "pymoose_${_name_we}")
373+
set(_test_name "core_${_name_we}")
374374
add_test(NAME ${_test_name}
375375
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
376-
WORKING_DIRECTORY ${PYMOOSE_TEST_DIRECTORY}
376+
WORKING_DIRECTORY ${PYMOOSE_TEST_DIRECTORY})
377+
set_tests_properties(${_test_name}
378+
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
377379
)
380+
endforeach()
381+
382+
# Tests for supported formats such as neuroml, sbml etc.
383+
set(SUPPORT_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/support)
384+
file(GLOB PY_TEST_SCRIPTS "${SUPPORT_TEST_DIRECTORY}/test_*.py" )
385+
foreach(_test_script ${PY_TEST_SCRIPTS} )
386+
get_filename_component(_name_we ${_test_script} NAME_WE)
387+
set(_test_name "support_${_name_we}")
388+
add_test(NAME ${_test_name}
389+
COMMAND ${PYTHON_EXECUTABLE} ${_test_script}
390+
WORKING_DIRECTORY ${SUPPORT_TEST_DIRECTORY})
378391
set_tests_properties(${_test_name}
379392
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
380393
)
381-
endforeach( )
394+
endforeach()
382395

383396
# rdesigneur tests. These tests require matplotlib.
384397
set(RDES_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/py_rdesigneur)
@@ -396,7 +409,7 @@ foreach(_test_script ${RDES_TEST_SCRIPTS})
396409
endforeach()
397410

398411
# FIXME TESTS. These should not run by default. We need to fix them.
399-
set(PYMOOSE_FIXME_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/fixme)
412+
set(PYMOOSE_FIXME_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/devel/fixme)
400413
file(GLOB PY_FIXME_TEST_SCRIPTS "${PYMOOSE_FIXME_TEST_DIRECTORY}/*.py" )
401414
foreach( _test_script ${PY_FIXME_TEST_SCRIPTS} )
402415
get_filename_component( _name_we ${_test_script} NAME_WE)
@@ -426,9 +439,36 @@ foreach(_test_script ${PY_ISSUES_SCRIPTS})
426439
)
427440
endforeach()
428441

429-
############################ CPACK ######################################
430-
# This is not maintained anymore since packaging is done using OpenBuildService
431-
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake_moose_cpack.cmake)
442+
################################# COVERAGE ###################################
443+
444+
add_custom_target(coverage)
445+
set(PYTEST_TEST_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
446+
file(GLOB_RECURSE PYTEST_TEST_SCRIPTS ${PYTEST_TEST_DIRECTORY}/test_*.py)
447+
448+
foreach(_test_script ${PYTEST_TEST_SCRIPTS})
449+
get_filename_component(_name_we ${_test_script} NAME_WE)
450+
set(_test_name "pytest_${_name_we}")
451+
# message(STATUS "Adding test ${_test_name}")
452+
add_custom_target(${_test_name}
453+
# We collect coverage data but do not show report during each test.
454+
# We show report at the end of all tests. Set `--cov-report=`
455+
COMMAND ${PYTHON_EXECUTABLE} -m pytest
456+
--cov=moose --cov=rdesigneur --cov-append --cov-report=
457+
${_test_script}
458+
DEPENDS _moose
459+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
460+
COMMENT "Executing ${_test_script} using pytest"
461+
VERBATIM)
462+
add_dependencies(coverage ${_test_name})
463+
endforeach()
464+
465+
# Generate report at the end.
466+
add_custom_command(TARGET coverage POST_BUILD
467+
COMMAND ${PYTHON_EXECUTABLE} -m coverage report
468+
COMMAND ${PYTHON_EXECUTABLE} -m coverage html
469+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
470+
COMMENT "Genearting coverage report"
471+
VERBATIM)
432472

433473

434474
########################### RELEASE #########################################
@@ -479,10 +519,3 @@ foreach(_py_script ${PY_SCRIPTS})
479519
add_dependencies(pylint ${TGT_NAME} )
480520
endforeach( )
481521

482-
# Replicate Travis-CI building using docker
483-
add_custom_target(docker
484-
COMMAND docker build -t bhallalab/travis:latest
485-
-f ${CMAKE_CURRENT_SOURCE_DIR}/devel/docker/travis/Dockerfile .
486-
COMMENT "Replicating Travis-CI building using Docker."
487-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
488-
VERBATIM)

CheckCXXCompiler.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ add_definitions(-Wall
1818
-Wno-unused-function
1919
#-Wno-unused-private-field
2020
)
21+
2122
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
23+
# gcc-4.9.0 has regex supports though moose will compile with 4.8.x;
24+
# <regex> won't work.
25+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
26+
message(FATAL_ERROR "Insufficient gcc version. Minimum requried 4.9")
27+
endif()
2228
add_definitions( -Wno-unused-local-typedefs )
2329
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
2430
add_definitions( -Wno-unused-local-typedef )
2531
endif()
2632

27-
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
28-
add_definitions( -Wno-unused-local-typedefs )
29-
endif()
30-
3133
add_definitions(-fPIC)
3234
if(COMPILER_WARNS_STRICT_ALIASING)
3335
add_definitions( -Wno-strict-aliasing )

0 commit comments

Comments
 (0)