Running dotest.py with a path to tests directory results in:
terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid Aborted
for some tests. For example, when a test executes command "script import relative_path.py" the exception happens in ScriptInterpreterPython::LoadScriptingModule at the line
std::string directory = target_file.GetDirectory().GetCString();
because GetCString returns nullptr.
The reason of such behavior is that llvm::RealFileSystem returns cached current working directory value until it will be updated with setCurrentWorkingDirectory. So, we permanently have cwd == directory of the first test, FileSystem::Resolve doesn't find the file and just returns the original value.
P.S. What about FileSpec::GetDirectory and FileSpec::GetFileName those never return nullptr? There is a lot of code that doesn't check result on nullptr (look at llvm.org/pr37054, for example). I made a patch where these functions return empty strings instead of nullptr, but some tests fail as they expect the result is None. Other API users can be broken also.