Skip to content
Snippets Groups Projects
Commit b2f63059 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

refactor tests

parent 31369bc9
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ function(gtest target test_source_files test_libraries)
if (CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
set (COVERAGE_EXCLUDES '*/unittests/*')
set(COVERAGE_EXCLUDES '*/unittests/*')
SETUP_TARGET_FOR_COVERAGE(NAME coverage-${target} EXECUTABLE test-${target} ${target})
add_test(NAME coveragetest-${target}
COMMAND ${CMAKE_MODULE_PATH}/check_test.sh
......@@ -32,3 +32,26 @@ function(gtest target test_source_files test_libraries)
endif ()
endif ()
endfunction()
function(add_test_setup_cleanup exename)
if (BUILD_TESTS)
add_test(NAME test-${exename}-setup COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/setup.sh)
add_test(NAME test-${exename}-cleanup COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cleanup.sh)
set_tests_properties(test-${exename}-setup PROPERTIES FIXTURES_SETUP test-${exename}-fixture)
set_tests_properties(test-${exename}-cleanup PROPERTIES FIXTURES_CLEANUP test-${exename}-fixture)
endif ()
endfunction()
function(add_integration_test exename testname commandargs)
if (BUILD_TESTS)
set( args ${commandargs} )
separate_arguments(args)
add_test(NAME test-${exename}-${testname} COMMAND ${exename} ${args})
set_tests_properties(test-${exename}-${testname} PROPERTIES
LABELS "integration;all"
FIXTURES_REQUIRED test-${exename}-fixture
)
endif ()
endfunction()
......@@ -83,17 +83,13 @@ void CollectFileInformationRecursivly(const std::string& path,
if (IsDirectory(current_entity)) {
CollectFileInformationRecursivly(path + "/" + current_entity->d_name,
files, err);
if (*err != IOErrors::NO_ERROR) {
closedir(dir);
return;
}
} else {
ProcessFileEntity(current_entity, path, files, err);
}
ProcessFileEntity(current_entity, path, files, err);
if (*err != IOErrors::NO_ERROR) {
closedir(dir);
return;
}
}
*err = IOErrorFromErrno();
closedir(dir);
......
......@@ -13,33 +13,8 @@ set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE CXX)
# Testing
################################
add_test(NAME test-${TARGET_NAME}-create_list COMMAND ${TARGET_NAME} test 23subtest/subtest241)
add_test(NAME test-${TARGET_NAME}-foldernotfound COMMAND ${TARGET_NAME} test_notexist notfound)
add_test(NAME test-${TARGET_NAME}-foldernoaccess COMMAND ${TARGET_NAME} test_noaccess noaccess)
set_tests_properties(test-${TARGET_NAME}-create_list PROPERTIES
LABELS "integration;all"
FIXTURES_REQUIRED ${TARGET_NAME}-fixture
)
set_tests_properties(test-${TARGET_NAME}-foldernotfound PROPERTIES
LABELS "integration;all"
# FIXTURES_REQUIRED ${TARGET_NAME}-fixture
)
set_tests_properties(test-${TARGET_NAME}-foldernoaccess PROPERTIES
LABELS "integration;all"
FIXTURES_REQUIRED ${TARGET_NAME}-fixture
)
add_test(NAME test-${TARGET_NAME}-setup COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/setup.sh)
add_test(NAME test-${TARGET_NAME}-cleanup COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cleanup.sh)
set_tests_properties(test-${TARGET_NAME}-setup PROPERTIES FIXTURES_SETUP ${TARGET_NAME}-fixture)
set_tests_properties(test-${TARGET_NAME}-cleanup PROPERTIES FIXTURES_CLEANUP ${TARGET_NAME}-fixture)
add_test_setup_cleanup(${TARGET_NAME})
add_integration_test(${TARGET_NAME} create_list "test 23subtest/subtest241")
add_integration_test(${TARGET_NAME} foldernotfound "test_notexist notfound")
add_integration_test(${TARGET_NAME} foldernoaccess "test_noaccess noaccess")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment