Skip to content

Commit

Permalink
Get rid of once_cell crate
Browse files Browse the repository at this point in the history
- bump up MSRV to 1.80
  • Loading branch information
tyranron committed Jul 26, 2024
1 parent a5daa52 commit 4010c1a
Show file tree
Hide file tree
Showing 49 changed files with 209 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
strategy:
fail-fast: false
matrix:
msrv: ["1.75.0"]
msrv: ["1.80.0"]
crate:
- cucumber-codegen
- cucumber
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ All user visible changes to `cucumber` crate will be documented in this file. Th



## [0.22.0] · 2024-??-?? (unreleased)
[0.22.0]: /../../tree/v0.22.0

[Diff](/../../compare/v0.21.1...v0.22.0) | [Milestone](/../../milestone/28)

### BC Breaks

- Bumped up [MSRV] to 1.80 to get rid of `once_cell` crate. ([todo])

[todo]: /../../commit/todo-full




## [0.21.1] · 2024-06-16
[0.21.1]: /../../tree/v0.21.1

Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cucumber"
version = "0.21.1"
edition = "2021"
rust-version = "1.75"
rust-version = "1.80"
description = """\
Cucumber testing framework for Rust, with async support. \
Fully native, no external test runners or dependencies.\
Expand Down Expand Up @@ -73,11 +73,9 @@ gherkin = "0.14"
globwalk = "0.9"
humantime = "2.1"
itertools = "0.13"
lazy-regex = "3.0"
linked-hash-map = "0.5.3"
once_cell = "1.13"
pin-project = "1.0"
regex = "1.5.5"
regex = "1.9"
sealed = "0.5"
smart-default = "0.7.1"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Cucumber testing framework for Rust
===================================

[![crates.io](https://img.shields.io/crates/v/cucumber.svg?maxAge=2592000 "crates.io")](https://crates.io/crates/cucumber)
[![Rust 1.75+](https://img.shields.io/badge/rustc-1.75+-lightgray.svg "Rust 1.75")](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![Rust 1.80+](https://img.shields.io/badge/rustc-1.80+-lightgray.svg "Rust 1.80")](https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg "Unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
[![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 docs](https://docs.rs/cucumber/badge.svg "Rust docs")](https://docs.rs/cucumber)
Expand Down
8 changes: 3 additions & 5 deletions book/src/architecture/runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ Now, let's implement a custom [`Runner`] which simply executes [scenario]s in [f
```rust
# extern crate cucumber;
# extern crate futures;
# extern crate once_cell;
# extern crate tokio;
#
# use std::{
# panic::{self, AssertUnwindSafe},
# path::PathBuf,
# sync::Arc,
# sync::{Arc, LazyLock},
# time::Duration,
# };
#
Expand All @@ -25,7 +24,6 @@ Now, let's implement a custom [`Runner`] which simply executes [scenario]s in [f
# future::{self, FutureExt as _},
# stream::{self, LocalBoxStream, Stream, StreamExt as _, TryStreamExt as _},
# };
# use once_cell::sync::Lazy;
# use tokio::time::sleep;
#
# #[derive(Clone, Copy, Debug, Default)]
Expand Down Expand Up @@ -135,8 +133,8 @@ struct CustomRunner;
impl CustomRunner {
fn steps_fns() -> &'static step::Collection<AnimalWorld> {
// Wire the static collection of step matching functions.
static STEPS: Lazy<step::Collection<AnimalWorld>> =
Lazy::new(AnimalWorld::collection);
static STEPS: LazyLock<step::Collection<AnimalWorld>> =
LazyLock::new(AnimalWorld::collection);
&STEPS
}

Expand Down
8 changes: 3 additions & 5 deletions book/src/architecture/writer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ Finally, let's implement a custom [`Writer`] which simply outputs [cucumber even
```rust
# extern crate cucumber;
# extern crate futures;
# extern crate once_cell;
# extern crate tokio;
#
# use std::{
# panic::{self, AssertUnwindSafe},
# path::PathBuf,
# sync::Arc,
# sync::{Arc, LazyLock},
# time::Duration,
# };
#
Expand All @@ -26,7 +25,6 @@ Finally, let's implement a custom [`Writer`] which simply outputs [cucumber even
# future::{self, FutureExt as _},
# stream::{self, LocalBoxStream, Stream, StreamExt as _, TryStreamExt as _},
# };
# use once_cell::sync::Lazy;
# use tokio::time::sleep;
#
# #[derive(Clone, Copy, Debug, Default)]
Expand Down Expand Up @@ -135,8 +133,8 @@ Finally, let's implement a custom [`Writer`] which simply outputs [cucumber even
#
# impl CustomRunner {
# fn steps_fns() -> &'static step::Collection<AnimalWorld> {
# static STEPS: Lazy<step::Collection<AnimalWorld>> =
# Lazy::new(AnimalWorld::collection);
# static STEPS: LazyLock<step::Collection<AnimalWorld>> =
# LazyLock::new(AnimalWorld::collection);
# &STEPS
# }
#
Expand Down
14 changes: 14 additions & 0 deletions codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ All user visible changes to `cucumber-codegen` crate will be documented in this



## [0.22.0] · 2024-??-?? (unreleased)
[0.22.0]: /../../tree/v0.22.0/codegen

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

### BC Breaks

- Bumped up [MSRV] to 1.80 to get rid of `once_cell` crate. ([todo])

[todo]: /../../commit/todo-full




## [0.21.1] · 2024-06-16
[0.21.1]: /../../tree/v0.21.1/codegen

Expand Down
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cucumber-codegen"
version = "0.21.1" # should be the same as main crate version
edition = "2021"
rust-version = "1.75"
rust-version = "1.80"
description = "Code generation for `cucumber` crate."
license = "MIT OR Apache-2.0"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
========================

[![crates.io](https://img.shields.io/crates/v/cucumber-codegen.svg?maxAge=2592000 "crates.io")](https://crates.io/crates/cucumber-codegen)
[![Rust 1.75+](https://img.shields.io/badge/rustc-1.75+-lightgray.svg "Rust 1.75")](https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html)
[![Rust 1.80+](https://img.shields.io/badge/rustc-1.80+-lightgray.svg "Rust 1.80")](https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html)
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg "Unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
[![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 docs](https://docs.rs/cucumber-codegen/badge.svg "Rust docs")](https://docs.rs/cucumber-codegen)
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ impl Step {
column: ::std::column!(),
},
regex: || {
static LAZY: ::cucumber::codegen::Lazy<
static LAZY: ::std::sync::LazyLock<
::cucumber::codegen::Regex
> = ::cucumber::codegen::Lazy::new(|| { #regex });
> = ::std::sync::LazyLock::new(|| { #regex });
LAZY.clone()
},
func: |__cucumber_world, __cucumber_ctx| {
Expand Down
3 changes: 1 addition & 2 deletions src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub use cucumber_expressions::{
};
pub use futures::future::LocalBoxFuture;
pub use inventory::{self, collect, submit};
pub use once_cell::sync::Lazy;
pub use regex::Regex;

/// [`World`] extension allowing to register steps in [`inventory`].
Expand All @@ -43,7 +42,7 @@ pub trait WorldInventory: World {
type Then: inventory::Collect + StepConstructor<Self>;
}

/// Alias for a [`fn`] returning a [`Lazy`] [`Regex`].
/// Alias for a [`fn`] returning a [`Regex`].
pub type LazyRegex = fn() -> Regex;

/// Trait for registering a [`Step`] with [`given`], [`when`] and [`then`]
Expand Down
9 changes: 6 additions & 3 deletions src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
use std::{
iter, mem,
path::{Path, PathBuf},
sync::LazyLock,
};

use derive_more::{Display, Error};
use lazy_regex::regex;
use once_cell::sync::Lazy;
use regex::Regex;
use sealed::sealed;

Expand Down Expand Up @@ -144,7 +143,11 @@ fn expand_scenario(
/// [`Regex`] matching placeholders [`Examples`] should expand into.
///
/// [`Examples`]: gherkin::Examples
static TEMPLATE_REGEX: &Lazy<Regex> = regex!(r"<([^>\s]+)>");
// TODO: Switch back to `lazy-regex::regex!()` once it migrates to `std`:
// https://github.com/Canop/lazy-regex/issues/10
#[allow(clippy::unwrap_used)] // never panics
static TEMPLATE_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"<([^>\s]+)>").unwrap());

if scenario.examples.is_empty() {
return vec![Ok(scenario)];
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,10 @@ pub use self::{
/// across [scenarios][0], because we want some friction there to avoid tests
/// being dependent on each other. If your workflow needs a way to share state
/// between [scenarios][0] (ex. database connection pool), we recommend using
/// [`once_cell`][1] crate or organize it other way via [shared state][2].
/// a [`std::sync::LazyLock`] or organize it other way via [shared state][1].
///
/// [0]: https://cucumber.io/docs/gherkin/reference#descriptions
/// [1]: https://docs.rs/once_cell
/// [2]: https://doc.rust-lang.org/book/ch16-03-shared-state.html
/// [1]: https://doc.rust-lang.org/book/ch16-03-shared-state.html
/// [Cucumber]: https://cucumber.io
pub trait World: Sized + 'static {
/// Error of creating a new [`World`] instance.
Expand Down
4 changes: 2 additions & 2 deletions src/writer/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use std::{
fmt::{Debug, Display},
io,
str::FromStr,
sync::LazyLock,
};

use derive_more::{Deref, DerefMut};
use itertools::Itertools as _;
use once_cell::sync::Lazy;
use regex::CaptureLocations;
use smart_default::SmartDefault;

Expand Down Expand Up @@ -1123,7 +1123,7 @@ where
/// Trims start of the path if it matches the current project directory.
pub(crate) fn trim_path(path: &str) -> &str {
/// Path of the current project directory.
static CURRENT_DIR: Lazy<String> = Lazy::new(|| {
static CURRENT_DIR: LazyLock<String> = LazyLock::new(|| {
env::var("CARGO_WORKSPACE_DIR")
.or_else(|_| env::var("CARGO_MANIFEST_DIR"))
.unwrap_or_else(|_| {
Expand Down
4 changes: 2 additions & 2 deletions src/writer/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
use std::{
fmt::{self, Debug},
io, mem,
sync::LazyLock,
time::SystemTime,
};

use base64::Engine as _;
use derive_more::Display;
use inflector::Inflector as _;
use mime::Mime;
use once_cell::sync::Lazy;
use serde::{Serialize, Serializer};

use crate::{
Expand Down Expand Up @@ -448,7 +448,7 @@ impl Embedding {
/// Creates [`Embedding`] from the provided [`event::Scenario::Log`].
fn from_log(msg: impl AsRef<str>) -> Self {
/// [`Mime`] of the [`event::Scenario::Log`] [`Embedding`].
static LOG_MIME: Lazy<Mime> = Lazy::new(|| {
static LOG_MIME: LazyLock<Mime> = LazyLock::new(|| {
"text/x.cucumber.log+plain"
.parse()
.unwrap_or_else(|_| unreachable!("valid MIME"))
Expand Down
Loading

0 comments on commit 4010c1a

Please sign in to comment.