aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/files.cpp
diff options
context:
space:
mode:
authorBilly O'Neal <bion@microsoft.com>2020-09-22 20:16:24 -0700
committerGitHub <noreply@github.com>2020-09-22 20:16:24 -0700
commit5d33bd3d7910c6090911f71f9dcf1a4eecd303da (patch)
treecbd4b6e0562f4f0a18b2489cb7e43ab110b1432c /toolsrc/src/vcpkg-test/files.cpp
parent1095c177a9e1616921c03ffcd3a7799c627b5cd0 (diff)
downloadvcpkg-5d33bd3d7910c6090911f71f9dcf1a4eecd303da.tar.gz
vcpkg-5d33bd3d7910c6090911f71f9dcf1a4eecd303da.zip
[vcpkg] Fix the case of current_path() before use on Windows. (#13537)
* Fix the case of current_path() before use on Windows. This is a better solution than that I tried in https://github.com/microsoft/vcpkg/pull/13144 -- rather than trying to cannoicalize the path completely, which would destroy symlinks etc; this form calls FindFirstFile on each path element to get the real case from the filesystem. Fixes #13105. (Note the wrong case in the CWD in the prompt, but the correct case in all the output:) PS C:\DeV\vcPKG> .\vcpkg.exe install curl Computing installation plan... The following packages will be built and installed: curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows * zlib[core]:x86-windows Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x86-windows... Starting package 1/2: zlib:x86-windows Building package zlib[core]:x86-windows... Using cached binary package: C:\Users\billy\AppData\Local\vcpkg/archives\c6\c61dd1bcc23348934c55f4ced77f1e4b0f353394.zipBuilding package zlib[core]:x86-windows... done Installing package zlib[core]:x86-windows... Installing package zlib[core]:x86-windows... done Elapsed time for package zlib:x86-windows: 62.26 ms Starting package 2/2: curl:x86-windows Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip -- Downloading https://github.com/curl/curl/archive/9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz... -- Extracting source C:/Dev/vcpkg/downloads/curl-curl-9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz -- Applying patch 0002_fix_uwp.patch -- Applying patch 0004_nghttp2_staticlib.patch -- Applying patch 0005_remove_imp_suffix.patch -- Applying patch 0006_fix_tool_depends.patch -- Applying patch 0007_disable_tool_export_curl_target.patch -- Applying patch 0009_fix_openssl_config.patch -- Applying patch 0010_fix_othertests_cmake.patch -- Applying patch 0011_fix_static_build.patch -- Using source at C:/Dev/vcpkg/buildtrees/curl/src/767f0f2a9e-91d24adee1.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/curl-config -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/vcpkg-cmake-wrapper.cmake -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/copyright -- Performing post-build validation -- Performing post-build validation done Stored binary cache: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Elapsed time for package curl:x86-windows: 1.299 min Total elapsed time: 1.33 min The package curl:x86-windows provides CMake targets: find_package(CURL CONFIG REQUIRED) target_link_libraries(main PRIVATE CURL::libcurl) PS C:\DeV\vcPKG> * Fix *nix builds. * PR feedback. * Update toolsrc/src/vcpkg/base/files.cpp Co-authored-by: ras0219 <533828+ras0219@users.noreply.github.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test/files.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/files.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-test/files.cpp b/toolsrc/src/vcpkg-test/files.cpp
index a8c7c2ba2..429a4ba15 100644
--- a/toolsrc/src/vcpkg-test/files.cpp
+++ b/toolsrc/src/vcpkg-test/files.cpp
@@ -194,6 +194,62 @@ TEST_CASE ("remove all", "[files]")
CHECK_EC_ON_FILE(temp_dir, ec);
}
+#if defined(_WIN32)
+TEST_CASE ("win32_fix_path_case", "[files]")
+{
+ using vcpkg::Files::win32_fix_path_case;
+
+ // This test assumes that the Windows directory is C:\Windows
+
+ CHECK(win32_fix_path_case(L"") == L"");
+
+ CHECK(win32_fix_path_case(L"C:") == L"C:");
+ CHECK(win32_fix_path_case(L"c:") == L"C:");
+ CHECK(win32_fix_path_case(L"C:/") == L"C:\\");
+ CHECK(win32_fix_path_case(L"C:\\") == L"C:\\");
+ CHECK(win32_fix_path_case(L"c:\\") == L"C:\\");
+ CHECK(win32_fix_path_case(L"C:\\WiNdOws") == L"C:\\Windows");
+ CHECK(win32_fix_path_case(L"c:\\WiNdOws\\") == L"C:\\Windows\\");
+ CHECK(win32_fix_path_case(L"C://///////WiNdOws") == L"C:\\Windows");
+ CHECK(win32_fix_path_case(L"c:\\/\\/WiNdOws\\/") == L"C:\\Windows\\");
+
+ auto& fs = vcpkg::Files::get_real_filesystem();
+ auto original_cwd = fs.current_path(VCPKG_LINE_INFO);
+ fs.current_path(L"C:\\", VCPKG_LINE_INFO);
+ CHECK(win32_fix_path_case(L"\\") == L"\\");
+ CHECK(win32_fix_path_case(L"\\/\\WiNdOws") == L"\\Windows");
+ CHECK(win32_fix_path_case(L"\\WiNdOws") == L"\\Windows");
+ CHECK(win32_fix_path_case(L"\\WiNdOws") == L"\\Windows");
+ CHECK(win32_fix_path_case(L"c:WiNdOws") == L"C:Windows");
+ CHECK(win32_fix_path_case(L"c:WiNdOws/system32") == L"C:Windows\\System32");
+ fs.current_path(original_cwd, VCPKG_LINE_INFO);
+
+ fs.create_directories("SuB/Dir/Ectory", VCPKG_LINE_INFO);
+ CHECK(win32_fix_path_case(L"sub") == L"SuB");
+ CHECK(win32_fix_path_case(L"SUB") == L"SuB");
+ CHECK(win32_fix_path_case(L"sub/") == L"SuB\\");
+ CHECK(win32_fix_path_case(L"sub/dir") == L"SuB\\Dir");
+ CHECK(win32_fix_path_case(L"sub/dir/") == L"SuB\\Dir\\");
+ CHECK(win32_fix_path_case(L"sub/dir/ectory") == L"SuB\\Dir\\Ectory");
+ CHECK(win32_fix_path_case(L"sub/dir/ectory/") == L"SuB\\Dir\\Ectory\\");
+ fs.remove_all("SuB", VCPKG_LINE_INFO);
+
+ CHECK(win32_fix_path_case(L"//nonexistent_server\\nonexistent_share\\") ==
+ L"\\\\nonexistent_server\\nonexistent_share\\");
+ CHECK(win32_fix_path_case(L"\\\\nonexistent_server\\nonexistent_share\\") ==
+ L"\\\\nonexistent_server\\nonexistent_share\\");
+ CHECK(win32_fix_path_case(L"\\\\nonexistent_server\\nonexistent_share") ==
+ L"\\\\nonexistent_server\\nonexistent_share");
+
+ CHECK(win32_fix_path_case(L"///three_slashes_not_a_server\\subdir\\") == L"\\three_slashes_not_a_server\\subdir\\");
+
+ CHECK(win32_fix_path_case(L"\\??\\c:\\WiNdOws") == L"\\??\\c:\\WiNdOws");
+ CHECK(win32_fix_path_case(L"\\\\?\\c:\\WiNdOws") == L"\\\\?\\c:\\WiNdOws");
+ CHECK(win32_fix_path_case(L"\\\\.\\c:\\WiNdOws") == L"\\\\.\\c:\\WiNdOws");
+ CHECK(win32_fix_path_case(L"c:\\/\\/Nonexistent\\/path/here") == L"C:\\Nonexistent\\path\\here");
+}
+#endif // _WIN32
+
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
TEST_CASE ("remove all -- benchmarks", "[files][!benchmark]")
{