Move creation of srcdirref and testfiles dir to BasicConfig
Those make testing more convenient and are also useful when there's no test target, eg. when testing syncthingtray with mocked configuration.
This commit is contained in:
parent
94e76f5a1a
commit
52bf075317
|
@ -208,6 +208,12 @@ if(HAS_PARENT)
|
||||||
message(STATUS "For the check target to work, it is required to call enable_testing() on the source directory root.")
|
message(STATUS "For the check target to work, it is required to call enable_testing() on the source directory root.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# make testing more convenient (not only useful if there's a test target; this is for instance also used in mocked configuration of syncthingtray)
|
||||||
|
# -> add a file called "srcdirref" to the build directory; this file contains the path of the sources so tests can easily find test files contained in the source directory
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/srcdirref" "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
# -> ensure the directory "testfiles" exists in the build directory; tests will create the directory for working copies of testfiles there by default
|
||||||
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/testfiles")
|
||||||
|
|
||||||
# add target for tidying with clang-format
|
# add target for tidying with clang-format
|
||||||
if(NOT META_NO_TIDY AND EXISTS "${CLANG_FORMAT_RULES}")
|
if(NOT META_NO_TIDY AND EXISTS "${CLANG_FORMAT_RULES}")
|
||||||
option(CLANG_FORMAT_ENABLED "enables creation of tidy target using clang-format" OFF)
|
option(CLANG_FORMAT_ENABLED "enables creation of tidy target using clang-format" OFF)
|
||||||
|
|
|
@ -352,12 +352,6 @@ if(CPP_UNIT_LIB OR META_NO_CPP_UNIT)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# add a file called "srcdirref" to the build directory; this file contains the path of the sources so tests can easily find test files contained in the source directory
|
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/srcdirref" "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
|
|
||||||
# ensure the directory "testfiles" exists in the build directory; tests will create the directory for working copies of testfiles there by default
|
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/testfiles")
|
|
||||||
|
|
||||||
set(META_HAVE_TESTS YES)
|
set(META_HAVE_TESTS YES)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -478,7 +478,8 @@ string TestApplication::readTestfilePathFromSrcRef()
|
||||||
|
|
||||||
return srcDirContent += "/testfiles/";
|
return srcDirContent += "/testfiles/";
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// the "srcdirref" file likely just does not exist, so ignore the error case for now
|
cerr << Phrases::Warning << "The file \"srcdirref\" can not be opened. It likely just doesn't exist in the working directory."
|
||||||
|
<< Phrases::EndFlush;
|
||||||
catchIoFailure();
|
catchIoFailure();
|
||||||
}
|
}
|
||||||
return string();
|
return string();
|
||||||
|
|
Loading…
Reference in New Issue