[darcs-devel] Help needed with the test harness

Ben Franksen ben.franksen at online.de
Wed May 17 09:24:56 UTC 2017


Hi Everyone

as I explained on #darcs I am working on fixing the encoding business in
darcs. I have uploaded my working version as a fork of screened under
bf at hub.darcs.net:bf/darcs-encoding. It passes all (shell, network)
tests, with darcs1 and darcs2, including a new test I have written to
check that operations on the same repo behave consistently even when we
switch the locale charset from UTF-8 to C (ASCII) and back.

However, I have problems with getting the test harness to compile that I
seem to be unable to solve without help.

The problem is caused by a refactoring regarding Prim (V1) patches. I
was not satisfied with the way file names are displayed to the user when
they contain non-ASCII characters or spaces. I discovered that the
reason for this is that Prim(V1) patches had been made instances of
ShowPatch, ReadPatch, and PatchListFormat. But this is incorrect!

Prim(V1) patches /cannot/ correctly implement these interfaces (and thus
also not the PrimPatch class etc), since the format of file names and
patch lists differs depending on whether the RepoPatch that uses them is
V1 or V2. On the other hand, large parts of the darcs code base,
including the unit and quickcheck tests for the patch system, depend on
being able to treat Prim patches very similar to RepoPatches. The only
manageable solution I found is to wrap Prim (V1) patches with a
RepoPatch-specific newtype (see Darcs.Patch.V1.Prim and
Darcs.Patch.V2.Prim). The wrapped types can now correctly implement the
above classes. They are what is now returned by the PrimOf type
function. A second type function RawPrimOf returns the actual Prim(V1)
patch (for FileUUID there is no wrapper and both are identical). The
latter is what actually gets created for the tests; I was able to adapt
the unit tests for RepoPatchV1 and RepoPatchV2 by traversing the
structures containing actual PrimV1 patches, wrapping each of them with
the appropriate newtype wrapper.

But I was unable to do this for the tests that directly operate on Prim
patches. I am pretty sure it is possible, I just can't figure out at
which point to apply the wrappers because the types are so complicated...

So the unit tests for Prim patches in my working version (qc_prim and
its use in harness/Darcs/Test/Patch.hs) are currently commented out. If
someone could look at my code and give me some hints...

If you have questions regarding the design, just ask and I will explain
in detail what I changed and why. I am also open to criticism; I may
have complicated things unnecessarily, even though I tried very hard not
to. I learned a lot about the internal workings of darcs, to the point
where I have the feeling I have dug into each and every dark corner...
but I may still miss some of the higher level design ideas. And the
tests system's pervasive use of overloading and type level programming
makes it so difficult to understand what's going on that I have more or
less given up on that. I just want to get it working again and move on.

Cheers
Ben



More information about the darcs-devel mailing list