diff options
Diffstat (limited to 'tests-clar/clar_libgit2.h')
-rw-r--r-- | tests-clar/clar_libgit2.h | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/tests-clar/clar_libgit2.h b/tests-clar/clar_libgit2.h index d250494f5..93909d8a5 100644 --- a/tests-clar/clar_libgit2.h +++ b/tests-clar/clar_libgit2.h @@ -6,17 +6,17 @@ #include "common.h" /** - * Special wrapper for `clar_must_pass` that passes - * the last library error as the test failure message. + * Replace for `clar_must_pass` that passes the last library error as the + * test failure message. * - * Use this wrapper around all `git_` library calls that - * return error codes! + * Use this wrapper around all `git_` library calls that return error codes! */ #define cl_git_pass(expr) do { \ + int _lg2_error; \ giterr_clear(); \ - if ((expr) != 0) \ - clar__assert(0, __FILE__, __LINE__, "Function call failed: " #expr, giterr_last() ? giterr_last()->message : NULL, 1); \ - } while(0) + if ((_lg2_error = (expr)) != 0) \ + cl_git_report_failure(_lg2_error, __FILE__, __LINE__, "Function call failed: " #expr); \ + } while (0) /** * Wrapper for `clar_must_fail` -- this one is @@ -25,6 +25,12 @@ */ #define cl_git_fail(expr) cl_must_fail(expr) +#define cl_git_fail_with(expr, error) cl_assert_equal_i(error,expr) + +void cl_git_report_failure(int, const char *, int, const char *); + +#define cl_assert_equal_sz(sz1,sz2) cl_assert_equal_i((int)sz1, (int)(sz2)) + /* * Some utility macros for building long strings */ @@ -38,11 +44,31 @@ void cl_git_mkfile(const char *filename, const char *content); void cl_git_append2file(const char *filename, const char *new_content); void cl_git_rewritefile(const char *filename, const char *new_content); -void cl_git_write2file(const char *filename, const char *new_content, int mode); +void cl_git_write2file(const char *filename, const char *new_content, int flags, unsigned int mode); + +bool cl_toggle_filemode(const char *filename); +bool cl_is_chmod_supported(void); + +/* Environment wrappers */ +char *cl_getenv(const char *name); +int cl_setenv(const char *name, const char *value); + +/* Reliable rename */ +int cl_rename(const char *source, const char *dest); /* Git sandbox setup helpers */ git_repository *cl_git_sandbox_init(const char *sandbox); void cl_git_sandbox_cleanup(void); +/* Local-repo url helpers */ +const char* cl_git_fixture_url(const char *fixturename); +const char* cl_git_path_url(const char *path); + +/* Test repository cleaner */ +int cl_git_remove_placeholders(const char *directory_path, const char *filename); + +/* config setting helpers */ +void cl_repo_set_bool(git_repository *repo, const char *cfg, int value); + #endif |