This reapplies commit 95033eb3 that reverted commit 1d9e8e13. The tests were failing on Windows due to spaces and backslashes in paths not being handled carefully.