Skip to content
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

Added cross platform tests workflow #534

Merged
merged 8 commits into from
Apr 4, 2022
79 changes: 79 additions & 0 deletions .github/workflows/cross_platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "Cross platform tests",
"on": {
"push": {
"branches": [
"trunk",
"v*.x",
"ci/*"
]
},
"pull_request": {
"branches": [
"trunk",
"v*.x"
]
}
},
"jobs": {
"check": {
"name": "Test",
"runs-on": "ubuntu-latest",
"strategy": {
"fail-fast": false,
"matrix": {
"platform": [
"aarch64-unknown-linux-gnu",
"arm-unknown-linux-gnueabi",
"arm-unknown-linux-gnueabihf",
# "armv5te-unknown-linux-gnueabi",
"armv7-unknown-linux-gnueabihf",
"i586-unknown-linux-gnu",
# "i686-pc-windows-gnu",
"i686-unknown-linux-gnu",
# "mips-unknown-linux-gnu",
"mips64-unknown-linux-gnuabi64",
"mips64el-unknown-linux-gnuabi64",
# "mipsel-unknown-linux-gnu",
# "powerpc-unknown-linux-gnu",
# "powerpc64-unknown-linux-gnu",
# "powerpc64le-unknown-linux-gnu",
"riscv64gc-unknown-linux-gnu",
# "sparc64-unknown-linux-gnu",
"x86_64-pc-windows-gnu",
"x86_64-unknown-linux-gnu"
]
}
},
"steps": [
{
"uses": "actions/checkout@v2",
"name": "Checkout"
},
{
"uses": "actions-rs/toolchain@v1",
"with": {
"profile": "minimal",
"toolchain": "stable",
"override": true
},
"name": "Install Rust stable"
},
{
"uses": "actions-rs/[email protected]",
"with": {
"crate": "cross"
},
"name": "Install cargo cross"
},
{
"run": "cross test --target ${{ matrix.platform }}",
"name": "Run tests",
"env": {
"RUSTFLAGS": "-D warnings"
}
}
]
}
}
}
8 changes: 4 additions & 4 deletions src/enc/impls.rs
Original file line number Diff line number Diff line change
@@ -134,8 +134,8 @@ impl Encode for usize {
crate::varint::varint_encode_usize(encoder.writer(), E::C::ENDIAN, *self)
}
IntEncoding::Fixed => match E::C::ENDIAN {
Endian::Big => encoder.writer().write(&self.to_be_bytes()),
Endian::Little => encoder.writer().write(&self.to_le_bytes()),
Endian::Big => encoder.writer().write(&(*self as u64).to_be_bytes()),
Endian::Little => encoder.writer().write(&(*self as u64).to_le_bytes()),
},
}
}
@@ -246,8 +246,8 @@ impl Encode for isize {
crate::varint::varint_encode_isize(encoder.writer(), E::C::ENDIAN, *self)
}
IntEncoding::Fixed => match E::C::ENDIAN {
Endian::Big => encoder.writer().write(&self.to_be_bytes()),
Endian::Little => encoder.writer().write(&self.to_le_bytes()),
Endian::Big => encoder.writer().write(&(*self as i64).to_be_bytes()),
Endian::Little => encoder.writer().write(&(*self as i64).to_le_bytes()),
},
}
}
8 changes: 7 additions & 1 deletion tests/alloc.rs
Original file line number Diff line number Diff line change
@@ -115,7 +115,13 @@ fn test_container_limits() {
bincode::config::standard().with_limit::<DECODE_LIMIT>(),
);

assert_eq!(result.unwrap_err(), DecodeError::LimitExceeded);
let name = core::any::type_name::<T>();
match result {
Ok(_) => panic!("Decoding {} should fail, it instead succeeded", name),
Err(DecodeError::OutsideUsizeRange(_)) if cfg!(target_pointer_width = "32") => {},
Err(DecodeError::LimitExceeded) => {},
Err(e) => panic!("Expected OutsideUsizeRange (on 32 bit platforms) or LimitExceeded whilst decoding {}, got {:?}", name, e),
}
}

for slice in test_cases {