Skip to content

Commit 4bfa010

Browse files
committed
Add no_std and alloc checks to CI
1 parent 6eb142b commit 4bfa010

4 files changed

Lines changed: 70 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,29 @@ jobs:
6262
run: |
6363
cargo +nightly generate-lockfile -Z minimal-versions
6464
cd bin-proto && cargo msrv verify
65+
66+
no_std:
67+
name: Check no_std
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
- uses: dtolnay/rust-toolchain@stable
72+
with:
73+
targets: x86_64-unknown-none
74+
- uses: Swatinem/rust-cache@v2
75+
- name: Run Check
76+
run: cargo b --package tests --target x86_64-unknown-none
77+
working-directory: tests
78+
79+
alloc:
80+
name: Check alloc
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
- uses: dtolnay/rust-toolchain@stable
85+
with:
86+
targets: x86_64-unknown-none
87+
- uses: Swatinem/rust-cache@v2
88+
- name: Run Check
89+
run: cargo b --package tests --target x86_64-unknown-none --features alloc
90+
working-directory: tests

bin-proto/src/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ macro_rules! test_codec {
268268

269269
macro_rules! test_roundtrip {
270270
($ty:ty) => {
271-
#[cfg(all(test, feature = "alloc"))]
271+
#[cfg(all(test, feature = "std"))]
272272
::proptest::proptest!(
273273
#[test]
274274
fn roundtrip(x in ::proptest::arbitrary::any::<$ty>()) {

tests/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "tests"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[features]
8+
alloc = ["bin-proto/alloc"]
9+
10+
[dependencies]
11+
bin-proto = { path = "../bin-proto", default-features = false, features = ["derive", "prepend-tags"] }

tests/src/main.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![no_std]
2+
#![no_main]
3+
4+
use core::panic::PanicInfo;
5+
6+
extern crate bin_proto;
7+
8+
#[no_mangle]
9+
fn main() {}
10+
11+
#[panic_handler]
12+
fn panic(_: &PanicInfo) -> ! {
13+
loop {}
14+
}
15+
16+
#[cfg(feature = "alloc")]
17+
struct Allocator;
18+
19+
#[cfg(feature = "alloc")]
20+
unsafe impl core::alloc::GlobalAlloc for Allocator {
21+
unsafe fn alloc(&self, _: core::alloc::Layout) -> *mut u8 {
22+
unimplemented!()
23+
}
24+
25+
unsafe fn dealloc(&self, _: *mut u8, _: core::alloc::Layout) {
26+
unimplemented!()
27+
}
28+
}
29+
30+
#[cfg(feature = "alloc")]
31+
#[global_allocator]
32+
static GLOBAL: Allocator = Allocator;

0 commit comments

Comments
 (0)