Skip to content

Commit

Permalink
Port automated nose tests to pytest
Browse files Browse the repository at this point in the history
Nose is pretty much dead.
  • Loading branch information
casch-at committed Dec 30, 2019
1 parent c15ee63 commit 5719ec9
Show file tree
Hide file tree
Showing 9 changed files with 1,118 additions and 235 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
include: include:
- os: linux - os: linux
compiler: g++ compiler: g++
dist: trusty
env: T=g++-linux COMPILER_VERSION=-7 CMAKE_BUILD_TYPE=Debug env: T=g++-linux COMPILER_VERSION=-7 CMAKE_BUILD_TYPE=Debug
script: ./scripts/travis.sh script: ./scripts/travis.sh
addons: addons:
Expand All @@ -27,7 +26,6 @@ jobs:
- libcppunit-dev - libcppunit-dev
- os: linux - os: linux
compiler: g++ compiler: g++
dist: trusty
env: T=g++-linux COMPILER_VERSION=-7 CMAKE_BUILD_TYPE=Release env: T=g++-linux COMPILER_VERSION=-7 CMAKE_BUILD_TYPE=Release
script: ./scripts/travis.sh script: ./scripts/travis.sh
addons: addons:
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ else ()
message(WARNING "Perl not found! Excluding sbroot test from tests.") message(WARNING "Perl not found! Excluding sbroot test from tests.")
endif() endif()


find_program(NOSETEST NAMES nosetests PATHS "$ENV{HOME}/.local/bin") find_program(PYTEST NAMES pytest py.test)
if (NOSETEST) if (PYTEST)
add_test(NAME nosetests COMMAND ${NOSETEST} -w ${CMAKE_SOURCE_DIR}/tests/automated --no-byte-compile -v) add_test(NAME automated_tests COMMAND ${PYTEST} -svvv ${CMAKE_SOURCE_DIR}/tests/automated WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/automated)
set_property(TEST nosetests PROPERTY ENVIRONMENT "RTAGS_BINARY_DIR=${CMAKE_BINARY_DIR}/bin") set_property(TEST automated_tests PROPERTY ENVIRONMENT "RTAGS_BINARY_DIR=${CMAKE_BINARY_DIR}/bin")
else() else()
message(WARNING "Nosetests executable not found! Excluding automated_tests from tests.") message(WARNING "pytest executable not found! Excluding automated_tests from tests.")
endif () endif ()


if (EMACS_EXECUTABLE AND NOT RTAGS_NO_ELISP_FILES) if (EMACS_EXECUTABLE AND NOT RTAGS_NO_ELISP_FILES)
Expand Down
24 changes: 9 additions & 15 deletions scripts/travis.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ fi
export CCACHE_DEBUG=1 export CCACHE_DEBUG=1
function build_and_test() function build_and_test()
{ {
rm -rf build cmake_args=$1; shift
mkdir build && pushd build > /dev/null mkdir build
emacs --version cd build
cmake "$1" "${CMAKE_PARAMS[@]}" .. || cat CMakeFiles/CMakeError.log cmake "$cmake_args" "${CMAKE_PARAMS[@]}" .. || cat CMakeFiles/CMakeError.log
make VERBOSE=1 -j2 make VERBOSE=1 -j2
shift PATH=$PATH:$(pwd)/bin
PATH=$(pwd)/bin:$PATH ctest --output-on-failure --verbose "$@" ctest --output-on-failure --verbose "$@"
popd >/dev/null
} }


function add_cmake_params() function add_cmake_params()
Expand All @@ -52,12 +51,7 @@ function add_cmake_params()


function osx() function osx()
{ {
## Step -- Setup
pip3 install --user --upgrade nose PyHamcrest

## Step -- Build
mkdir -p ~/.local/bin mkdir -p ~/.local/bin
ln -s /usr/local/Cellar/numpy/*/libexec/nose/bin/nosetests-3.6 ~/.local/bin/nosetests
export LIBCLANG_LLVM_CONFIG_EXECUTABLE=$(find /usr/local/Cellar/llvm/*/bin -name llvm-config 2>/dev/null) export LIBCLANG_LLVM_CONFIG_EXECUTABLE=$(find /usr/local/Cellar/llvm/*/bin -name llvm-config 2>/dev/null)
# Help cmake to find openssl includes/library # Help cmake to find openssl includes/library
add_cmake_params "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" add_cmake_params "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
Expand All @@ -68,13 +62,13 @@ function osx()


function gnu_linux() function gnu_linux()
{ {
## Step -- Setup
pip3 install --user --upgrade nose PyHamcrest

build_and_test -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} build_and_test -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
} }


pip3 install --user --upgrade pytest

if [ $TRAVIS_OS_NAME = osx ]; then if [ $TRAVIS_OS_NAME = osx ]; then
export PATH=$PATH:$(python3 -c 'import site; print(site.USER_BASE)')/bin
osx osx
else else
gnu_linux gnu_linux
Expand Down
13 changes: 13 additions & 0 deletions tests/automated/README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,17 @@
# Adding a new test
To add a new test in this folder, just add a new folder with a To add a new test in this folder, just add a new folder with a
descriptive name with some sources and an `expectation.json` file with descriptive name with some sources and an `expectation.json` file with
some commands to run through `rc` and the expected resulting some commands to run through `rc` and the expected resulting
locations. locations.

The directory must start with a specific word to classify the test, those are:

* Location
* Parsing
* Completion
* Output

If it doesn't start with one of those it is considered to be a _Location_ test.

Those types of tests are handled with the test file _test\_misc.py_. For
bigger tests consider using a separate test file.
Empty file added tests/automated/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions tests/automated/requirements-dev.txt
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
yapf
pylint
pylint-mccabe
pycodestyle
pytest
Loading

0 comments on commit 5719ec9

Please sign in to comment.