ScalaCheck and the Unkillable Trash

2016-04-21

Well that’s weird

I ran into an interesting problem in a recent Scala project. Let’s set the scene …

Quickly Checking in Scala

In the project in question, I reached for a library to do a fair amount of JSON parsing. I hadn’t used the library before, so I ended up writing some ScalaCheck tests for the convenience/wrapper functions I made.

One test involved writing data to a temporary file, reading and parsing that information, then comparing the parsed results to the original data. If all went well, the parsed and original data should match perfectly. Either way, there was clean up code at the end of the test to delete the temporary file. My mistake was in letting ScalaCheck generate strings of arbitrary characters for the temporary file’s name, rather than restricting those filenames to printable or alphanumeric characters only.

Obscure OS X obstacles

It turns out that the latest version of Mac OS X can’t delete—or otherwise get a handle on, via GUI or CLI—files with certain characters in the name. So, when ScalaCheck created such a temporary file, my clean up code was unable to rm it. I tried everything the Quantifind Dev team and I could think of, to no avail. I now have, tucked away in a directory called unkillable_trash, a file that nothing short of reformatting my hard drive will remove.

Update (2017-04-13)

Since the time of this post, a botched update necessitated reinstalling the OS on my work computer; the unkillable_trash is, sadly, now gone.