Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix build for unit test #3494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2015
Merged

Conversation

leoyanggit
Copy link

If none of GIT_OPENSSL, GIT_WINHTTP or GIT_SECURE_TRANSPORT
is defined we should also be able to build the unit test.

@carlosmn
Copy link
Member

These should not be successful, as we did not run the tests. They should be skipped.

@leoyanggit
Copy link
Author

How to skip it?

@carlosmn
Copy link
Member

With cl_skip().

@leoyanggit
Copy link
Author

Hmm cl_skip() seems to skip test in the runtime. But the problem here is that if none of those macros is defined the code won't compile. Or you mean in addition to my patch we should also use cl_skip() in my those 3 empty functions?

@ethomson
Copy link
Member

ethomson commented Nov 2, 2015

Hmm. I'm not sure I understand why you can't build those tests without those SSL? git_clone is public API, as is GIT_ECERTIFICATE... I would expect that you could build them but that they would fail.

If that's not the case, then that's the first thing that we need to fix.

Once that's done, I would expect to see something like:

void test_online_badssl__self_signed(void)
{
    if (!has_ssl)
        cl_skip();

    cl_git_fail_with(GIT_ECERTIFICATE,
        git_clone(&g_repo, "https://self-signed.badssl.com/fake.git", "./fake", NULL));
}

@leoyanggit
Copy link
Author

As I mentioned above: I have none of GIT_OPENSSL, GIT_WINHTTP or GIT_SECURE_TRANSPORT defined. Those 3 test functions are guarded by them. So I can't compile.

@ethomson
Copy link
Member

ethomson commented Nov 2, 2015

But there's nothing about those functions that you can't compile, right? In that case, you should put a cl_skip at the beginning of the test if you don't want to run it. You can leverage the existing #ifdefs to determine whether to skip or not.

@leoyanggit
Copy link
Author

But there's nothing about those functions that you can't compile, right?

right.

Seems like I don't get how cl_skip works. By at the beginning of the test what do you mean?

@ethomson
Copy link
Member

ethomson commented Nov 2, 2015

Like what I posted above. I think you want to do something like:

#include "git2/clone.h"

static git_repository *g_repo;

#if defined(GIT_OPENSSL) || defined(GIT_WINHTTP) || defined(GIT_SECURE_TRANSPORT)
static bool has_ssl = true;
#else
static bool has_ssl = false;
#endif

void test_online_badssl__self_signed(void)
{
    if (!has_ssl)
        cl_skip();

    cl_git_fail_with(GIT_ECERTIFICATE,
        git_clone(&g_repo, "https://self-signed.badssl.com/fake.git", "./fake", NULL));
}

...etc...

@leoyanggit
Copy link
Author

I see. Instead of forking the test functions just adding some flags. I'll update my patch to follow this style.

If none of GIT_OPENSSL, GIT_WINHTTP or GIT_SECURE_TRANSPORT
is defined we should also be able to build the unit test.
@leoyanggit
Copy link
Author

OK, patch updated.

@ethomson
Copy link
Member

ethomson commented Nov 2, 2015

Awesome! 👯

Thanks for this.

@leoyanggit
Copy link
Author

Thank you for the review!

carlosmn added a commit that referenced this pull request Nov 3, 2015
@carlosmn carlosmn merged commit 3ce6cd4 into libgit2:master Nov 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants