Skip to content

Commit c49e96f

Browse files
authored
Merge pull request #95 from Jules-Bertholet/bench-fuzz-ci
Check benches and fuzz tests in CI
2 parents a6a221a + 2d713ab commit c49e96f

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

.github/workflows/rust.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
with:
3030
toolchain: ${{ matrix.rust }}
3131
override: true
32+
components: rustfmt, clippy
3233
- name: Build
3334
run: cargo build --verbose
3435
- name: Run tests with all features
@@ -49,7 +50,18 @@ jobs:
4950
run: cargo fmt --all --check
5051
- name: Check clippy
5152
if: matrix.rust == 'stable'
52-
run: cargo clippy --all-features --all --verbose
53+
run: cargo clippy --all-features --lib --tests --examples --verbose
54+
- name: Check benchmarks with clippy
55+
if: matrix.rust == 'nightly'
56+
run: cargo clippy --all-features --benches --verbose
57+
- name: Check fuzz tests with clippy
58+
if: matrix.rust == 'stable'
59+
working-directory: fuzz
60+
run: cargo clippy --all-features --all-targets --verbose
61+
- name: Check fuzz tests formatting
62+
if: matrix.rust == 'stable'
63+
working-directory: fuzz
64+
run: cargo fmt --all --check
5365
msrv:
5466
runs-on: ubuntu-latest
5567
steps:

benches/bench.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use std::fs;
77
use test::Bencher;
88
use unicode_normalization::UnicodeNormalization;
99

10-
const ASCII: &'static str = "all types of normalized";
11-
const NFC: &'static str = "Introducci\u{00f3}n a Unicode.pdf";
12-
const NFD: &'static str = "Introduccio\u{0301}n a Unicode.pdf";
10+
const ASCII: &str = "all types of normalized";
11+
const NFC: &str = "Introducci\u{00f3}n a Unicode.pdf";
12+
const NFD: &str = "Introduccio\u{0301}n a Unicode.pdf";
1313

1414
#[bench]
1515
fn bench_is_nfc_ascii(b: &mut Bencher) {

fuzz/fuzz_targets/streaming.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#[macro_use]
1414
extern crate libfuzzer_sys;
1515

16-
use std::str::Chars;
1716
use std::cell::RefCell;
1817
use std::rc::Rc;
18+
use std::str::Chars;
1919
use unicode_normalization::{char::canonical_combining_class, UnicodeNormalization};
2020

2121
const MAX_NONSTARTERS: u32 = 30;
@@ -43,8 +43,11 @@ impl<'a> Iterator for Counter<'a> {
4343
fuzz_target!(|input: String| {
4444
let stream_safe = input.chars().stream_safe().collect::<String>();
4545

46-
let mut value = Rc::new(RefCell::new(0));
47-
let counter = Counter { iter: stream_safe.chars(), value: Rc::clone(&mut value) };
46+
let value = Rc::new(RefCell::new(0));
47+
let counter = Counter {
48+
iter: stream_safe.chars(),
49+
value: Rc::clone(&value),
50+
};
4851
for _ in counter.nfc() {
4952
// Plus 1: The iterator may consume a starter that begins the next sequence.
5053
assert!(*value.borrow() <= MAX_NONSTARTERS + 1);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy