-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests leave fingerprint/archive files in ~/.unison #636
Comments
I have two proposals for you. First is to use the Second is to have self-test mode remove all files behind itself (see patch proposal below - I can open a PR if you'd like). But this still leaves the homedir behind. The ultimate solution is probably to combine the two above in
(One might ask - why not do this sequence without the second proposal above? Well, because running self-tests is possible without a A PR would be appreciated if someone can write this up in the A patch to implement the second proposal above: Edit: This patch is slightly wrong, it does not clean up when a test fails. I'm keeping it as it is here and fix it if there is a desire to get a PR. diff --git a/src/test.ml b/src/test.ml
index 60ccd052..82df092c 100644
--- a/src/test.ml
+++ b/src/test.ml
@@ -555,6 +555,9 @@ let test() =
*)
end;
+ Util.msg "Cleaning up...\n";
+ Lwt_unix.run (Update.removeAllArchiveFiles ());
+
if !failures = 0 then
Util.msg "Success :-)\n"
else
diff --git a/src/update.ml b/src/update.ml
index 4fa5ccee..c7cc0616 100644
--- a/src/update.ml
+++ b/src/update.ml
@@ -612,6 +612,14 @@ let removeArchiveLocal ((fspath: Fspath.t), (v: archiveVersion)): unit Lwt.t =
let removeArchiveOnRoot: Common.root -> archiveVersion -> unit Lwt.t =
Remote.registerRootCmd "removeArchive" marchiveVersion Umarshal.unit removeArchiveLocal
+let removeAllArchiveFiles () =
+ Globals.allRootsIter (fun r ->
+ removeArchiveOnRoot r FPCache >>= fun () ->
+ removeArchiveOnRoot r ScratchArch >>= fun () ->
+ removeArchiveOnRoot r NewArch >>= fun () ->
+ removeArchiveOnRoot r MainArch >>= fun () ->
+ removeArchiveOnRoot r Lock)
+
(* [commitArchive (fspath, ())] commits the archive for [fspath] by changing
the filenames from ScratchArch-ones to a NewArch-ones *)
let commitArchiveLocal ((fspath: Fspath.t), ())
diff --git a/src/update.mli b/src/update.mli
index 7451dd2e..a8f53bb8 100644
--- a/src/update.mli
+++ b/src/update.mli
@@ -99,3 +99,7 @@ val setStasherFun : (Fspath.t -> Path.local -> unit) -> unit
presentation of the current fspath with the list of names/fspaths of
all the roots and the current archive format *)
val archiveHash : Fspath.t -> string
+
+(* Remove all permanent and temporary archive and cache files for current
+ roots. Useful when running self-tests. *)
+val removeAllArchiveFiles : unit -> unit Lwt.t |
Let's see where we are after the Makefile cleanup and BUILD.md conversion. It may be that we document that tests run via "make check" -- perhaps after making it so -- in which case ad hoc running of tests doing random things is not really a bug. It also might be that we move at least slightly in the direction of out--of-tree builds (mkdir build; cd build && ../configure, not that unison is like that) and tests could be like that. I am not really bothered by droppings in a build tree; it's the stuff in the real unison dir that is an issue. It's also not a major issues |
When running
make test
, the tests run, which is great, but this results in ar/fp files for the test roots remaining in the user's ~/.unison directory. This behavior is likely to trigger an error in pkgsrc, which creates a fake HOME and checks that it is empty after building (but perhaps not after testing, although it should).The tests should be independent of the user's enviironment both ways, not reading config, and not writing. To fix, some sort of temporary/fake homedir should be created, or some similar workaround.
The text was updated successfully, but these errors were encountered: