The chaotic order is intended. Some completion algorithms tend to sort
their results by modification time or something similar.
The "huge" number of directories is also intended. With more items the
chance is higher to hit a bug if no sorting took place.
Since Zsh just completes non-empty directories, some files have to be
created, too.
Even if there is a directory in the current working directory with the
same name as a command, the directory must not be completed.
So, if we want to complete "true" and there is a directory "true" in the
current working directory, the completion list has to be just {"true"},
not {"true", "true/"}, or anything else!
In some circumstances, if not every syscall was somehow redefined, the
directory was not changed correctly. With luafilesystem.chdir it is
assured that we are in the wanted directory afterwards.
Since busted seems to spawn isolated child processes for every test
suite, the temporary PATH directories have to be created at the
beginning and destroyed at the end of a test suite.
We cannot possibly know what is in the PATH of a user. The completion
test cases however assume that there is nothing else in the PATH that
starts with `true` other than `true` itself.
These two methods create or respectively destroy a temporary PATH
directory especially for testing. We can put commands in there via
symlinks and verify the correct functionality of the complete commands.
The PATH environment variable is set and reset via GLib.