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

Migrate listpack.c unit tests to new test framework #484

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

b1zantine
Copy link

This PR migrates all tests related to listpack.c into new test framework as part of the parent issue #428.

@b1zantine b1zantine force-pushed the listpack-unit-test branch 2 times, most recently from 2b605d6 to 35a1a2e Compare May 10, 2024 02:06
Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.80%. Comparing base (138a7d9) to head (b271ce2).
Report is 15 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #484      +/-   ##
============================================
+ Coverage     69.78%   69.80%   +0.02%     
============================================
  Files           109      109              
  Lines         61795    61795              
============================================
+ Hits          43122    43138      +16     
+ Misses        18673    18657      -16     
Files Coverage Δ
src/listpack.c 91.57% <ø> (+1.51%) ⬆️
src/server.c 88.60% <ø> (ø)

... and 16 files with indirect coverage changes

@madolson
Copy link
Member

@b1zantine Looks like the build is failing, can you double check it's working when you run:

make valkey-unit-tests

Signed-off-by: b1zantine <b1zantine.king@gmail.com>
@b1zantine
Copy link
Author

@madolson make valkey-unit-tests exits with code 0 when there are warnings. The CI workflows failed since we are passing the flag to treat warnings as errors. I have fixed the issues and verified it by running make valkey-unit-tests SERVER_CFLAGS='-Werror'. The CI workflows should succeed now.

@@ -28,6 +28,8 @@
#define KBLUE "\33[34m"
#define KRESET "\33[0m"

#define TEST(name) printf("test — %s\n", name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the new test framework, probably we can stop using this TEST which was originally used for printing different test case names.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's stop using TEST, which really should have been individual tests.

unsigned char intbuf[LP_INTBUF_SIZE];
int accurate = (flags & UNIT_TEST_ACCURATE);

TEST("Create int list") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think It would be better if we break these TEST into different test case functions. For example, something like:

int test_listpackCreateIntList(int argc, char **argv, int flags)

Similarly for other places as well, when possible.

@@ -45,98 +45,6 @@
#include "serverassert.h"
#include "util.h"

#define LP_HDR_SIZE 6 /* 32 bit total len + 16 bit number of elements. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little hesitant about exporting all this, since it complicates the header file a bit. I think I would rather use the alternative testing strategy we have, which is to #include "../listpack.c" in the test file, similar to

#include "../intset.c"
.

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.

None yet

3 participants