summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-02 09:47:35 -0700
committerRussell Belfer <rb@github.com>2014-04-02 09:47:35 -0700
commit2e9c07f5eda5070bdcf9f962809375e5e3c561bb (patch)
tree0581602ed3fbcf7474366a88e100fb4f3017726c
parentada157b2375bea8ed0c7a71320a3325a9903ebd7 (diff)
downloadlibgit2-rb/dont-count-on-libgit2-source.tar.gz
Create cl_skip macro and use it to skip testsrb/dont-count-on-libgit2-source
There are a few tests that we need to skip in some cases. This adds a cl_skip macro to return from the current test and print a nicely formatted reason for doing so.
-rw-r--r--tests/blame/simple.c3
-rw-r--r--tests/clar.c10
-rw-r--r--tests/clar.h2
-rw-r--r--tests/clar_libgit2.h2
-rw-r--r--tests/online/clone.c13
-rw-r--r--tests/online/push.c64
6 files changed, 51 insertions, 43 deletions
diff --git a/tests/blame/simple.c b/tests/blame/simple.c
index 86e8fe264..4e28e5b9f 100644
--- a/tests/blame/simple.c
+++ b/tests/blame/simple.c
@@ -141,9 +141,8 @@ void test_blame_simple__trivial_libgit2(void)
git_repository_is_shallow(g_repo) ||
git_revparse_single(&obj, g_repo, "359fc2d") < 0)
{
- printf("NOT INSIDE VALID LIBGIT2 REPO; skipping blame test\n");
giterr_clear();
- return;
+ cl_skip("not inside valid libgit2 repo");
}
git_oid_cpy(&opts.newest_commit, git_object_id(obj));
diff --git a/tests/clar.c b/tests/clar.c
index 2f81a1923..5eb1c05f6 100644
--- a/tests/clar.c
+++ b/tests/clar.c
@@ -555,6 +555,16 @@ void cl_set_cleanup(void (*cleanup)(void *), void *opaque)
_clar.local_cleanup_payload = opaque;
}
+const char *clar_active_suite(void)
+{
+ return _clar.active_suite;
+}
+
+const char *clar_active_test(void)
+{
+ return _clar.active_test;
+}
+
#include "clar/sandbox.h"
#include "clar/fixtures.h"
#include "clar/fs.h"
diff --git a/tests/clar.h b/tests/clar.h
index 81263051d..48786de2c 100644
--- a/tests/clar.h
+++ b/tests/clar.h
@@ -16,6 +16,8 @@ void clar_test_shutdown(void);
int clar_test(int argc, char *argv[]);
const char *clar_sandbox_path(void);
+const char *clar_active_suite(void);
+const char *clar_active_test(void);
void cl_set_cleanup(void (*cleanup)(void *), void *opaque);
void cl_fs_cleanup(void);
diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h
index 915111244..48c26b054 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar_libgit2.h
@@ -65,6 +65,8 @@ void clar__assert_equal_file(
const char *file,
int line);
+#define cl_skip(reason) do { printf("skipping %s::%s; %s\n", clar_active_suite(), clar_active_test(), reason); return; } while (0)
+
/*
* Some utility macros for building long strings
*/
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 9919e8b06..fd39afbd4 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -200,15 +200,10 @@ void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
const char *remote_url = cl_getenv("GITTEST_REMOTE_URL");
const char *remote_user = cl_getenv("GITTEST_REMOTE_USER");
- if (!remote_url) {
- printf("GITTEST_REMOTE_URL unset; skipping clone test\n");
- return;
- }
-
- if (!remote_user) {
- printf("GITTEST_REMOTE_USER unset; skipping clone test\n");
- return;
- }
+ if (!remote_url)
+ cl_skip("GITTEST_REMOTE_URL unset");
+ if (!remote_user)
+ cl_skip("GITTEST_REMOTE_USER unset");
g_options.remote_callbacks.credentials = cred_failure_cb;
diff --git a/tests/online/push.c b/tests/online/push.c
index 55b97b282..00d567756 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -307,6 +307,9 @@ void test_online_push__initialize(void)
/* Remote URL environment variable must be set. User and password are optional. */
_remote_url = cl_getenv("GITTEST_REMOTE_URL");
+ if (!_remote_url)
+ cl_skip("GITTEST_REMOTE_URL unset");
+
_remote_user = cl_getenv("GITTEST_REMOTE_USER");
_remote_pass = cl_getenv("GITTEST_REMOTE_PASS");
_remote_ssh_key = cl_getenv("GITTEST_REMOTE_SSH_KEY");
@@ -315,46 +318,43 @@ void test_online_push__initialize(void)
_remote_default = cl_getenv("GITTEST_REMOTE_DEFAULT");
_remote = NULL;
- if (_remote_url) {
- cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url));
+ cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url));
- record_callbacks_data_clear(&_record_cbs_data);
- git_remote_set_callbacks(_remote, &_record_cbs);
+ record_callbacks_data_clear(&_record_cbs_data);
+ git_remote_set_callbacks(_remote, &_record_cbs);
- cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH));
+ cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH));
- /* Clean up previously pushed branches. Fails if receive.denyDeletes is
- * set on the remote. Also, on Git 1.7.0 and newer, you must run
- * 'git config receive.denyDeleteCurrent ignore' in the remote repo in
- * order to delete the remote branch pointed to by HEAD (usually master).
- * See: https://raw.github.com/git/git/master/Documentation/RelNotes/1.7.0.txt
- */
- cl_git_pass(git_remote_ls(&heads, &heads_len, _remote));
- cl_git_pass(create_deletion_refspecs(&delete_specs, heads, heads_len));
- if (delete_specs.length) {
- git_push *push;
-
- cl_git_pass(git_push_new(&push, _remote));
+ /* Clean up previously pushed branches. Fails if receive.denyDeletes is
+ * set on the remote. Also, on Git 1.7.0 and newer, you must run
+ * 'git config receive.denyDeleteCurrent ignore' in the remote repo in
+ * order to delete the remote branch pointed to by HEAD (usually master).
+ * See: https://raw.github.com/git/git/master/Documentation/RelNotes/1.7.0.txt
+ */
+ cl_git_pass(git_remote_ls(&heads, &heads_len, _remote));
+ cl_git_pass(create_deletion_refspecs(&delete_specs, heads, heads_len));
+ if (delete_specs.length) {
+ git_push *push;
- git_vector_foreach(&delete_specs, i, curr_del_spec) {
- git_push_add_refspec(push, curr_del_spec);
- git__free(curr_del_spec);
- }
+ cl_git_pass(git_push_new(&push, _remote));
- cl_git_pass(git_push_finish(push));
- git_push_free(push);
+ git_vector_foreach(&delete_specs, i, curr_del_spec) {
+ git_push_add_refspec(push, curr_del_spec);
+ git__free(curr_del_spec);
}
- git_remote_disconnect(_remote);
- git_vector_free(&delete_specs);
+ cl_git_pass(git_push_finish(push));
+ git_push_free(push);
+ }
- /* Now that we've deleted everything, fetch from the remote */
- cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_FETCH));
- cl_git_pass(git_remote_download(_remote));
- cl_git_pass(git_remote_update_tips(_remote, NULL, NULL));
- git_remote_disconnect(_remote);
- } else
- printf("GITTEST_REMOTE_URL unset; skipping push test\n");
+ git_remote_disconnect(_remote);
+ git_vector_free(&delete_specs);
+
+ /* Now that we've deleted everything, fetch from the remote */
+ cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_FETCH));
+ cl_git_pass(git_remote_download(_remote));
+ cl_git_pass(git_remote_update_tips(_remote, NULL, NULL));
+ git_remote_disconnect(_remote);
}
void test_online_push__cleanup(void)