MOD-9985 Bindings of C types to allow Rust Unit tests for RSSortingVector#6342
MOD-9985 Bindings of C types to allow Rust Unit tests for RSSortingVector#6342
Conversation
fba6674 to
c3843f6
Compare
d3ad5e8 to
9a140bb
Compare
JonasKruckenberg
left a comment
There was a problem hiding this comment.
This is a great improvement, maybe we can find a way to simplify this even more? Cut down the size of the PR?
As a sidenote, the past tense of bind would be bound 😉 but I think we should rename the crate to something more helpful anyway 🤔
| let platform = format!("{}-{}-{}", os, arch, get_build_profile_name()); | ||
|
|
||
| let root = git_root(); | ||
| let lib_path = root |
There was a problem hiding this comment.
if we depend on the rust binding artifact in the build script we need to add it as a dependency to Cargo.toml too.
| .join("rust-binded"); | ||
|
|
||
| // check if the static library exists and quit with an error if it does not | ||
| let full_path = lib_path.join("librust_binded.a"); |
There was a problem hiding this comment.
this will not work on windows I think?
There was a problem hiding this comment.
I don't think we should be modifying the redis headers for this PR if at all possible.
There was a problem hiding this comment.
It's only a rename: For the c file it's necessary to not generate duplicate symbols (root CMakeLists used "*.c" in the src folder.
The pattern of keeping headers and c files together was used before, e.g. in wildcard. Let's stick to it.
0d9c8e3 to
2fc0440
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6342 +/- ##
==========================================
+ Coverage 88.77% 88.82% +0.05%
==========================================
Files 250 247 -3
Lines 41497 41212 -285
Branches 3632 3482 -150
==========================================
- Hits 36837 36605 -232
+ Misses 4611 4564 -47
+ Partials 49 43 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
15f2dc0 to
26a98cf
Compare
bf7f303 to
a923381
Compare
… e.g. Config and Context some free methods are using leaking variants for rust test suite
…ts which are unstable in rust
0940230 to
ca72d9c
Compare
ca72d9c to
f318a67
Compare
Closed
It was stopped because the rust coverage unit tests require many (more than 400) symbols to be defined. It’s not clear why the linker behavior changes. A speculation is that it is related to changes due to command specifics:
cargo +nightly llvm-cov test --doctests --codecov --workspace ...Initial Goal
Link
RSValueand dependencies, which is a variant data type that contains:mempool_t, sds and strdup)ToString,RSValue_StringPtrLen,compare_arrays,convert..., …)RSValue_SendReplyProblem
There was a dependency on mempool_t, which required parts of the RedisModule API.
We started by mocking those RedisModule API parts, but more unresolved symbols appeared.
The C Code is not very modular, which means that we need many symbols quickly. There are two possible solutions:
Solved Challenges
RediSearch/src/c2rust/variadic_helper.c
Line 16 in 52d9810
Open Challenges
The CI job that generates the test coverage report uses different linker settings. However, the output is not easily reproducible.
The command
./build.sh FORCE COV=1 RUN_UNIT_TESTS RUN_RUST_TESTSacts like the CI job. The problem occurs in Rust, so running./build.sh FORCE DEBUG COV=1 RUN_RUST_TESTSshould be enough.redis_mockWhen we get rid of the error-limit of the linker, we still receive over 400 symbols that need to be defined for the PR. The following code shows how to get rid of the linker error:
The line linker argument
--unresolved-symbols=ignore-allshifts the problem from build time to runtime and breaks on the first symbol that cannot be resolved.Describe the changes in the pull request
We need these changes to run Rust unit tests that use RSValue internally; more precisely, RSValue's reference-counted methods require linking to the Rust test binaries. The tests with coverage require part of the
RedisModuleAPI mocked out.RSValue)mempool_t) used byRSValuefor allocationsRSGlobalConfigandRSDummyContext)mempool_trelies on allocations with size zero. And it's safe as long as the pointers don't get dereferenced.RedisModule_TryAlloc, the reply functions, the Command API.Extracted from: #6311
Mark if applicable