diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-03-05 15:13:51 +0000 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-03-05 15:13:51 +0000 | 
| commit | 77c1c4e3c2e43a57e4a153d3dc2602b9566c901a (patch) | |
| tree | 61fcf34a9ba79c1fb3f8313ecaf510f18f0242ba | |
| parent | Initial fetch options in a way that doesn't produce a warning (diff) | |
| download | gentoobrowse-api-77c1c4e3c2e43a57e4a153d3dc2602b9566c901a.tar.bz2 gentoobrowse-api-77c1c4e3c2e43a57e4a153d3dc2602b9566c901a.tar.xz gentoobrowse-api-77c1c4e3c2e43a57e4a153d3dc2602b9566c901a.zip | |
Test, fix and remove debug around git operation function name retrieval
| -rw-r--r-- | gentoobrowse-api/service/utils/git.cpp | 3 | ||||
| -rw-r--r-- | gentoobrowse-api/service/utils/git.h | 2 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/Jamfile.jam | 8 | ||||
| -rw-r--r-- | gentoobrowse-api/unittests/testUtils.cpp | 23 | 
4 files changed, 34 insertions, 2 deletions
| diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp index 1dd3653..bbd69a3 100644 --- a/gentoobrowse-api/service/utils/git.cpp +++ b/gentoobrowse-api/service/utils/git.cpp @@ -10,8 +10,9 @@ namespace Gentoo {  			throwError(void * const func, int err)  			{  				const git_error * e = giterr_last(); -				fprintf(stderr, "func %p\n", func);  				char ** fn = backtrace_symbols(&func, 1); +				assert(fn); +				assert(*fn);  				throw ::Gentoo::GitError(*fn, err, e->klass, e->message);  			} diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h index 7df0172..6900435 100644 --- a/gentoobrowse-api/service/utils/git.h +++ b/gentoobrowse-api/service/utils/git.h @@ -11,7 +11,7 @@ namespace Gentoo {  			gitSafe(int (*func)(P...), A ... p)  			{  				if (int _giterror = func(p...) < 0) { -					throwError(&func, _giterror); +					throwError((void * const)func, _giterror);  				}  			} diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam index 558d7d9..9f60eb4 100644 --- a/gentoobrowse-api/unittests/Jamfile.jam +++ b/gentoobrowse-api/unittests/Jamfile.jam @@ -47,6 +47,14 @@ lib testCommon :  	;  run +	testUtils.cpp ../service/utils/git.cpp +	: : : +	<define>BOOST_TEST_DYN_LINK +	<library>testCommon +	<library>git2 +	: testUtils ; + +run  	testDepend.cpp ../service/depend.cpp  	: : :  	<define>BOOST_TEST_DYN_LINK diff --git a/gentoobrowse-api/unittests/testUtils.cpp b/gentoobrowse-api/unittests/testUtils.cpp new file mode 100644 index 0000000..e89f0fb --- /dev/null +++ b/gentoobrowse-api/unittests/testUtils.cpp @@ -0,0 +1,23 @@ +#define BOOST_TEST_MODULE TestDepend +#include <boost/test/unit_test.hpp> + +#include <utils/git.h> +#include <maintenance.h> + +using namespace Gentoo::Utils::Git; + +BOOST_AUTO_TEST_CASE( gitErrorMessage ) +{ +	try { +		gitSafeGet(git_repository_open_ext, git_repository_free, "/", 0, nullptr); +	} +	catch (const Gentoo::GitError & ge) { +		BOOST_TEST_CONTEXT(ge.what()) { +			BOOST_REQUIRE_EQUAL(ge.errorCode, 1); +			BOOST_REQUIRE_EQUAL(ge.errorClass, 6); +			BOOST_REQUIRE(ge.operation.find("git_repository_open_ext") + 1); +			BOOST_REQUIRE(ge.message.find("repository") + 1); +		} +	} +} + | 
