-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor housekeeping work #310
Changes from 3 commits
6ffe7fe
f73ee79
186b050
77dc2cf
73b28f7
38c202e
25b3dcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ struct Step { | |
/// reference. | ||
/// | ||
/// [`gherkin::Step`]: https://bit.ly/3j42hcd | ||
step_arg_name: Option<syn::Ident>, | ||
arg_name: Option<syn::Ident>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @barafael |
||
} | ||
|
||
impl Step { | ||
|
@@ -97,7 +97,7 @@ impl Step { | |
attr_name, | ||
attr_arg, | ||
func, | ||
step_arg_name, | ||
arg_name: step_arg_name, | ||
}) | ||
} | ||
|
||
|
@@ -274,7 +274,7 @@ impl Step { | |
|
||
Ok((func_args, addon_parsing)) | ||
} | ||
} else if self.step_arg_name.is_some() { | ||
} else if self.arg_name.is_some() { | ||
Ok(( | ||
quote! { ::std::borrow::Borrow::borrow(&__cucumber_ctx.step), }, | ||
None, | ||
|
@@ -304,7 +304,7 @@ impl Step { | |
let (ident, ty) = parse_fn_arg(arg)?; | ||
|
||
let is_ctx_arg = | ||
self.step_arg_name.as_ref().map(|i| *i == *ident) == Some(true); | ||
self.arg_name.as_ref().map(|i| *i == *ident) == Some(true); | ||
|
||
let decl = if is_ctx_arg { | ||
quote! { | ||
|
@@ -385,7 +385,7 @@ impl Step { | |
&self, | ||
arg: &syn::FnArg, | ||
) -> syn::Result<TokenStream> { | ||
if let Some(name) = &self.step_arg_name { | ||
if let Some(name) = &self.arg_name { | ||
let (ident, _) = parse_fn_arg(arg)?; | ||
if name == ident { | ||
return Ok(quote! { | ||
|
@@ -444,7 +444,7 @@ impl Step { | |
) -> syn::Result<TokenStream> { | ||
let expr = expr.value(); | ||
let params = | ||
Parameters::new(&expr, &self.func, self.step_arg_name.as_ref())?; | ||
Parameters::new(&expr, &self.func, self.arg_name.as_ref())?; | ||
|
||
let provider_impl = | ||
params.gen_provider_impl(&parse_quote! { Provider }); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ pub struct Event<T: ?Sized> { | |
impl<T> Event<T> { | ||
/// Creates a new [`Event`] out of the given `value`. | ||
#[must_use] | ||
pub fn new(value: T) -> Self { | ||
pub const fn new(value: T) -> Self { | ||
Self { | ||
#[cfg(feature = "timestamps")] | ||
at: SystemTime::now(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @barafael this won't compile with
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1074,7 +1074,7 @@ async fn execute<W, Before, After>( | |
} | ||
} | ||
#[cfg(not(feature = "tracing"))] | ||
let _ = id; | ||
let _: ScenarioId = id; | ||
|
||
if fail_fast && scenario_failed && !retried { | ||
started_scenarios = ControlFlow::Break(()); | ||
|
@@ -1485,7 +1485,7 @@ where | |
(fut, span_id) | ||
}; | ||
#[cfg(not(feature = "tracing"))] | ||
let _ = scenario_id; | ||
let _: ScenarioId = scenario_id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @barafael I would prefer
|
||
|
||
let result = fut.then_yield().await; | ||
|
||
|
@@ -1606,7 +1606,7 @@ where | |
waiter.wait_for_span_close(id).then_yield().await; | ||
} | ||
#[cfg(not(feature = "tracing"))] | ||
let _ = scenario_id; | ||
let _: ScenarioId = scenario_id; | ||
|
||
match result { | ||
Ok((Some(captures), loc, Some(world))) => { | ||
|
@@ -1762,7 +1762,7 @@ where | |
(fut, span_id) | ||
}; | ||
#[cfg(not(feature = "tracing"))] | ||
let _ = scenario_id; | ||
let _: ScenarioId = scenario_id; | ||
|
||
let res = fut.then_yield().await; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,7 +347,7 @@ impl<Writer> Normalized for AssertNormalized<Writer> {} | |
#[derive(Clone, Debug)] | ||
struct Queue<K: Eq + Hash, V> { | ||
/// Underlying FIFO queue of values. | ||
queue: LinkedHashMap<K, V>, | ||
fifo: LinkedHashMap<K, V>, | ||
|
||
/// Initial [`Metadata`] of this [`Queue`] creation. | ||
/// | ||
|
@@ -363,7 +363,7 @@ impl<K: Eq + Hash, V> Queue<K, V> { | |
/// Creates a new normalization [`Queue`] with an initial metadata. | ||
fn new(initial: Metadata) -> Self { | ||
Self { | ||
queue: LinkedHashMap::new(), | ||
fifo: LinkedHashMap::new(), | ||
initial: Some(initial), | ||
state: FinishedState::NotFinished, | ||
} | ||
|
@@ -385,7 +385,7 @@ impl<K: Eq + Hash, V> Queue<K, V> { | |
|
||
/// Removes the given `key` from this [`Queue`]. | ||
fn remove(&mut self, key: &K) { | ||
drop(self.queue.remove(key)); | ||
drop(self.fifo.remove(key)); | ||
} | ||
} | ||
|
||
|
@@ -489,7 +489,7 @@ impl<World> CucumberQueue<World> { | |
/// [`Feature`]: gherkin::Feature | ||
fn new_feature(&mut self, feat: Event<Arc<gherkin::Feature>>) { | ||
let (feat, meta) = feat.split(); | ||
drop(self.queue.insert(feat, FeatureQueue::new(meta))); | ||
drop(self.fifo.insert(feat, FeatureQueue::new(meta))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @barafael not a fan of this particular change. It's more meaningful to emphasize we're queuing something here, rather than bothering reader with exact semantics of the queue, which is "implementation detail". |
||
} | ||
|
||
/// Marks a [`Feature`] as finished on [`event::Feature::Finished`]. | ||
|
@@ -500,7 +500,7 @@ impl<World> CucumberQueue<World> { | |
/// [`Feature`]: gherkin::Feature | ||
fn feature_finished(&mut self, feat: Event<&gherkin::Feature>) { | ||
let (feat, meta) = feat.split(); | ||
self.queue | ||
self.fifo | ||
.get_mut(feat) | ||
.unwrap_or_else(|| panic!("No Feature {}", feat.name)) | ||
.finished(meta); | ||
|
@@ -514,7 +514,7 @@ impl<World> CucumberQueue<World> { | |
feat: &gherkin::Feature, | ||
rule: Event<Arc<gherkin::Rule>>, | ||
) { | ||
self.queue | ||
self.fifo | ||
.get_mut(feat) | ||
.unwrap_or_else(|| panic!("No Feature {}", feat.name)) | ||
.new_rule(rule); | ||
|
@@ -531,7 +531,7 @@ impl<World> CucumberQueue<World> { | |
feat: &gherkin::Feature, | ||
rule: Event<Arc<gherkin::Rule>>, | ||
) { | ||
self.queue | ||
self.fifo | ||
.get_mut(feat) | ||
.unwrap_or_else(|| panic!("No Feature {}", feat.name)) | ||
.rule_finished(rule); | ||
|
@@ -545,7 +545,7 @@ impl<World> CucumberQueue<World> { | |
scenario: Arc<gherkin::Scenario>, | ||
event: Event<event::RetryableScenario<World>>, | ||
) { | ||
self.queue | ||
self.fifo | ||
.get_mut(feat) | ||
.unwrap_or_else(|| panic!("No Feature {}", feat.name)) | ||
.insert_scenario_event(rule, scenario, event.retries, event); | ||
|
@@ -559,7 +559,7 @@ impl<'me, World> Emitter<World> for &'me mut CucumberQueue<World> { | |
type EmittedPath = (); | ||
|
||
fn current_item(self) -> Option<Self::Current> { | ||
self.queue | ||
self.fifo | ||
.iter_mut() | ||
.next() | ||
.map(|(f, ev)| (Arc::clone(f), ev)) | ||
|
@@ -641,7 +641,7 @@ impl<World> FeatureQueue<World> { | |
fn new_rule(&mut self, rule: Event<Arc<gherkin::Rule>>) { | ||
let (rule, meta) = rule.split(); | ||
drop( | ||
self.queue.insert( | ||
self.fifo.insert( | ||
Either::Left(rule), | ||
Either::Left(RulesQueue::new(meta)), | ||
), | ||
|
@@ -653,7 +653,7 @@ impl<World> FeatureQueue<World> { | |
/// [`Rule`]: gherkin::Rule | ||
fn rule_finished(&mut self, rule: Event<Arc<gherkin::Rule>>) { | ||
let (rule, meta) = rule.split(); | ||
match self.queue.get_mut(&Either::Left(rule)) { | ||
match self.fifo.get_mut(&Either::Left(rule)) { | ||
Some(Either::Left(ev)) => { | ||
ev.finished(meta); | ||
} | ||
|
@@ -673,12 +673,12 @@ impl<World> FeatureQueue<World> { | |
) { | ||
if let Some(r) = rule { | ||
match self | ||
.queue | ||
.fifo | ||
.get_mut(&Either::Left(Arc::clone(&r))) | ||
.unwrap_or_else(|| panic!("No Rule {}", r.name)) | ||
{ | ||
Either::Left(rules) => rules | ||
.queue | ||
.fifo | ||
.entry((scenario, retries)) | ||
.or_insert_with(ScenariosQueue::new) | ||
.0 | ||
|
@@ -687,7 +687,7 @@ impl<World> FeatureQueue<World> { | |
} | ||
} else { | ||
match self | ||
.queue | ||
.fifo | ||
.entry(Either::Right((scenario, retries))) | ||
.or_insert_with(|| Either::Right(ScenariosQueue::new())) | ||
{ | ||
|
@@ -705,7 +705,7 @@ impl<'me, World> Emitter<World> for &'me mut FeatureQueue<World> { | |
type EmittedPath = Arc<gherkin::Feature>; | ||
|
||
fn current_item(self) -> Option<Self::Current> { | ||
Some(match self.queue.iter_mut().next()? { | ||
Some(match self.fifo.iter_mut().next()? { | ||
(Either::Left(rule), Either::Left(events)) => { | ||
Either::Left((Arc::clone(rule), events)) | ||
} | ||
|
@@ -748,7 +748,7 @@ impl<'me, World> Emitter<World> for &'me mut RulesQueue<World> { | |
type EmittedPath = (Arc<gherkin::Feature>, Arc<gherkin::Rule>); | ||
|
||
fn current_item(self) -> Option<Self::Current> { | ||
self.queue | ||
self.fifo | ||
.iter_mut() | ||
.next() | ||
.map(|((sc, _), ev)| (Arc::clone(sc), ev)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@barafael I've found it more comfortable to keep each dependency as a single line in
[dependencies]
section.