Skip to content

Commit

Permalink
test: reorg tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yf0μl committed Mar 1, 2024
1 parent 5f33c59 commit 6152776
Show file tree
Hide file tree
Showing 285 changed files with 2,697 additions and 2,746 deletions.
19 changes: 14 additions & 5 deletions .github/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ export INSTA_UPDATE=no
pushd borsh
cargo test --no-run
cargo test
cargo test --features unstable__schema,ascii --test test_ascii_strings
cargo test --features ascii 'roundtrip::test_ascii_strings'
cargo test --features ascii 'deserialization_errors::test_ascii_strings'
cargo test --features ascii,unstable__schema 'schema::test_ascii_strings'
cargo test --features derive
cargo test --features unstable__schema
cargo test --test test_rc --features unstable__schema,rc
cargo test --test test_hash_map --test test_btree_map --features de_strict_order
cargo test --features rc 'roundtrip::test_rc'
cargo test --features rc,unstable__schema 'schema::test_rc'
cargo test --features de_strict_order 'roundtrip::test_hash_map'
cargo test --features de_strict_order 'roundtrip::test_btree_map'
cargo test --features derive,bson 'roundtrip::test_bson_object_ids'
cargo test --features derive,bytes 'roundtrip::test_ultimate_many_features_combined'

cargo test --no-default-features
cargo test --no-default-features --features unstable__schema,ascii --test test_ascii_strings
cargo test --no-default-features --features ascii 'roundtrip::test_ascii_strings'
cargo test --no-default-features --features ascii 'deserialization_errors::test_ascii_strings'
cargo test --no-default-features --features ascii,unstable__schema 'schema::test_ascii_strings'
cargo test --no-default-features --features derive
cargo test --no-default-features --features unstable__schema
cargo test --no-default-features --test test_rc --features unstable__schema,rc
cargo test --no-default-features --features rc 'roundtrip::test_rc'
cargo test --no-default-features --features rc,unstable__schema 'schema::test_rc'
cargo test --no-default-features --features hashbrown
popd
pushd borsh-derive
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ enum A {
}
```

## Testing

Integration tests should generally be preferred to unit ones. Root module of integration tests of `borsh` crate is [linked](./borsh/tests/tests.rs) here.

## Releasing

The versions of all public crates in this repository are collectively managed by a single version in the [workspace manifest](https://github.com/near/borsh-rs/blob/master/Cargo.toml).
Expand Down
4 changes: 0 additions & 4 deletions borsh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ bytes = { version = "1", optional = true }
bson = { version = "2", optional = true }

[dev-dependencies]
bytes = "1"
bson = "2"
# Enable the "bytes" and "bson" features in integ tests: https://github.com/rust-lang/cargo/issues/2911#issuecomment-1464060655
borsh = { path = ".", default_features = false, features = ["bytes", "bson"] }
insta = "1.29.0"

[package.metadata.docs.rs]
Expand Down
8 changes: 4 additions & 4 deletions borsh/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::{
mem::size_of,
};

#[cfg(any(test, feature = "bytes"))]
#[cfg(feature = "bytes")]
use bytes::{BufMut, BytesMut};

use crate::__private::maybestd::{
Expand Down Expand Up @@ -421,7 +421,7 @@ where
}
}

#[cfg(any(test, feature = "bytes"))]
#[cfg(feature = "bytes")]
impl BorshDeserialize for bytes::Bytes {
#[inline]
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self> {
Expand All @@ -430,7 +430,7 @@ impl BorshDeserialize for bytes::Bytes {
}
}

#[cfg(any(test, feature = "bytes"))]
#[cfg(feature = "bytes")]
impl BorshDeserialize for bytes::BytesMut {
#[inline]
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self> {
Expand All @@ -443,7 +443,7 @@ impl BorshDeserialize for bytes::BytesMut {
}
}

#[cfg(any(test, feature = "bson"))]
#[cfg(feature = "bson")]
impl BorshDeserialize for bson::oid::ObjectId {
#[inline]
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self> {
Expand Down
4 changes: 2 additions & 2 deletions borsh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
This feature is set to be mutually exclusive with **std** feature.
* **bytes** -
Gates implementation of [BorshSerialize] and [BorshDeserialize]
for [Bytes](bytes::Bytes) and [BytesMut](bytes::BytesMut).
for [Bytes](https://docs.rs/bytes/1.5.0/bytes/struct.Bytes.html) and [BytesMut](https://docs.rs/bytes/1.5.0/bytes/struct.BytesMut.html).
* **bson** -
Gates implementation of [BorshSerialize] and [BorshDeserialize]
for [ObjectId](bson::oid::ObjectId).
for [ObjectId](https://docs.rs/bson/2.9.0/bson/oid/struct.ObjectId.html).
* **ascii** -
Gates implementation of [BorshSerialize], [BorshDeserialize], [BorshSchema] for
types from [ascii](https://docs.rs/ascii/1.1.0/ascii/) crate.
Expand Down
Loading

0 comments on commit 6152776

Please sign in to comment.