diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddce40d9..ff0d3e24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: strategy: fail-fast: false matrix: - msrv: ['1.54.0'] + msrv: ['1.56.0'] crate: - cucumber-codegen - cucumber diff --git a/Cargo.toml b/Cargo.toml index dfed1d3e..c8be9b4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "cucumber" version = "0.10.0" -edition = "2018" -resolver = "2" +edition = "2021" +rust-version = "1.56" description = """\ Cucumber testing framework for Rust, with async support. \ Fully native, no external test runners or dependencies.\ diff --git a/README.md b/README.md index a3ac56b6..592a20f6 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Cucumber testing framework for Rust [![Documentation](https://docs.rs/cucumber/badge.svg)](https://docs.rs/cucumber) [![Actions Status](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg)](https://github.com/cucumber-rs/cucumber/actions) -[![Rust 1.54+](https://img.shields.io/badge/rustc-1.54+-lightgray.svg "Rust 1.54+")](https://blog.rust-lang.org/2021/07/29/Rust-1.54.0.html) -[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/) +[![Rust 1.56+](https://img.shields.io/badge/rustc-1.56+-lightgray.svg "Rust 1.56+")](https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html) +[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance) An implementation of the [Cucumber] testing framework for Rust. Fully native, no external test runners or dependencies. diff --git a/book/tests/Cargo.toml b/book/tests/Cargo.toml index b9a1f3b4..60c7ce3a 100644 --- a/book/tests/Cargo.toml +++ b/book/tests/Cargo.toml @@ -1,8 +1,7 @@ [package] name = "cucumber-book-tests" version = "0.0.0" -edition = "2018" -resolver = "2" +edition = "2021" authors = [ "Brendan Molloy ", "Ilya Solovyiov ", diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index a27c851d..424a53a0 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "cucumber-codegen" version = "0.10.0" # should be the same as main crate version -edition = "2018" -resolver = "2" +edition = "2021" +rust-version = "1.56" description = "Code generation for `cucumber` crate." license = "MIT OR Apache-2.0" authors = [ diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 2f8f4dcc..ae2975ac 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -93,11 +93,13 @@ variant_size_differences )] +use proc_macro::TokenStream; + mod attribute; mod derive; -use proc_macro::TokenStream; - +/// Helper macro for generating public shims for [`macro@given`], [`macro@when`] +/// and [`macro@then`] attributes. macro_rules! step_attribute { ($name:ident) => { /// Attribute to auto-wire the test to the [`World`] implementer. @@ -195,6 +197,9 @@ macro_rules! step_attribute { }; } +/// Helper macro for generating public shim of [`macro@WorldInit`] deriving +/// macro consistently with the ones of [`macro@given`], [`macro@when`] and +/// [`macro@then`] attributes. macro_rules! steps { ($($name:ident),*) => { /// Derive macro for tests auto-wiring. diff --git a/src/codegen.rs b/src/codegen.rs index cafda329..f5310c66 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -13,16 +13,14 @@ use std::{fmt::Debug, path::Path}; use async_trait::async_trait; - -use crate::{cucumber::DefaultCucumber, step, Cucumber, Step, World}; - pub use futures::future::LocalBoxFuture; pub use inventory::{self, collect, submit}; pub use regex::Regex; +use crate::{Cucumber, cucumber::DefaultCucumber, step, Step, World}; + /// [`World`] extension with auto-wiring capabilities. #[async_trait(?Send)] -#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] pub trait WorldInit: WorldInventory where Self: Debug, @@ -124,7 +122,6 @@ where } /// [`World`] extension allowing to register steps in [`inventory`]. -#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] pub trait WorldInventory: World where G: StepConstructor + inventory::Collect, @@ -186,7 +183,6 @@ where /// [`given`]: crate::given /// [`when`]: crate::when /// [`then`]: crate::then -#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] pub trait StepConstructor { /// Creates a new [`Step`] with the corresponding [`Regex`]. #[must_use] diff --git a/src/event.rs b/src/event.rs index 77224791..60aecb1d 100644 --- a/src/event.rs +++ b/src/event.rs @@ -104,15 +104,15 @@ impl Cucumber { scenario: Arc, event: Scenario, ) -> Self { - #[allow(clippy::option_if_let_else)] // use of moved value: `event` - if let Some(r) = rule { - Self::Feature( - feat, - Feature::Rule(r, Rule::Scenario(scenario, event)), - ) - } else { - Self::Feature(feat, Feature::Scenario(scenario, event)) - } + Self::Feature( + feat, + #[allow(clippy::option_if_let_else)] // use of moved value: `event` + if let Some(r) = rule { + Feature::Rule(r, Rule::Scenario(scenario, event)) + } else { + Feature::Scenario(scenario, event) + }, + ) } } diff --git a/src/lib.rs b/src/lib.rs index a01dbf69..0464e107 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,31 +97,12 @@ )] #![cfg_attr(docsrs, feature(doc_cfg))] -pub mod cli; -mod cucumber; -pub mod event; -pub mod feature; -pub mod parser; -pub mod runner; -pub mod step; -pub mod writer; - -#[cfg(feature = "macros")] -#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] -pub mod codegen; - use std::error::Error as StdError; use async_trait::async_trait; - pub use gherkin; #[cfg(feature = "macros")] -#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] -#[doc(inline)] -pub use self::codegen::WorldInit; -#[cfg(feature = "macros")] -#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] #[doc(inline)] pub use cucumber_codegen::{given, then, when, WorldInit}; @@ -136,6 +117,21 @@ pub use self::{ Failure as FailureWriter, Writer, }, }; +#[cfg(feature = "macros")] +#[doc(inline)] +pub use self::codegen::WorldInit; + +pub mod cli; +mod cucumber; +pub mod event; +pub mod feature; +pub mod parser; +pub mod runner; +pub mod step; +pub mod writer; + +#[cfg(feature = "macros")] +pub mod codegen; /// Represents a shared user-defined state for a [Cucumber] run. /// It lives on per-[scenario][0] basis.