mirror of https://github.com/microsoft/WSL
test: add more path translation variations
This commit is contained in:
parent
e24df7e0d1
commit
5e157e6cf0
|
|
@ -163,6 +163,13 @@ Return Value:
|
||||||
LxtCheckResult(LxtCheckWslPathTranslation("C:/Foo/bar", "/mnt/c/Foo/bar", true));
|
LxtCheckResult(LxtCheckWslPathTranslation("C:/Foo/bar", "/mnt/c/Foo/bar", true));
|
||||||
LxtCheckResult(LxtCheckWslPathTranslation("foo", "foo", true));
|
LxtCheckResult(LxtCheckWslPathTranslation("foo", "foo", true));
|
||||||
LxtCheckResult(LxtCheckWslPathTranslation("foo\\", "foo/", true));
|
LxtCheckResult(LxtCheckWslPathTranslation("foo\\", "foo/", true));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation("C:\\Program Files\\Git", "/mnt/c/Program Files/Git", true));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation("C:\\Program Files\\PowerShell\\7", "/mnt/c/Program Files/PowerShell/7", true));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation("C:\\Program Files (x86)\\Common Files", "/mnt/c/Program Files (x86)/Common Files", true));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation(
|
||||||
|
"C:\\Users\\Test User\\AppData\\Local\\Programs\\Microsoft VS Code\\bin",
|
||||||
|
"/mnt/c/Users/Test User/AppData/Local/Programs/Microsoft VS Code/bin",
|
||||||
|
true));
|
||||||
|
|
||||||
ErrorExit:
|
ErrorExit:
|
||||||
return Result;
|
return Result;
|
||||||
|
|
@ -241,6 +248,13 @@ Return Value:
|
||||||
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Users", "C:\\Users", false));
|
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Users", "C:\\Users", false));
|
||||||
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Users/", "C:\\Users\\", false));
|
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Users/", "C:\\Users\\", false));
|
||||||
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/DOESNOTEXIST/", "C:\\DOESNOTEXIST\\", false));
|
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/DOESNOTEXIST/", "C:\\DOESNOTEXIST\\", false));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Program Files/Git", "C:\\Program Files\\Git", false));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Program Files/PowerShell/7", "C:\\Program Files\\PowerShell\\7", false));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation("/mnt/c/Program Files (x86)/Common Files", "C:\\Program Files (x86)\\Common Files", false));
|
||||||
|
LxtCheckResult(LxtCheckWslPathTranslation(
|
||||||
|
"/mnt/c/Users/Test User/AppData/Local/Programs/Microsoft VS Code/bin",
|
||||||
|
"C:\\Users\\Test User\\AppData\\Local\\Programs\\Microsoft VS Code\\bin",
|
||||||
|
false));
|
||||||
|
|
||||||
ErrorExit:
|
ErrorExit:
|
||||||
return Result;
|
return Result;
|
||||||
|
|
|
||||||
|
|
@ -262,5 +262,39 @@ class SimpleTests
|
||||||
std::transform(upperCaseGuidStringWide.begin(), upperCaseGuidStringWide.end(), upperCaseGuidStringWide.begin(), toupper);
|
std::transform(upperCaseGuidStringWide.begin(), upperCaseGuidStringWide.end(), upperCaseGuidStringWide.begin(), toupper);
|
||||||
VERIFY_ARE_EQUAL(upperCaseGuidStringWide, wsl::shared::string::GuidToString<wchar_t>(guid, wsl::shared::string::GuidToStringFlags::Uppercase));
|
VERIFY_ARE_EQUAL(upperCaseGuidStringWide, wsl::shared::string::GuidToString<wchar_t>(guid, wsl::shared::string::GuidToStringFlags::Uppercase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(WindowsPathWithSpaces)
|
||||||
|
{
|
||||||
|
wil::unique_environstrings_ptr originalPath;
|
||||||
|
const DWORD pathLength = GetEnvironmentVariableW(L"PATH", nullptr, 0);
|
||||||
|
if (pathLength > 0)
|
||||||
|
{
|
||||||
|
originalPath.reset(static_cast<PWSTR>(HeapAlloc(GetProcessHeap(), 0, pathLength * sizeof(wchar_t))));
|
||||||
|
THROW_LAST_ERROR_IF_NULL(originalPath.get());
|
||||||
|
THROW_LAST_ERROR_IF(GetEnvironmentVariableW(L"PATH", originalPath.get(), pathLength) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto cleanup = wil::scope_exit([&]() {
|
||||||
|
if (originalPath)
|
||||||
|
{
|
||||||
|
THROW_LAST_ERROR_IF(!SetEnvironmentVariableW(L"PATH", originalPath.get()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const wchar_t* testPath =
|
||||||
|
L"C:\\Program Files\\Git\\cmd;"
|
||||||
|
L"C:\\Program Files\\PowerShell\\7;"
|
||||||
|
L"C:\\Program Files (x86)\\Common Files;"
|
||||||
|
L"C:\\Users\\Test User\\AppData\\Local\\Programs\\Microsoft VS Code\\bin";
|
||||||
|
|
||||||
|
THROW_LAST_ERROR_IF(!SetEnvironmentVariableW(L"PATH", testPath));
|
||||||
|
|
||||||
|
auto [output, __] = LxsstuLaunchWslAndCaptureOutput(L"echo $PATH");
|
||||||
|
|
||||||
|
VERIFY_IS_TRUE(output.find(L"/mnt/c/Program Files/Git/cmd") != std::wstring::npos);
|
||||||
|
VERIFY_IS_TRUE(output.find(L"/mnt/c/Program Files/PowerShell/7") != std::wstring::npos);
|
||||||
|
VERIFY_IS_TRUE(output.find(L"/mnt/c/Program Files (x86)/Common Files") != std::wstring::npos);
|
||||||
|
VERIFY_IS_TRUE(output.find(L"/mnt/c/Users/Test User/AppData/Local/Programs/Microsoft VS Code/bin") != std::wstring::npos);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace SimpleTests
|
} // namespace SimpleTests
|
||||||
Loading…
Reference in New Issue