Skip to content

Commit f907c79

Browse files
committed
Workaround to allow test-specific code in dependencies
1 parent 0713a3b commit f907c79

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ jobs:
5656

5757
- run:
5858
name: Run all tests
59-
command: cargo test --features experimental-api --all
59+
command: cargo test --features test,experimental-api --all-targets

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ cc = "1.0"
3636
default = []
3737
experimental-api = []
3838

39+
# Workaround to allow cfg(feature = "test") in dependencies:
40+
# https://github.com/rust-lang/rust/issues/59168#issuecomment-472653680
41+
# This requires running the tests with `--features test`
42+
test = []

build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
cargo build --features experimental-api --all --all-targets
3+

src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ impl Context {
5757
}
5858

5959
pub fn is_keys_position_request(&self) -> bool {
60-
// HACK: Used for tests, where the context is null
61-
if self.ctx.is_null() {
60+
// We want this to be available in tests where we don't have an actual Redis to call
61+
if cfg!(feature = "test") {
6262
return false;
6363
}
6464

test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
cargo test --all-targets --features test,experimental-api

0 commit comments

Comments
 (0)