-
Notifications
You must be signed in to change notification settings - Fork 11
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 ConfigTests
tests
#85
Conversation
cluster: *mut CassCluster, | ||
contact_points: *mut *const c_char, | ||
contact_points_length: *mut size_t, | ||
contact_points_boxed: *mut *const String, |
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 probably doesn't matter, but maybe this should be *mut *mut
? We use it as *mut String
when freeing.
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.
I guess that does not have an effect on the generated code and rather is a question of documenting intent.
scylla-rust-wrapper/build.rs
Outdated
fn prepare_testing_bindings(out_path: &Path) { | ||
let testing_bindings = bindgen::Builder::default() | ||
.header("extern/testing_utils.h") | ||
.parse_callbacks(Box::new(bindgen::CargoCallbacks)) | ||
.layout_tests(true) | ||
.generate_comments(false) | ||
.generate() | ||
.expect("Unable to generate bindings"); | ||
|
||
testing_bindings | ||
.write_to_file(out_path.join("testing_bindings.rs")) | ||
.expect("Couldn't write bindings!"); | ||
} | ||
|
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.
Why are you generating those bindings? It doesn't look like your'e using them anywhere
#include "testing_utils.h" | ||
#include <stdexcept> | ||
|
||
CASS_EXPORT CassConsistency testing_get_consistency(const CassStatement* statement) { | ||
throw std::runtime_error("UNIMPLEMENTED testing_get_consistency\n"); | ||
} | ||
|
||
CASS_EXPORT CassConsistency testing_get_serial_consistency(const CassStatement* statement) { | ||
throw std::runtime_error("UNIMPLEMENTED testing_get_serial_consistency\n"); | ||
} | ||
|
||
CASS_EXPORT cass_uint64_t testing_get_request_timeout_ms(const CassStatement* statement) { | ||
throw std::runtime_error("UNIMPLEMENTED testing_get_request_timeout_ms\n"); | ||
} | ||
|
||
CASS_EXPORT const CassRetryPolicy* testing_get_retry_policy(const CassStatement* statement) { | ||
throw std::runtime_error("UNIMPLEMENTED testing_get_retry_policy\n"); | ||
} | ||
|
||
CASS_EXPORT const char* testing_get_server_name(CassFuture* future) { | ||
throw std::runtime_error("UNIMPLEMENTED testing_get_server_name\n"); | ||
} | ||
|
||
CASS_EXPORT void testing_set_record_attempted_hosts(CassStatement* statement, cass_bool_t enable) { | ||
throw std::runtime_error("UNIMPLEMENTED testing_set_record_attempted_hosts\n"); | ||
} |
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.
Why are those implementations required? Can't you just remove them from testing_utils.h?
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.
We can safely remove them, but I guess this way it will be much easier to find which testing functions are yet to be implemented.
#ifndef CPPDRIVERV2_TESTING_UTILS_H | ||
#define CPPDRIVERV2_TESTING_UTILS_H | ||
|
||
#include "cassandra.h" | ||
|
||
extern "C" { | ||
CASS_EXPORT cass_uint16_t testing_get_connect_timeout_from_cluster(CassCluster* cluster); | ||
|
||
CASS_EXPORT cass_int32_t testing_get_port_from_cluster(CassCluster* cluster); | ||
|
||
CASS_EXPORT void | ||
testing_get_contact_points_from_cluster( | ||
CassCluster* cluster, | ||
const char** contact_points, | ||
size_t* contact_points_length, | ||
void** contact_points_boxed | ||
); | ||
|
||
CASS_EXPORT void testing_free_contact_points_string(void* box); | ||
|
||
CASS_EXPORT CassConsistency testing_get_consistency(const CassStatement* statement); | ||
|
||
CASS_EXPORT CassConsistency testing_get_serial_consistency(const CassStatement* statement); | ||
|
||
CASS_EXPORT cass_uint64_t testing_get_request_timeout_ms(const CassStatement* statement); | ||
|
||
CASS_EXPORT const CassRetryPolicy* testing_get_retry_policy(const CassStatement* statement); | ||
|
||
CASS_EXPORT const char* testing_get_server_name(CassFuture* future); | ||
|
||
CASS_EXPORT void testing_set_record_attempted_hosts(CassStatement* statement, cass_bool_t enable); | ||
} | ||
|
||
#endif //CPPDRIVERV2_TESTING_UTILS_H |
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.
This file is present twice for some reason, with a slight modification. Do we need it twice in our repository?
Also, if I'm understanding this correctly, those are signatures for Rust functions that are used in implementation of testing.hpp
. If that's the case then:
- Name should be different than
testing_utils.h
- something liketesting_rust_impls.h
maybe? - This file should not be written by hand, but rather generated - cbindgen is a tool to do that
Added implementation for functions in `testing.cpp` used in `ConfigTests` tests: * get_connect_timeout_from_cluster * get_port_from_cluster * get_contact_points_from_cluster To avoid generating bindings for functions that are directly under namespaces and may return objects of custom types, `testing_utils` header is added as median between the Rust implementation of those functions and the `testing.hpp` header. Added `ConfigTests` tests to GitHub Actions for Cassandra and ScyllaDB.
Closing in favor of #163 |
Added implementation for functions in
testing.cpp
used inConfigTests
tests:To avoid generating bindings for functions that are directly under namespaces and may return objects of custom types, the
testing_utils
header is added as a median between the Rust implementation of those functions and thetesting.hpp
header.Added
ConfigTests
tests to GitHub Actions for Cassandra and ScyllaDB.Pre-review checklist
.github/workflows/build.yml
ingtest_filter
..github/workflows/cassandra.yml
ingtest_filter
.