libgit2/tests
Russell Belfer 25e0b1576d Remove converting user error to GIT_EUSER
This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
2013-12-11 10:57:49 -08:00
..
attr Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
blame Clean up warnings 2013-12-09 11:40:44 -05:00
buf Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
checkout Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
clar Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
clone Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
commit Introduce git_revert to revert a single commit 2013-12-02 16:57:41 -06:00
config Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
core Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
date Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
diff Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
fetchhead Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
filter Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
index tests: Drop unrelated comment 2013-11-19 14:25:30 +01:00
merge Clean up warnings 2013-12-09 11:40:44 -05:00
network Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
notes Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
object Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
odb Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
online Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
pack Update files that reference tests-clar 2013-11-14 14:10:32 -08:00
refs Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
repo Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
reset Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
resources Introduce git_revert to revert a single commit 2013-12-02 16:57:41 -06:00
revert Reorder var decls in revert test 2013-12-03 10:47:18 -05:00
revwalk Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
stash Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
status Remove converting user error to GIT_EUSER 2013-12-11 10:57:49 -08:00
stress Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
submodule Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
threads Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
trace Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
clar_libgit2.c Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
clar_libgit2.h Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
clar.c Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
clar.h Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
generate.py Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
main.c Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
README.md Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
valgrind-supp-mac.txt Rename tests-clar to tests 2013-11-14 14:05:52 -08:00

Writing Clar tests for libgit2

For information on the Clar testing framework and a detailed introduction please visit:

https://github.com/vmg/clar

  • Write your modules and tests. Use good, meaningful names.

  • Make sure you actually build the tests by setting:

      cmake -DBUILD_CLAR=ON build/
    
  • Test:

      ./build/libgit2_clar
    
  • Make sure everything is fine.

  • Send your pull request. That's it.