Skip to content

Commit

Permalink
Tune up Cargo features according to 1.60 Rust and bump up MSRV
Browse files Browse the repository at this point in the history
Additionally:
- tune lints for 1.60 Rust
  • Loading branch information
tyranron committed Apr 8, 2022
1 parent b8eb6b1 commit fbd08ec
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ['1.57.0']
msrv: ["1.60.0"]
crate:
- cucumber-codegen
- cucumber
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ All user visible changes to `cucumber` crate will be documented in this file. Th



## [0.14.0] · 2022-??-?? (unreleased)
[0.14.0]: /../../tree/v0.14.0

[Diff](/../../compare/v0.13.0...v0.14.0) | [Milestone](/../../milestone/13)

### BC Breaks

- Bump up [MSRV] to 1.60 for more clever support of [Cargo feature]s.




## [0.13.0] · 2022-03-29
[0.13.0]: /../../tree/v0.13.0

Expand Down Expand Up @@ -416,6 +428,7 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
[`gherkin`]: https://docs.rs/gherkin
[`gherkin_rust`]: https://docs.rs/gherkin_rust

[Cargo feature]: https://doc.rust-lang.org/cargo/reference/features.html
[Cucumber Expressions]: https://cucumber.github.io/cucumber-expressions
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "cucumber"
version = "0.13.0"
version = "0.14.0-dev"
edition = "2021"
rust-version = "1.57"
rust-version = "1.60"
description = """\
Cucumber testing framework for Rust, with async support. \
Fully native, no external test runners or dependencies.\
Expand All @@ -28,11 +28,11 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
default = ["macros"]
# Enables step attributes and auto-wiring.
macros = ["cucumber-codegen", "cucumber-expressions", "inventory"]
macros = ["dep:cucumber-codegen", "dep:cucumber-expressions", "dep:inventory"]
# Enables support for outputting in Cucumber JSON format.
output-json = ["Inflector", "serde", "serde_json", "timestamps"]
output-json = ["dep:Inflector", "dep:serde", "dep:serde_json", "timestamps"]
# Enables support for outputting JUnit XML report.
output-junit = ["junit-report", "timestamps"]
output-junit = ["dep:junit-report", "timestamps"]
# Enables timestamps collecting for all events.
timestamps = []

Expand All @@ -53,7 +53,7 @@ regex = "1.5.5"
sealed = "0.4"

# "macros" feature dependencies.
cucumber-codegen = { version = "0.13", path = "./codegen", optional = true }
cucumber-codegen = { version = "0.14.0-dev", path = "./codegen", optional = true }
cucumber-expressions = { version = "0.2.1", features = ["into-regex"], optional = true }
inventory = { version = "0.2", optional = true }

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Cucumber testing framework for Rust
===================================

[![Crates.io](https://img.shields.io/crates/v/cucumber.svg?maxAge=2592000)](https://crates.io/crates/cucumber)
[![Documentation](https://docs.rs/cucumber/badge.svg)](https://docs.rs/cucumber)
[![CI](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber/actions?query=workflow%3ACI+branch%3Amain)
[![Rust 1.57+](https://img.shields.io/badge/rustc-1.57+-lightgray.svg "Rust 1.57+")](https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html)
[![Rust 1.60+](https://img.shields.io/badge/rustc-1.60+-lightgray.svg "Rust 1.60+")](https://blog.rust-lang.org/2022/04/07/Rust-1.60.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.
Expand Down
2 changes: 1 addition & 1 deletion book/src/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ fn hungry_cat(world: &mut AnimalWorld, state: String) {
match state.as_str() {
"hungry" => world.cat.hungry = true,
"satiated" => world.cat.hungry = false,
s => panic!("expected 'hungry' or 'satiated', found: {}", s),
s => panic!("expected 'hungry' or 'satiated', found: {s}"),
}
}
#
Expand Down
2 changes: 1 addition & 1 deletion book/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
[dependencies]
async-trait = "0.1"
clap = { version = "3.0", features = ["derive"] }
cucumber = { version = "0.13", path = "../..", features = ["output-json", "output-junit"] }
cucumber = { version = "0.14.0-dev", path = "../..", features = ["output-json", "output-junit"] }
futures = "0.3"
humantime = "2.1"
once_cell = { version = "1.8", features = ["parking_lot"] }
Expand Down
13 changes: 13 additions & 0 deletions codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ All user visible changes to `cucumber-codegen` crate will be documented in this



## [0.14.0] · 2022-??-?? (unreleased)
[0.14.0]: /../../tree/v0.14.0/codegen

[Milestone](/../../milestone/13)

### BC Breaks

- Bump up [MSRV] to 1.60 for more clever support of [Cargo feature]s.




## [0.13.0] · 2022-03-29
[0.13.0]: /../../tree/v0.13.0/codegen

Expand Down Expand Up @@ -173,6 +185,7 @@ See `cucumber` crate [changelog](https://github.com/cucumber-rs/cucumber/blob/v0



[Cargo feature]: https://doc.rust-lang.org/cargo/reference/features.html
[Cucumber Expressions]: https://cucumber.github.io/cucumber-expressions
[MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
[Semantic Versioning 2.0.0]: https://semver.org
4 changes: 2 additions & 2 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "cucumber-codegen"
version = "0.13.0" # should be the same as main crate version
version = "0.14.0-dev" # should be the same as main crate version
edition = "2021"
rust-version = "1.57"
rust-version = "1.60"
description = "Code generation for `cucumber` crate."
license = "MIT OR Apache-2.0"
authors = [
Expand Down
3 changes: 2 additions & 1 deletion codegen/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
`cucumber-codegen` crate
========================

[![Crates.io](https://img.shields.io/crates/v/cucumber-codegen.svg?maxAge=2592000)](https://crates.io/crates/cucumber-codegen)
[![Documentation](https://docs.rs/cucumber-codegen/badge.svg)](https://docs.rs/cucumber-codegen)
[![CI](https://github.com/cucumber-rs/cucumber/workflows/CI/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber/actions?query=workflow%3ACI+branch%3Amain)
[![Rust 1.57+](https://img.shields.io/badge/rustc-1.57+-lightgray.svg "Rust 1.57+")](https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html)
[![Rust 1.60+](https://img.shields.io/badge/rustc-1.60+-lightgray.svg "Rust 1.60+")](https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance)

- [Changelog](https://github.com/cucumber-rs/cucumber/blob/main/codegen/CHANGELOG.md)
Expand Down
20 changes: 6 additions & 14 deletions codegen/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ impl Step {

let regex = self.gen_regex()?;

// TODO: Use "{func_name}" syntax once MSRV bumps above 1.58.
let caller_name =
format_ident!("__cucumber_{}_{}", self.attr_name, func_name);
format_ident!("__cucumber_{}_{func_name}", self.attr_name);
let awaiting = func.sig.asyncness.map(|_| quote! { .await });
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
let unwrapping = (!self.returns_unit())
.then(|| quote! { .unwrap_or_else(|e| panic!("{}", e)) });
let step_caller = quote! {
Expand Down Expand Up @@ -348,11 +346,9 @@ impl Step {
return Err(syn::Error::new(ty.span(), "Type path expected"));
};

// TODO: Use "{ident}" syntax once MSRV bumps above 1.58.
let not_found_err = format!("{} not found", ident);
let not_found_err = format!("{ident} not found");
let parsing_err = format!(
"{} can not be parsed to {}",
ident,
"{ident} can not be parsed to {}",
ty.path
.segments
.last()
Expand Down Expand Up @@ -456,8 +452,7 @@ impl Step {
}
AttributeArgument::Regex(re) => {
drop(Regex::new(re.value().as_str()).map_err(|e| {
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
syn::Error::new(re.span(), format!("Invalid regex: {}", e))
syn::Error::new(re.span(), format!("Invalid regex: {e}"))
})?);

Ok(quote! { ::cucumber::codegen::Regex::new(#re).unwrap() })
Expand Down Expand Up @@ -541,8 +536,7 @@ impl<'p> Parameters<'p> {
let expr = Expression::parse(expr).map_err(|e| {
syn::Error::new(
expr.span(),
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
format!("Incorrect cucumber expression: {}", e),
format!("Incorrect cucumber expression: {e}"),
)
})?;

Expand Down Expand Up @@ -667,12 +661,10 @@ impl<'p> Parameters<'p> {
} else {
// Here we use double escaping to properly render `{name}`
// in the assertion message of the generated code.
// TODO: Use "{name}" syntax once MSRV bumps above 1.58.
let assert_msg = format!(
"Type `{}` doesn't implement a custom parameter \
`{{{{{}}}}}`",
`{{{{{name}}}}}`",
quote! { #ty },
name,
);

quote! {
Expand Down
3 changes: 3 additions & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
clippy::dbg_macro,
clippy::debug_assert_with_mut_call,
clippy::decimal_literal_representation,
clippy::default_union_representation,
clippy::else_if_without_else,
clippy::empty_line_after_outer_attr,
clippy::equatable_if_let,
Expand All @@ -50,6 +51,7 @@
clippy::missing_const_for_fn,
clippy::missing_docs_in_private_items,
clippy::multiple_inherent_impl,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::nonstandard_macro_braces,
clippy::option_if_let_else,
Expand All @@ -71,6 +73,7 @@
clippy::suspicious_operation_groupings,
clippy::todo,
clippy::trailing_empty_array,
clippy::transmute_undefined_repr,
clippy::trivial_regex,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
Expand Down
3 changes: 1 addition & 2 deletions codegen/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ impl TryFrom<syn::DeriveInput> for Definition {
let attrs: Attrs = Attrs::parse_attrs("param", &input)?;

let regex = Regex::new(&attrs.regex.value()).map_err(|e| {
// TODO: Use "{e}" syntax once MSRV bumps above 1.58.
syn::Error::new(attrs.regex.span(), format!("Invalid regex: {}", e))
syn::Error::new(attrs.regex.span(), format!("Invalid regex: {e}"))
})?;

let name = attrs.name.as_ref().map_or_else(
Expand Down
3 changes: 1 addition & 2 deletions codegen/src/world_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ pub(crate) fn derive(
///
/// [`syn::Ident`]: struct@syn::Ident
fn step_types(steps: &[&str], world: &syn::Ident) -> Vec<syn::Ident> {
// TODO: Use "{world}" syntax once MSRV bumps above 1.58.
steps
.iter()
.map(|step| format_ident!("Cucumber{}{}", to_pascal_case(step), world))
.map(|step| format_ident!("Cucumber{}{world}", to_pascal_case(step)))
.collect()
}

Expand Down
13 changes: 3 additions & 10 deletions src/cucumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,31 +1272,24 @@ where

let failed_steps = writer.failed_steps();
if failed_steps > 0 {
// TODO: Use "{failed_steps}" syntax once MSRV bumps above 1.58.
msg.push(format!(
"{} step{} failed",
failed_steps,
"{failed_steps} step{} failed",
(failed_steps > 1).then(|| "s").unwrap_or_default(),
));
}

let parsing_errors = writer.parsing_errors();
if parsing_errors > 0 {
// TODO: Use "{parsing_errors}" syntax once MSRV bumps above
// 1.58.
msg.push(format!(
"{} parsing error{}",
parsing_errors,
"{parsing_errors} parsing error{}",
(parsing_errors > 1).then(|| "s").unwrap_or_default(),
));
}

let hook_errors = writer.hook_errors();
if hook_errors > 0 {
// TODO: Use "{hook_errors}" syntax once MSRV bumps above 1.58.
msg.push(format!(
"{} hook error{}",
hook_errors,
"{hook_errors} hook error{}",
(hook_errors > 1).then(|| "s").unwrap_or_default(),
));
}
Expand Down
3 changes: 1 addition & 2 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ pub enum HookType {

impl fmt::Display for HookType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// TODO: Use "{self}" syntax once MSRV bumps above 1.58.
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ fn expand_scenario(
let mut err = None;
let replaced = TEMPLATE_REGEX
.replace_all(str, |cap: &regex::Captures<'_>| {
// PANIC: Unwrapping is OK here as `TEMPLATE_REGEX`
// contains this capture group.
#[allow(clippy::unwrap_used)]
let name = cap.get(1).unwrap().as_str();

row.clone()
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
clippy::dbg_macro,
clippy::debug_assert_with_mut_call,
clippy::decimal_literal_representation,
clippy::default_union_representation,
clippy::else_if_without_else,
clippy::empty_line_after_outer_attr,
clippy::equatable_if_let,
Expand All @@ -52,6 +53,7 @@
clippy::missing_const_for_fn,
clippy::missing_docs_in_private_items,
clippy::multiple_inherent_impl,
clippy::mutex_atomic,
clippy::mutex_integer,
clippy::nonstandard_macro_braces,
clippy::option_if_let_else,
Expand All @@ -73,6 +75,7 @@
clippy::suspicious_operation_groupings,
clippy::todo,
clippy::trailing_empty_array,
clippy::transmute_undefined_repr,
clippy::trivial_regex,
clippy::undocumented_unsafe_blocks,
clippy::unimplemented,
Expand Down
4 changes: 1 addition & 3 deletions src/parser/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ impl<I: AsRef<Path>> Parser<I> for Basic {
.case_insensitive(true)
.build()
.unwrap_or_else(|e| {
// TODO: Use "{e}" syntax once MSRV bumps above
// 1.58.
unreachable!("GlobWalkerBuilder panicked: {}", e)
unreachable!("GlobWalkerBuilder panicked: {e}")
});
walk(w)
}
Expand Down
9 changes: 2 additions & 7 deletions src/runner/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,8 @@ where
.map_err(Info::from)
.and_then(|r| {
r.map_err(|e| {
// TODO: Use "{step:p}" syntax once MSRV bumps above
// 1.58.
coerce_into_info(format!(
"failed to initialize World: {}",
e,
"failed to initialize World: {e}",
))
})
})
Expand Down Expand Up @@ -961,9 +958,7 @@ where
Ok(Ok(w)) => w,
Ok(Err(e)) => {
let e = event::StepError::Panic(coerce_into_info(
// TODO: Use "{step:p}" syntax once MSRV bumps above
// 1.58.
format!("failed to initialize World: {}", e),
format!("failed to initialize World: {e}"),
));
return Err((e, None, None));
}
Expand Down
Loading

0 comments on commit fbd08ec

Please sign in to comment.