Add check to skip directory change when basePath is "." or already the
current working directory. This fixes test failures with mock filesystems
that don't have "." in their directory list.
Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com>