Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake: Add targets for invoking tests
- Loading branch information
Showing
8 changed files
with
166 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
cmake_minimum_required(VERSION 3.3.0) | ||
|
||
enable_testing() | ||
|
||
# add test for install target | ||
add_test( | ||
NAME test-installed-files | ||
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/check-installed-files" "${CMAKE_MAKE_PROGRAM}" | ||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" | ||
) | ||
|
||
# add test for YAML syntax | ||
find_program(YAMLLINT_PATH yamllint) | ||
if (YAMLLINT_PATH) | ||
add_test( | ||
NAME test-local-yaml-syntax | ||
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/check-yaml-syntax" "${YAMLLINT_PATH}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
else () | ||
message(STATUS "Set YAMLLINT_PATH to the path of the yamllint executable to enable YAML syntax checks.") | ||
endif () | ||
|
||
# add tidy check | ||
add_test( | ||
NAME test-local-tidy | ||
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/tidy" --check | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
|
||
# add test for Perl syntax/style issues | ||
find_program(PERLCRITIC_PATH perlcritic) | ||
if (PERLCRITIC_PATH) | ||
add_test( | ||
NAME test-local-perl-style | ||
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/check-perl-style" "${PERLCRITIC_PATH}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
else () | ||
message(STATUS "Set PERLCRITIC_PATH to the path of the perlcritic executable to enable Perl syntax/style checks.") | ||
endif () | ||
|
||
# add spell checking for test API documentation | ||
find_program(PODSPELL_PATH podspell) | ||
find_program(SPELL_PATH spell) | ||
if (PODSPELL_PATH AND SPELL_PATH) | ||
add_test( | ||
NAME test-doc-testapi-spellchecking | ||
COMMAND sh -c "\"${PODSPELL_PATH}\" \"${CMAKE_CURRENT_SOURCE_DIR}/testapi.pm\" | \"${SPELL_PATH}\"" | ||
) | ||
else () | ||
message(STATUS "Set PODSPELL_PATH/SPELL_PATH to the path of the podspell/spell executable to enable spell checking.") | ||
endif () | ||
|
||
# add targets for invoking Perl test suite | ||
find_program(PROVE_PATH prove) | ||
if (PROVE_PATH) | ||
add_test( | ||
NAME test-perl-testsuite | ||
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/invoke-tests" "${PROVE_PATH}" "${CMAKE_MAKE_PROGRAM}" "${CMAKE_CURRENT_BINARY_DIR}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
else () | ||
message(STATUS "Set PROVE_PATH to the path of the prove executable to enable running the Perl testsuite.") | ||
endif () | ||
|
||
# add build system targets for invoking specific tests | ||
add_custom_target(test-local COMMAND ${CMAKE_CTEST_COMMAND} -R "test-local-.*" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") | ||
add_custom_target(test-doc COMMAND ${CMAKE_CTEST_COMMAND} -R "test-doc-.*" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") | ||
add_custom_target(test-installed-files COMMAND ${CMAKE_CTEST_COMMAND} -R "test-installed-files" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
add_custom_target(test-perl-testsuite COMMAND ${CMAKE_CTEST_COMMAND} -R "test-perl-testsuite" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) | ||
add_dependencies(test-perl-testsuite symlinks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh -e | ||
export PERL5LIB=tools/lib/perlcritic:$PERL5LIB | ||
"${1:-perlcritic}" --gentle --include Perl::Critic::Policy::HashKeyQuote "${2:-$PWD}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh -e | ||
# fall back to find if there is no git, e.g. in package builds | ||
"${1:-yamllint}" --strict $(git ls-files "*.yml" "*.yaml" 2>/dev/null || find -name '*.y*ml') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash -e | ||
|
||
# process arguments | ||
if [[ $1 == --coverage ]]; then | ||
WITH_COVER_OPTIONS=1 | ||
shift | ||
fi | ||
if [[ $# -lt 3 ]]; then | ||
echo "usage: $0 [--coverage] prove-tool-path make-tool-path build-directory [test-file...]" | ||
exit | ||
fi | ||
prove_path=$1 make_path=$2 build_dir=$3 | ||
shift 3 | ||
test_files=("$@") | ||
|
||
# set Perl module include path and coverage options | ||
export PERL5LIB="$PWD:$PWD/ppmclibs:$PWD/ppmclibs/blib/arch/auto/tinycv:$PERL5LIB" | ||
if [[ $WITH_COVER_OPTIONS ]]; then | ||
path_regex='^|$(PWD)/|\.\./' | ||
export PERL5OPT="-MDevel::Cover=-db,$build_dir/cover_db,-select,($path_regex)(OpenQA|backend|consoles|ppmclibs)/|($path_regex)isotovideo|($path_regex)[^/]+\.pm,-ignore,\.t|data/tests/|fake/tests/|$prove_path,-coverage,statement" | ||
fi | ||
|
||
# set variables for tests which need to invoke the make tool | ||
export OS_AUTOINST_BUILD_DIRECTORY=$build_dir | ||
export OS_AUTOINST_MAKE_TOOL=$make_path | ||
|
||
# define list of tests to run by default; allow specifying the list of tests via TESTS in consistency with openQA | ||
[[ ${#test_files[@]} -lt 1 ]] && test_files=($TESTS) | ||
[[ ${#test_files[@]} -lt 1 ]] && test_files=( | ||
00-compile-check-all.t | ||
01-test_needle.t | ||
02-test_ocr.t | ||
03-testapi.t | ||
04-check_vars_docu.t | ||
05-pod.t | ||
06-pod-coverage.t | ||
07-commands.t | ||
08-autotest.t | ||
09-lockapi.t | ||
10-terminal.t | ||
10-virtio_terminal.t | ||
10-test-image-conversion-benchmark.t | ||
11-image-ppm.t | ||
12-bmwqemu.t | ||
13-osutils.t | ||
14-isotovideo.t | ||
15-logging.t | ||
16-send_with_fd.t | ||
17-basetest.t | ||
18-qemu.t | ||
18-backend-qemu.t | ||
18-qemu-options.t | ||
19-isotovideo-command-processing.t | ||
20-openqa-benchmark-stopwatch-utils.t | ||
21-needle-downloader.t | ||
22-svirt.t | ||
23-baseclass.t | ||
24-myjsonrpc.t | ||
24-myjsonrpc-debug.t | ||
25-spvm.t | ||
26-serial_screen.t | ||
26-ssh_screen.t | ||
27-make-update-deps.t | ||
99-full-stack.t | ||
) | ||
|
||
# invoke tests within the t directory | ||
cd t && "$prove_path" $PROVE_ARGS "${test_files[@]}" |