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

Greatly reduce amount of generated code #1

Merged
merged 8 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Continuous integration

on:
push:
branches: [master]
pull_request:

jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: cargo test
- run: cargo test --no-default-features --tests
- run: cargo test --all-features

fuzz-tests:
name: Fuzz tests
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- run: cargo install cargo-fuzz
- run: for fuzz_test in `cargo fuzz list`; do cargo fuzz run $fuzz_test -- -max_total_time=60 -detect_leaks=0 -len_control=0 || exit 1; done

lint:
name: Rustfmt & Clippy
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
# This is a legacy codebase and clippy has a lot of complaints, disable it for now
# - run: rustup component add clippy
# - uses: actions-rs/cargo@v1
# with:
# command: clippy
# args: -- -D warnings
5 changes: 5 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ cargo-fuzz = true

[dependencies.serde_cbor]
path = ".."

[dependencies.serde_cbor_original]
git = "https://github.com/pyfisch/cbor.git"
package = "serde_cbor"

[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"

Expand Down
7 changes: 5 additions & 2 deletions fuzz/fuzz_targets/from_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ extern crate serde_cbor;
use serde_cbor::Value;

fuzz_target!(|data: &[u8]| {
let mut data = data;
let _ = serde_cbor::from_reader::<Value, _>(&mut data);
let mut data1 = data;
let mut data2 = data;
let new = serde_cbor::from_reader::<Value, _>(&mut data1).map_err(|_| ());
let original = serde_cbor_original::from_reader::<Value, _>(&mut data2).map_err(|_| ());
assert_eq!(new, original);
});
8 changes: 7 additions & 1 deletion fuzz/fuzz_targets/from_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ extern crate serde_cbor;
use serde_cbor::Value;

fuzz_target!(|data: &[u8]| {
let _ = serde_cbor::from_slice::<Value>(data);
let new = serde_cbor::from_slice::<Value>(data).map_err(|_| ());
let original = serde_cbor_original::from_slice::<Value>(data).map_err(|_| ());
assert_eq!(new, original);
assert_eq!(
new.and_then(|v| serde_cbor::to_vec(&v).map_err(|_| ())),
original.and_then(|v| serde_cbor_original::to_vec(&v).map_err(|_| ())),
);
});
Loading
Loading