[WIP] extend unit test to directories starting or ending in whitespace

front port of #5647 - let's see what happens with doctrine