diff --git a/.github/workflows/rustbench.yml b/.github/workflows/rustbench.yml index ce5565ab..52c3112b 100644 --- a/.github/workflows/rustbench.yml +++ b/.github/workflows/rustbench.yml @@ -29,7 +29,7 @@ jobs: version: latest - name: Run Benchmarks on changes - run: cargo bench --bench bench -- --save-baseline changes + run: cargo bench --workspace --benches -- --save-baseline changes - uses: actions/checkout@v4 with: @@ -37,7 +37,7 @@ jobs: clean: false - name: Run Benchmarks before changes - run: cargo bench --bench bench -- --save-baseline before + run: cargo bench --workspace --benches -- --save-baseline before - name: Compare benchmarks run: | diff --git a/.github/workflows/rustlib.yml b/.github/workflows/rustlib.yml index efffa7e5..4152f2d5 100644 --- a/.github/workflows/rustlib.yml +++ b/.github/workflows/rustlib.yml @@ -42,18 +42,14 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - override: true - components: rustfmt + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@stable - name: Cache dependencies uses: Swatinem/rust-cache@v2 - - name: Check that code compiles + - name: Check that tests run uses: actions-rs/cargo@v1 with: command: test - args: --verbose + args: --workspace --verbose diff --git a/.github/workflows/rustmsrv.yml b/.github/workflows/rustmsrv.yml index 404a51d3..4f7a6e37 100644 --- a/.github/workflows/rustmsrv.yml +++ b/.github/workflows/rustmsrv.yml @@ -24,4 +24,4 @@ jobs: version: ^0.15.1 - name: Check MSRV - run: cd logos && cargo msrv verify -- cargo check --all-features + run: cd logos && cargo msrv verify -- cargo check --workspace --all-features diff --git a/Cargo.toml b/Cargo.toml index e383943f..ebfc062d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,10 @@ all-features = true cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] rustdoc-args = ["--cfg", "docsrs"] +[package.metadata.release] +shared-version = true +tag-name = "v{{version}}" + [profile] bench = {lto = true} release = {lto = true} diff --git a/book/src/contributing/setup.md b/book/src/contributing/setup.md index c8fa1cde..15a574e3 100644 --- a/book/src/contributing/setup.md +++ b/book/src/contributing/setup.md @@ -30,7 +30,7 @@ Finally, launch a terminal (i.e., command-line) session and go to the A good way to see if you code can compile is to use the eponym command: ```bash -cargo check +cargo check --worspace ``` ## Formatting and linting your code @@ -57,7 +57,13 @@ A code that compiles isn't necessarily correct, and testing it against known cases is of good practice: ```bash -cargo test +cargo test --workspace +``` + +You can also run benchmarks: + +```bash +cargo bench --workspace --benches ``` ## Building the documentation diff --git a/logos-cli/tests/data/output.rs b/logos-cli/tests/data/output.rs index 181dc489..4d273229 100644 --- a/logos-cli/tests/data/output.rs +++ b/logos-cli/tests/data/output.rs @@ -1 +1 @@ -# [derive (Debug , Clone , Copy , PartialEq)] enum Token { Letter , }impl < 's > :: logos :: Logos < 's > for Token { type Error = () ; type Extras = () ; type Source = str ; fn lex (lex : & mut :: logos :: Lexer < 's , Self >) { use :: logos :: internal :: { LexerInternal , CallbackResult } ; type Lexer < 's > = :: logos :: Lexer < 's , Token > ; fn _end < 's > (lex : & mut Lexer < 's >) { lex . end () } fn _error < 's > (lex : & mut Lexer < 's >) { lex . bump_unchecked (1) ; lex . error () ; } macro_rules ! _fast_loop { ($ lex : ident , $ test : ident , $ miss : expr) => { while let Some (arr) = $ lex . read :: < & [u8 ; 16] > () { if $ test (arr [0]) { if $ test (arr [1]) { if $ test (arr [2]) { if $ test (arr [3]) { if $ test (arr [4]) { if $ test (arr [5]) { if $ test (arr [6]) { if $ test (arr [7]) { if $ test (arr [8]) { if $ test (arr [9]) { if $ test (arr [10]) { if $ test (arr [11]) { if $ test (arr [12]) { if $ test (arr [13]) { if $ test (arr [14]) { if $ test (arr [15]) { $ lex . bump_unchecked (16) ; continue ; } $ lex . bump_unchecked (15) ; return $ miss ; } $ lex . bump_unchecked (14) ; return $ miss ; } $ lex . bump_unchecked (13) ; return $ miss ; } $ lex . bump_unchecked (12) ; return $ miss ; } $ lex . bump_unchecked (11) ; return $ miss ; } $ lex . bump_unchecked (10) ; return $ miss ; } $ lex . bump_unchecked (9) ; return $ miss ; } $ lex . bump_unchecked (8) ; return $ miss ; } $ lex . bump_unchecked (7) ; return $ miss ; } $ lex . bump_unchecked (6) ; return $ miss ; } $ lex . bump_unchecked (5) ; return $ miss ; } $ lex . bump_unchecked (4) ; return $ miss ; } $ lex . bump_unchecked (3) ; return $ miss ; } $ lex . bump_unchecked (2) ; return $ miss ; } $ lex . bump_unchecked (1) ; return $ miss ; } return $ miss ; } while $ lex . test ($ test) { $ lex . bump_unchecked (1) ; } $ miss } ; } # [inline] fn goto1_x < 's > (lex : & mut Lexer < 's >) { lex . set (Ok (Token :: Letter)) ; } # [inline] fn goto3_at1_with3 < 's > (lex : & mut Lexer < 's >) { match lex . read_at :: < & [u8 ; 2usize] > (1usize) { Some (b"-z") => { lex . bump_unchecked (3usize) ; goto1_x (lex) } , _ => _error (lex) , } } # [inline] fn goto4 < 's > (lex : & mut Lexer < 's >) { let arr = match lex . read :: < & [u8 ; 3usize] > () { Some (arr) => arr , None => return _end (lex) , } ; match arr [0] { b'a' => goto3_at1_with3 (lex) , _ => _error (lex) , } } goto4 (lex) } } +# [derive (Debug , Clone , Copy , PartialEq)] enum Token { Letter , }impl < 's > :: logos :: Logos < 's > for Token { type Error = () ; type Extras = () ; type Source = str ; fn lex (lex : & mut :: logos :: Lexer < 's , Self >) { use :: logos :: internal :: { LexerInternal , CallbackResult } ; type Lexer < 's > = :: logos :: Lexer < 's , Token > ; fn _end < 's > (lex : & mut Lexer < 's >) { lex . end () } fn _error < 's > (lex : & mut Lexer < 's >) { lex . bump_unchecked (1) ; lex . error () ; } macro_rules ! _fast_loop { ($ lex : ident , $ test : ident , $ miss : expr) => { while let Some (arr) = $ lex . read :: < & [u8 ; 16] > () { if $ test (arr [0]) { if $ test (arr [1]) { if $ test (arr [2]) { if $ test (arr [3]) { if $ test (arr [4]) { if $ test (arr [5]) { if $ test (arr [6]) { if $ test (arr [7]) { if $ test (arr [8]) { if $ test (arr [9]) { if $ test (arr [10]) { if $ test (arr [11]) { if $ test (arr [12]) { if $ test (arr [13]) { if $ test (arr [14]) { if $ test (arr [15]) { $ lex . bump_unchecked (16) ; continue ; } $ lex . bump_unchecked (15) ; return $ miss ; } $ lex . bump_unchecked (14) ; return $ miss ; } $ lex . bump_unchecked (13) ; return $ miss ; } $ lex . bump_unchecked (12) ; return $ miss ; } $ lex . bump_unchecked (11) ; return $ miss ; } $ lex . bump_unchecked (10) ; return $ miss ; } $ lex . bump_unchecked (9) ; return $ miss ; } $ lex . bump_unchecked (8) ; return $ miss ; } $ lex . bump_unchecked (7) ; return $ miss ; } $ lex . bump_unchecked (6) ; return $ miss ; } $ lex . bump_unchecked (5) ; return $ miss ; } $ lex . bump_unchecked (4) ; return $ miss ; } $ lex . bump_unchecked (3) ; return $ miss ; } $ lex . bump_unchecked (2) ; return $ miss ; } $ lex . bump_unchecked (1) ; return $ miss ; } return $ miss ; } while $ lex . test ($ test) { $ lex . bump_unchecked (1) ; } $ miss } ; } # [inline] fn goto1_x < 's > (lex : & mut Lexer < 's >) { lex . set (Ok (Token :: Letter)) ; } # [inline] fn goto3_at1_with3 < 's > (lex : & mut Lexer < 's >) { match lex . read_at :: < & [u8 ; 2usize] > (1usize) { Some (b"-z") => { lex . bump_unchecked (3usize) ; goto1_x (lex) } , _ => _error (lex) , } } # [inline] fn goto4 < 's > (lex : & mut Lexer < 's >) { let arr = match lex . read :: < & [u8 ; 3usize] > () { Some (arr) => arr , None => return _end (lex) , } ; match arr [0] { b'a' => goto3_at1_with3 (lex) , _ => _error (lex) , } } goto4 (lex) } } \ No newline at end of file diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 8aaedc88..db51cc9a 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -1,6 +1,8 @@ -[[bench]] -harness = false -name = "bench" +[package] +edition.workspace = true +name = "tests" +publish = false +version = "0.1.0" [dependencies] logos-derive2 = {path = "../logos-derive"} @@ -9,7 +11,6 @@ logos2 = {path = "../", default-features = false, features = ["std"]} [dev-dependencies] criterion = "0.4" -[package] -name = "tests" -publish = false -version = "0.0.0" +[[bench]] +harness = false +name = "bench" diff --git a/tests/src/lib.rs b/tests/src/lib.rs index ece50f68..76d35308 100644 --- a/tests/src/lib.rs +++ b/tests/src/lib.rs @@ -77,7 +77,6 @@ //! //! } //! ``` - use logos::source::Source; use logos::Logos;