Update tests, and add documentation!
This PR does the following:
* fix tests -- now, they're always built in the CMake scripts, and they work on VS2015
*add a new flag, BUILD_TESTING, which allows one to turn off testing builds
* Add documentation for running tests
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -2,11 +2,16 @@ cmake_minimum_required(VERSION 3.3)
project(vcpkg C CXX)
-enable_testing()
-
+OPTION(BUILD_TESTING "Option for enabling testing" ON)
OPTION(DEFINE_DISABLE_METRICS "Option for disabling metrics" OFF)
OPTION(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang" OFF)
+if (DEFINE_DISABLE_METRICS)
+ set(DISABLE_METRICS_VALUE "1")
+else()
+ set(DISABLE_METRICS_VALUE "0")
+endif()
+
if(CMAKE_COMPILER_IS_GNUXX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(GCC 1)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
@@ -27,46 +32,12 @@ else()
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
-if(GCC OR CLANG)
- add_compile_options(-std=c++1z)
- if(WERROR)
- add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
- endif()
-endif()
-
-file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
-file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-test/*.cpp)
-
-if (DEFINE_DISABLE_METRICS)
- set(DISABLE_METRICS_VALUE "1")
-else()
- set(DISABLE_METRICS_VALUE "0")
-endif()
-
-add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
-add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
-add_executable(vcpkg-test
- EXCLUDE_FROM_ALL
- ${VCPKGTEST_SOURCES}
- $<TARGET_OBJECTS:vcpkglib>)
-
-foreach(TARGET_NAME vcpkglib vcpkg vcpkg-test)
- target_compile_definitions(${TARGET_NAME} PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
- target_include_directories(${TARGET_NAME} PRIVATE include)
-endforeach()
-
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
-target_link_libraries(vcpkg PRIVATE Threads::Threads)
-target_link_libraries(vcpkg-test PRIVATE Threads::Threads)
-foreach(TEST_NAME
- arguments chrono dependencies files
- paragraph plan specifier statusparagraphs
- strings supports update
-)
- add_test(${TEST_NAME} vcpkg-test [${TEST_NAME}])
-endforeach()
+add_definitions(-DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
+include_directories(include)
+link_libraries(Threads::Threads)
if(CLANG)
include(CheckCXXSourceCompiles)
@@ -80,11 +51,32 @@ if(CLANG)
endif()
if(GCC OR (CLANG AND USES_LIBSTDCXX))
- target_link_libraries(vcpkg PRIVATE stdc++fs)
- target_link_libraries(vcpkg-test PRIVATE stdc++fs)
+ link_libraries(stdc++fs)
elseif(CLANG)
- target_link_libraries(vcpkg PRIVATE c++fs)
- target_link_libraries(vcpkg-test PRIVATE c++fs)
+ link_libraries(c++fs)
+endif()
+
+if(GCC OR CLANG)
+ add_compile_options(-std=c++1z)
+ if(WERROR)
+ add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
+ endif()
+endif()
+
+file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
+
+add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
+add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
+
+if (BUILD_TESTING)
+ file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-test/*.cpp)
+
+ enable_testing()
+ add_executable(vcpkg-test
+ ${VCPKGTEST_SOURCES}
+ $<TARGET_OBJECTS:vcpkglib>)
+
+ add_test(NAME default COMMAND vcpkg-test [${TEST_NAME}])
endif()
if(MSVC)

MODIFY
src/vcpkg-test/util.cpp
src/vcpkg-test/util.cpp
@@ -76,12 +76,13 @@ namespace vcpkg::Test
static bool system_allows_symlinks()
{
-#if defined(_WIN32)
- if (!__cpp_lib_filesystem)
- {
+#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE
return false;
- }
-
+#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
+ return true;
+#elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
+ return true;
+#else
HKEY key;
bool allow_symlinks = true;
@@ -97,8 +98,6 @@ namespace vcpkg::Test
if (status == ERROR_SUCCESS) RegCloseKey(key);
return allow_symlinks;
-#else
- return true;
#endif
}
@@ -125,8 +124,8 @@ namespace vcpkg::Test
const bool SYMLINKS_ALLOWED = system_allows_symlinks();
const fs::path TEMPORARY_DIRECTORY = internal_temporary_directory();
-#if FILESYSTEM_SYMLINK == FILSYSTEM_SYMLINK_NONE
- constexpr inline char no_filesystem_message[] =
+#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE
+ constexpr char no_filesystem_message[] =
"<filesystem> doesn't exist; on windows, we don't attempt to use the win32 calls to create symlinks";
#endif

Update tests, and add documentation! (#7506)

This PR does the following:

* fix tests -- now, they're always built in the CMake scripts, and they work on VS2015
  *add a new flag, BUILD_TESTING, which allows one to turn off testing builds
* Add documentation for running tests