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
modules: Add newlen == 0 handling to RM_StringTruncate (#3717) #3718
Conversation
Since Redis 4 was released without redis/redis#3718 this change was required to make CHOP work properly with Redis 4.0.0. Now all tests pass on stock Redis 4.0.0.
087936a
to
3e7e215
Compare
@neomantra thanks for this fix - it looks good. @antirez - please consider merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me.
3e7e215
to
b743ad0
Compare
I just rebased this branch to the latest. Any chance to make it into 5.0? |
7602dc0
to
8aed0ee
Compare
@antirez @itamarhaber I saw the Tweet about "[Refactoring...] requires a lot of care, and a lot of tests." I remembered that I had added some unmerged module test tooling in this PR and also remembered that the workflow for testing modules could use some improvement. So I put some effort into this last commit 9c7f3d7 ( If you like this and would prefer it on its own branch (without the StringTruncate bugfix), I can do that. |
Previously, passing 0 for newlen would not truncate the string at all. This adds handling of this case, freeing the old string and creating a new empty string.
…XXXReply functions * adds TEST.STRING.TRUNCATE and includes it in TEST.IT This test fails unless issue redis#3717 is resolved * add handling for ERROR replies in TestAssertStringReply and TestAssertIntegerReply Previously these TestAssert functions would output something like, `<test> Unexpected reply type 1` rather than emitting the error message of what was wrong.
* add `test-module` make target * `make distclean` now cleans module src/test directories * `runtest-moduleapi` now builds and exercises `testmodule` * add `clean` target for `commandfilter` * add `.gitignore` for `commandfilter` * typo "SOME TEST NOT PASSED!" -> "SOME TEST DID NOT PASS!"
9c7f3d7
to
595b272
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge?
If I take the time to rebase this, will you actually merge it? I've rebased it 4 times already over 5 years -- it is an obvious bug in a public modules interface. |
This one must have been forgotten. @redis/core-team anyone have a look? |
Oh sad, it was forgotten. @neomantra Would you mind doing a rebase of the code. I looked through the code and thumbs'd up a couple of other comments that still weren't addressed. Sorry for dropping this! |
…wLenZero Conflicts: runtest-moduleapi src/Makefile tests/modules/Makefile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
- Introduce a new sdssubstr api as a building block for sdsrange. The API of sdsrange is many times hard to work with and also has corner case that cause bugs. sdsrange is easy to work with and also simplifies the implementation of sdsrange. - Revert the fix to RM_StringTruncate and just use sdssubstr instead of sdsrange. - Solve valgrind warnings from the new tests introduced by the previous PR.
This is not the first time i see the bad API of |
- Introduce a new sdssubstr api as a building block for sdsrange. The API of sdsrange is many times hard to work with and also has corner case that cause bugs. sdsrange is easy to work with and also simplifies the implementation of sdsrange. - Revert the fix to RM_StringTruncate and just use sdssubstr instead of sdsrange. - Solve valgrind warnings from the new tests introduced by the previous PR.
…edis#3718) Previously, passing 0 for newlen would not truncate the string at all. This adds handling of this case, freeing the old string and creating a new empty string. Other changes: - Move `src/modules/testmodule.c` to `tests/modules/basics.c` - Introduce that basic test into the test suite - Add tests to cover StringTruncate - Add `test-modules` build target for the main makefile - Extend `distclean` build target to clean modules too
- Introduce a new sdssubstr api as a building block for sdsrange. The API of sdsrange is many times hard to work with and also has corner case that cause bugs. sdsrange is easy to work with and also simplifies the implementation of sdsrange. - Revert the fix to RM_StringTruncate and just use sdssubstr instead of sdsrange. - Solve valgrind warnings from the new tests introduced by the previous PR.
src/modules make failed. As in #3718 testmodule.c was removed. But the makefile was not updated
…edis#3718) Previously, passing 0 for newlen would not truncate the string at all. This adds handling of this case, freeing the old string and creating a new empty string. Other changes: - Move `src/modules/testmodule.c` to `tests/modules/basics.c` - Introduce that basic test into the test suite - Add tests to cover StringTruncate - Add `test-modules` build target for the main makefile - Extend `distclean` build target to clean modules too (cherry picked from commit 1ccf2ca)
- Introduce a new sdssubstr api as a building block for sdsrange. The API of sdsrange is many times hard to work with and also has corner case that cause bugs. sdsrange is easy to work with and also simplifies the implementation of sdsrange. - Revert the fix to RM_StringTruncate and just use sdssubstr instead of sdsrange. - Solve valgrind warnings from the new tests introduced by the previous PR. (cherry picked from commit ae418ec)
src/modules make failed. As in redis#3718 testmodule.c was removed. But the makefile was not updated (cherry picked from commit d54c908)
Previously, passing 0 for newlen would not truncate the string at all. This adds handling of this case, freeing the old string and creating a new empty string. Other changes: - Move `src/modules/testmodule.c` to `tests/modules/basics.c` - Introduce that basic test into the test suite - Add tests to cover StringTruncate - Add `test-modules` build target for the main makefile - Extend `distclean` build target to clean modules too (cherry picked from commit 1ccf2ca)
- Introduce a new sdssubstr api as a building block for sdsrange. The API of sdsrange is many times hard to work with and also has corner case that cause bugs. sdsrange is easy to work with and also simplifies the implementation of sdsrange. - Revert the fix to RM_StringTruncate and just use sdssubstr instead of sdsrange. - Solve valgrind warnings from the new tests introduced by the previous PR. (cherry picked from commit ae418ec)
…edis#3718) Previously, passing 0 for newlen would not truncate the string at all. This adds handling of this case, freeing the old string and creating a new empty string. Other changes: - Move `src/modules/testmodule.c` to `tests/modules/basics.c` - Introduce that basic test into the test suite - Add tests to cover StringTruncate - Add `test-modules` build target for the main makefile - Extend `distclean` build target to clean modules too
- Introduce a new sdssubstr api as a building block for sdsrange. The API of sdsrange is many times hard to work with and also has corner case that cause bugs. sdsrange is easy to work with and also simplifies the implementation of sdsrange. - Revert the fix to RM_StringTruncate and just use sdssubstr instead of sdsrange. - Solve valgrind warnings from the new tests introduced by the previous PR.
src/modules make failed. As in redis#3718 testmodule.c was removed. But the makefile was not updated
Previously, passing 0 for newlen would not truncate the string at all.
This adds handling of this case, freeing the old string and creating a new empty string.
Other changes:
src/modules/testmodule.c
totests/modules/basics.c
test-modules
build target for the main makefiledistclean
build target to clean modules too