use tempdir instead of tempname in test/pkg.jl

since tempname creates a file on windows, but the goal here is creating
a directory. also don't try to delete nonexistent files during cleanup

(cherry picked from commit dd6cd5a63cd6164419aa4d579f2932a7bd7c2f8e)