Closed robertdfrench closed 3 years ago
@calebwherry this now "works", in the sense that every Git
object has a TempDir
member which will have the opportunity to attempt cleanup when the Git
object goes out of scope. However, there are some refactoring opportunities:
Git
's members are now public, so that they can be modified in the integration tests. That's not really a problem, but it seems like a crappy design since it allows Git
to be mutated in ways that would make it unsound.fake_git
test program is now even more deeply nested, and feels even more silly than it originally did.Git
is becoming more repetitive, particularly now that everything begins with <BINARY_PATH> -C <WORKING_DIRECTORY>
tests/real_git.rs
initializes an empty repo, and populates it with the stuff it needs for every integration test. We were doing this because we could only have one repo with the old pattern. Now we can break this setup logic into smaller chunks that can be done inside each integration test.
This is a proof of concept for re-introducing the
tempdir
package and using it to create a git repository for each test. By adding aworking_dir
field to the Git client wrapper, it can run all of its git commands with the-C
flag, as in:According to GIT(1), the
-C <DIR>
option instructs git to run as though it had been launched fromDIR
, even ifDIR
is not the current working directory of the parent process. Given that we cannot change the working directory ofcargo test
(since it runs tests as threads of a single process, and the notion of a "working directory" is a process-level property), this should give us exactly what we want.Caveat. The temporary repositories do not seem to actually get deleted on my mac. The TempDir docs seem to anticipate this:
So, perhaps this is all for naught. 🤷