Skip to content
Permalink
Browse files

Port automated nose tests to pytest

Nose is pretty much dead.
  • Loading branch information
cslux committed Dec 30, 2019
1 parent c15ee63 commit 5719ec94c4a10351619094e87cf31f9640e2c001
@@ -14,7 +14,6 @@ jobs:
include:
- os: linux
compiler: g++
dist: trusty
env: T=g++-linux COMPILER_VERSION=-7 CMAKE_BUILD_TYPE=Debug
script: ./scripts/travis.sh
addons:
@@ -27,7 +26,6 @@ jobs:
- libcppunit-dev
- os: linux
compiler: g++
dist: trusty
env: T=g++-linux COMPILER_VERSION=-7 CMAKE_BUILD_TYPE=Release
script: ./scripts/travis.sh
addons:
@@ -103,12 +103,12 @@ else ()
message(WARNING "Perl not found! Excluding sbroot test from tests.")
endif()

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

if (EMACS_EXECUTABLE AND NOT RTAGS_NO_ELISP_FILES)
@@ -33,14 +33,13 @@ fi
export CCACHE_DEBUG=1
function build_and_test()
{
rm -rf build
mkdir build && pushd build > /dev/null
emacs --version
cmake "$1" "${CMAKE_PARAMS[@]}" .. || cat CMakeFiles/CMakeError.log
cmake_args=$1; shift
mkdir build
cd build
cmake "$cmake_args" "${CMAKE_PARAMS[@]}" .. || cat CMakeFiles/CMakeError.log
make VERBOSE=1 -j2
shift
PATH=$(pwd)/bin:$PATH ctest --output-on-failure --verbose "$@"
popd >/dev/null
PATH=$PATH:$(pwd)/bin
ctest --output-on-failure --verbose "$@"
}

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

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

## Step -- Build
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)
# Help cmake to find openssl includes/library
add_cmake_params "-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
@@ -68,13 +62,13 @@ function osx()

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

build_and_test -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
}

pip3 install --user --upgrade pytest

if [ $TRAVIS_OS_NAME = osx ]; then
export PATH=$PATH:$(python3 -c 'import site; print(site.USER_BASE)')/bin
osx
else
gnu_linux
@@ -1,4 +1,17 @@
# Adding a new test
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
some commands to run through `rc` and the expected resulting
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.
No changes.
@@ -0,0 +1,5 @@
yapf
pylint
pylint-mccabe
pycodestyle
pytest

0 comments on commit 5719ec9

Please sign in to comment.
You can’t perform that action at this time.