diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000..1179ab2 --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,26 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Run tests + run: cargo test --verbose --all-features --workspace --tests --bins --lib + - name: Run doctests + run: cargo test --verbose --all-features --workspace --doc diff --git a/Cargo.toml b/Cargo.toml index 7825b38..3f947ff 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,5 +9,10 @@ readme = "README.md" repository = "https://github.com/D0A1V2I3D/binf" documentation = "https://docs.rs/binf/" +[workspace] +members = [ + "macros" +] + [dependencies] -binf_macros = { path = "macros", version = "1.0.1" } +binf_macros = { version = "1.0.1" } diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 3ed525e..219df67 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -3,7 +3,9 @@ use proc_macro::TokenStream; /// Attribute proc macro that turns a struct into a bitflag /// The underlying type of the bitflag is chosen based on the number of fields in the struct /// usage: -/// ```rust +/// ```ignore +/// use binf::bitflag; +/// /// #[bitflag] /// pub struct MyBitflag { /// a: bool, diff --git a/src/lib.rs b/src/lib.rs index 23e288c..fc38d3b 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,8 +4,6 @@ This crate aims to make working with binary/bit flags easier. It also provides a */ pub use binf_macros::*; -#[cfg(test)] -mod tests; /// A trait for types that can be used as bit flags. pub trait BitFlag { diff --git a/src/tests.rs b/tests/tests.rs similarity index 96% rename from src/tests.rs rename to tests/tests.rs index 031fe57..9b0d9ac 100644 --- a/src/tests.rs +++ b/tests/tests.rs @@ -1,4 +1,5 @@ -use crate::*; +use binf::*; +use binf_macros::*; #[bitflag] pub struct Test { @@ -14,7 +15,7 @@ pub struct Test { #[test] fn macro_test() { - let mut test = Test::new(0b10101010); + let test = Test::new(0b10101010); assert_eq!(test.a(), false); assert_eq!(test.b(), true); assert_eq!(test.c(), false);