mirror of https://git.sr.ht/~stygianentity/bincode
Added cross platform tests workflow (#534)
* Added cross platform tests * Added all cross platforms * Fixed an issue where `usize` and `isize` would be encoded wrong on 32 bit platforms * Made the cross platform tests actually run on the platforms * Disabled cross targets that don't build right now * Fixed a failing test on 32 bit platforms, re-enabled all platforms for testing * Disabled failing platforms
This commit is contained in:
parent
36e45d26eb
commit
883278fa0c
|
|
@ -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/install@v0.1",
|
||||
"with": {
|
||||
"crate": "cross"
|
||||
},
|
||||
"name": "Install cargo cross"
|
||||
},
|
||||
{
|
||||
"run": "cross test --target ${{ matrix.platform }}",
|
||||
"name": "Run tests",
|
||||
"env": {
|
||||
"RUSTFLAGS": "-D warnings"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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()),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue