Skip to content
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

Fix version compatibility test. #315

Merged
merged 1 commit into from
Dec 13, 2016
Merged

Conversation

sudden6
Copy link

@sudden6 sudden6 commented Dec 11, 2016

When the version number has trailing zeros, a change of the first non-zero number means a break in API compatibility. eg. 0.0.1 to 0.0.2 means a break, 0.3.0 to 0.4.0 means a break, but 0.3.0 to 0.3.1 means not.


This change is Reviewable

@sudden6 sudden6 requested a review from iphydf December 11, 2016 16:48
@iphydf iphydf added this to the v0.1.0 milestone Dec 11, 2016
@iphydf
Copy link
Member

iphydf commented Dec 11, 2016

@sudden6 I've added some tests. I think these tests should pass, but they don't. They don't pass on the old macro either, so it seems the old macro was broken to begin with. Do you think these tests should pass? Also, if you can, please add some tests of your own, as these are currently incomplete.

@iphydf iphydf self-assigned this Dec 11, 2016
@iphydf iphydf added P1 High priority bug Bug fix for the user, not a fix to a build script labels Dec 11, 2016
@GrayHatter GrayHatter self-assigned this Dec 12, 2016
@iphydf iphydf removed their assignment Dec 12, 2016
@iphydf
Copy link
Member

iphydf commented Dec 13, 2016

Unassigning myself, since I rewrote the version check macro. Someone else needs to review.

@iphydf iphydf changed the title Fix version handling Fix version compatibility test. Dec 13, 2016
@robinlinden
Copy link
Member

:lgtm_strong:


Reviewed 3 of 5 files at r1, 2 of 2 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks broke.


Comments from Reviewable

@GrayHatter
Copy link

Reviewed 1 of 5 files at r1.
Review status: 4 of 5 files reviewed at latest revision, 3 unresolved discussions.


CMakeLists.txt, line 430 at r3 (raw file):

  auto_test(toxav_many)
endif()
auto_test(version)

move this above if(BUILD_TOXAV) and add a blank line between the must run, and optionally run


toxcore/tox.api.h, line 193 at r3 (raw file):

  (TOX_VERSION_MAJOR > 0 && TOX_VERSION_MAJOR == MAJOR) && (		\
    /* 1.x.x, 2.x.x, etc. with matching major version. */		\
    TOX_VERSION_MINOR > MINOR ||					\

tabs and not spaces?


toxcore/tox.h, line 195 at r3 (raw file):

#define TOX_VERSION_IS_API_COMPATIBLE(MAJOR, MINOR, PATCH)          \
  (TOX_VERSION_MAJOR > 0 && TOX_VERSION_MAJOR == MAJOR) && (        \
    /* 1.x.x, 2.x.x, etc. with matching major version. */       \

Comments don't belong inside a macro, around is fine.

If that's a problem, the macro is too big.


Comments from Reviewable

@GrayHatter
Copy link

Reviewed 2 of 3 files at r4.
Review status: 4 of 5 files reviewed at latest revision, 4 unresolved discussions.


auto_tests/version_test.c, line 18 at r3 (raw file):

{
    if (actual != expected) {
        printf("Client version %d.%d.%d is%s compatible with library version %d.%d.%d, but it should%s be\n",

this hurts readability, this should be another if

tests should be 'glance-able'


Comments from Reviewable

@iphydf
Copy link
Member

iphydf commented Dec 13, 2016

Review status: 4 of 5 files reviewed at latest revision, 4 unresolved discussions.


CMakeLists.txt, line 430 at r3 (raw file):

Previously, GrayHatter (Gregory Mullen) wrote…

move this above if(BUILD_TOXAV) and add a blank line between the must run, and optionally run

Done.


toxcore/tox.api.h, line 193 at r3 (raw file):

Previously, GrayHatter (Gregory Mullen) wrote…

tabs and not spaces?

Done.


toxcore/tox.h, line 195 at r3 (raw file):

Previously, GrayHatter (Gregory Mullen) wrote…

Comments don't belong inside a macro, around is fine.

If that's a problem, the macro is too big.

The macro is necessarily big. The logic is complicated. We can't make it smaller, because this needs to work in the preprocessor. The only way to make this smaller is by making helper macros, and those won't help maintainability.


Comments from Reviewable

@GrayHatter
Copy link

:lgtm:


Reviewed 1 of 5 files at r1, 1 of 3 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


toxcore/tox.h, line 195 at r3 (raw file):

Previously, iphydf wrote…

The macro is necessarily big. The logic is complicated. We can't make it smaller, because this needs to work in the preprocessor. The only way to make this smaller is by making helper macros, and those won't help maintainability.

That's what I was suggesting, and it's what I would have done myself.

Either way, for what it is, with a test to back it up LFTM (looks fine to me)


Comments from Reviewable

Also added some test cases for it.
@iphydf iphydf assigned robinlinden and unassigned GrayHatter Dec 13, 2016
@iphydf iphydf merged commit 3cfe554 into TokTok:master Dec 13, 2016
@robinlinden
Copy link
Member

This doesn't have any tests covering the case where a client requests a major version < TOX_VERSION_MAJOR, so that might be something we'll want to add.

@nurupo
Copy link
Member

nurupo commented Dec 14, 2016

Reviewed 1 of 5 files at r1, 3 of 3 files at r4, 1 of 1 files at r5.
Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


toxcore/tox.h, line 197 at r5 (raw file):

    /* 1.x.x, 2.x.x, etc. with matching major version. */               \
    TOX_VERSION_MINOR > MINOR ||                                        \
    TOX_VERSION_MINOR == MINOR && TOX_VERSION_PATCH >= PATCH            \

I'd add () around TOX_VERSION_MINOR == MINOR && TOX_VERSION_PATCH >= PATCH just to make it more clear (not everyone remembers order precedence of operators).


Comments from Reviewable

@nurupo nurupo mentioned this pull request Dec 14, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug fix for the user, not a fix to a build script P1 High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants