diff --git a/.github/workflows/bencher.yml b/.github/workflows/bencher.yml
index 51d41ded..3c44eea0 100644
--- a/.github/workflows/bencher.yml
+++ b/.github/workflows/bencher.yml
@@ -31,7 +31,6 @@ jobs:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_CMD: cargo bench --all-features
BENCHER_PROJECT: socketioxide
- RUSTFLAGS: --cfg=socketioxide_test
benchmark_pr:
if: github.event_name == 'workflow_dispatch' && github.event.pull_request.head.repo.full_name == github.repository
@@ -62,4 +61,3 @@ jobs:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_CMD: cargo bench --all-features
BENCHER_PROJECT: socketioxide
- RUSTFLAGS: --cfg=socketioxide_test
\ No newline at end of file
diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml
index b2cf7f00..7d295d73 100644
--- a/.github/workflows/github-ci.yml
+++ b/.github/workflows/github-ci.yml
@@ -18,8 +18,6 @@ jobs:
toolchain: stable
components: rustfmt
- run: cargo fmt --all -- --check
- env:
- RUSTFLAGS: --cfg=socketioxide_test
test:
runs-on: ubuntu-latest
@@ -39,8 +37,6 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: cargo test --tests --all-features --workspace
- env:
- RUSTFLAGS: --cfg=socketioxide_test
udeps:
runs-on: ubuntu-latest
steps:
@@ -90,8 +86,6 @@ jobs:
- name: check crates
run: cargo check -p socketioxide -p engineioxide --all-features
- env:
- RUSTFLAGS: --cfg=socketioxide_test
feature_set:
runs-on: ubuntu-latest
@@ -188,8 +182,6 @@ jobs:
--tests
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
continue-on-error: true
- env:
- RUSTFLAGS: --cfg=socketioxide_test
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4d9068f1..01a23ed8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -16,7 +16,7 @@ today! As a contributor, here are the guidelines we would like you to follow:
## Got a Question or Problem?
-Please open a discussion on the [Q&A discussions](https://github.com/totodore/socketioxide/discussions) page.
+Please open a discussion on the [Q&A discussions](https://github.com/totodore/socketioxide/discussions) page.
We want to keep GitHub Issues for bugs and feature requests. If you open an issue it will be moved to Discussions.
## Found a Bug?
@@ -139,11 +139,6 @@ You will need [rustc and cargo](www.rust-lang.org/tools/install).
```shell
git clone https://github.com/totodore/socketioxide
```
-2. To test socketioxide don't forget to enable the flag `socketioxide_test` through the `RUSTFLAGS` environment variable:
-
- ```shell
- export RUSTFLAGS="--cfg socketioxide_test"
- ```
2. Depending on what you want to change, clone the [socketio/engine.io-protocol](https://github.com/socketio/engine.io-protocol) repo or the [socketio/socket.io-protocol](https://github.com/socketio/socket.io-protocol) repo or both
```shell
git clone https://github.com/socketio/engine.io-protocol
@@ -261,4 +256,4 @@ The subject contains succinct description of the change:
### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
-The body should include the motivation for the change and contrast this with previous behavior.
\ No newline at end of file
+The body should include the motivation for the change and contrast this with previous behavior.
diff --git a/engineioxide/Cargo.toml b/engineioxide/Cargo.toml
index 41ba0341..dde3f270 100644
--- a/engineioxide/Cargo.toml
+++ b/engineioxide/Cargo.toml
@@ -58,6 +58,7 @@ hyper-util = { workspace = true, features = ["tokio", "client-legacy"] }
[features]
v3 = ["memchr", "unicode-segmentation", "itoa"]
tracing = ["dep:tracing"]
+__test_harness = []
[[bench]]
name = "packet_encode"
diff --git a/engineioxide/src/lib.rs b/engineioxide/src/lib.rs
index 14777b7a..142435cf 100644
--- a/engineioxide/src/lib.rs
+++ b/engineioxide/src/lib.rs
@@ -36,7 +36,8 @@ pub use crate::str::Str;
pub use service::{ProtocolVersion, TransportType};
pub use socket::{DisconnectReason, Socket};
-#[cfg(any(test, socketioxide_test))]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
pub use packet::*;
pub mod config;
diff --git a/engineioxide/src/socket.rs b/engineioxide/src/socket.rs
index 430d8fa8..a1dd24e9 100644
--- a/engineioxide/src/socket.rs
+++ b/engineioxide/src/socket.rs
@@ -481,7 +481,8 @@ impl std::fmt::Debug for Socket {
}
}
-#[cfg(socketioxide_test)]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
impl Drop for Socket
where
D: Default + Send + Sync + 'static,
@@ -492,7 +493,8 @@ where
}
}
-#[cfg(any(socketioxide_test, test))]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
impl Socket
where
D: Default + Send + Sync + 'static,
diff --git a/socketioxide/Cargo.toml b/socketioxide/Cargo.toml
index 4b5c988c..6763bed2 100644
--- a/socketioxide/Cargo.toml
+++ b/socketioxide/Cargo.toml
@@ -42,6 +42,7 @@ v4 = ["engineioxide/v3"]
tracing = ["dep:tracing", "engineioxide/tracing"]
extensions = []
state = ["dep:state"]
+__test_harness = ["engineioxide/__test_harness"]
[dev-dependencies]
engineioxide = { path = "../engineioxide", features = ["v3", "tracing"] }
diff --git a/socketioxide/src/client.rs b/socketioxide/src/client.rs
index d69d313d..a430f662 100644
--- a/socketioxide/src/client.rs
+++ b/socketioxide/src/client.rs
@@ -16,7 +16,7 @@ use tokio::sync::oneshot;
use crate::adapter::Adapter;
use crate::handler::ConnectHandler;
use crate::ns::NamespaceCtr;
-use crate::parser::{self, CommonParser, Parse, Parser, TransportPayload};
+use crate::parser::{self, Parse, Parser, TransportPayload};
use crate::socket::DisconnectReason;
use crate::{
errors::Error,
@@ -349,7 +349,8 @@ impl std::fmt::Debug for Client {
}
}
-#[cfg(socketioxide_test)]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
impl Client {
pub async fn new_dummy_sock(
self: Arc,
@@ -387,7 +388,7 @@ impl Client {
}
}
});
- let (p, _) = CommonParser::default().serialize(Packet {
+ let (p, _) = parser::CommonParser::default().serialize(Packet {
ns: ns.into(),
inner: PacketData::Connect(Some(serde_json::to_value(&auth).unwrap())),
});
diff --git a/socketioxide/src/io.rs b/socketioxide/src/io.rs
index d133f801..3250d17c 100644
--- a/socketioxide/src/io.rs
+++ b/socketioxide/src/io.rs
@@ -905,7 +905,8 @@ impl From>> for SocketIo {
}
}
-#[cfg(any(test, socketioxide_test))]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
impl SocketIo {
/// Create a dummy socket for testing purpose with a
/// receiver to get the packets sent to the client
diff --git a/socketioxide/src/ns.rs b/socketioxide/src/ns.rs
index 365588fa..c4c4fec8 100644
--- a/socketioxide/src/ns.rs
+++ b/socketioxide/src/ns.rs
@@ -183,7 +183,8 @@ impl Namespace {
}
}
-#[cfg(any(test, socketioxide_test))]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
impl Namespace {
pub fn new_dummy(sockets: [Sid; S]) -> Arc {
let ns = Namespace::new("/".into(), || {});
diff --git a/socketioxide/src/socket.rs b/socketioxide/src/socket.rs
index ee6ecbe9..311b4d21 100644
--- a/socketioxide/src/socket.rs
+++ b/socketioxide/src/socket.rs
@@ -820,7 +820,8 @@ impl PartialEq for Socket {
}
}
-#[cfg(any(test, socketioxide_test))]
+#[doc(hidden)]
+#[cfg(feature = "__test_harness")]
impl Socket {
/// Creates a dummy socket for testing purposes
pub fn new_dummy(sid: Sid, ns: Arc>) -> Socket {