Fix wxFileName::ReplaceHomeDir() when HOME=="/"

This is rare but can happen and the function behaved completely wrongly
in this case, so handle it explicitly.

Also disable the unit test when HOME has this value, as it assumes this
is not the case.
This commit is contained in:
Vadim Zeitlin 2022-06-23 21:42:38 +02:00
parent 231c079c70
commit 96a917eaa8
2 changed files with 15 additions and 1 deletions

View file

@ -466,7 +466,16 @@ TEST_CASE("wxFileName::Replace", "[filename]")
// now test ReplaceHomeDir
wxFileName fn = wxFileName::DirName(wxGetHomeDir());
const wxString& homedir = wxGetHomeDir();
if ( homedir == "/" )
{
// These tests assume that HOME is a non-root directory, but this may
// not be the case.
WARN("Skipping wxFileName::ReplaceHomeDir() tests because HOME=/");
return;
}
wxFileName fn = wxFileName::DirName(homedir);
fn.AppendDir("test1");
fn.AppendDir("test2");
fn.AppendDir("test3");