Skip to content

Commit 359b682

Browse files
committed
fix clippy
1 parent 5a5f89b commit 359b682

File tree

2 files changed

+18
-46
lines changed

2 files changed

+18
-46
lines changed

crates/testing_crates/script_integration_test_harness/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl ScenarioStepSerialized {
383383
let mut parts = flat_string.split_whitespace();
384384
let step_name = parts
385385
.next()
386-
.ok_or_else(|| anyhow::anyhow!("Invalid flat string step: `{}`", flat_string))?;
386+
.ok_or_else(|| anyhow::anyhow!("Invalid flat string step: `{flat_string}`"))?;
387387
let mut map = serde_json::Map::new();
388388
map.insert(
389389
"step".to_string(),

crates/testing_crates/script_integration_test_harness/src/scenario.rs

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ impl ScenarioStep {
419419
context.event_log.log_events(context.current_step_no, world);
420420
if context.scenario_time_started.elapsed().as_secs() > TIMEOUT_SECONDS {
421421
return Err(anyhow!(
422-
"Test scenario timed out after {} seconds",
423-
TIMEOUT_SECONDS
422+
"Test scenario timed out after {TIMEOUT_SECONDS} seconds",
424423
));
425424
}
426425
Ok(())
@@ -477,8 +476,7 @@ impl ScenarioStep {
477476
Some(language) => language.clone(),
478477
None => {
479478
return Err(anyhow!(
480-
"Unknown script language for extension: {}",
481-
extension
479+
"Unknown script language for extension: {extension}",
482480
));
483481
}
484482
}
@@ -568,8 +566,7 @@ impl ScenarioStep {
568566
.insert(as_name.to_string(), script_handle);
569567

570568
info!(
571-
"Script '{}' marked for loading from path '{}'",
572-
as_name,
569+
"Script '{as_name}' marked for loading from path '{}'",
573570
path.display()
574571
);
575572
}
@@ -613,8 +610,7 @@ impl ScenarioStep {
613610
.add_handler::<CallbackC>(context.current_script_language.clone(), app),
614611
_ => {
615612
return Err(anyhow!(
616-
"callback label: {} is not allowed, you can only use one of a set of labels",
617-
label
613+
"callback label: {label} is not allowed, you can only use one of a set of labels",
618614
));
619615
}
620616
}
@@ -629,7 +625,7 @@ impl ScenarioStep {
629625
.id();
630626

631627
context.entities.insert(name.to_string(), entity);
632-
info!("Spawned entity '{}' with script '{}'", entity, script.id());
628+
info!("Spawned entity '{entity}' with script '{}'", script.id());
633629
}
634630
ScenarioStep::EmitScriptCallbackEvent { event } => {
635631
app.world_mut().send_event(event.clone());
@@ -646,49 +642,34 @@ impl ScenarioStep {
646642
let language_correct = language.is_none_or(|l| l == event.language);
647643
if event.label != label || event.context_key != script || !language_correct {
648644
return Err(anyhow!(
649-
"Callback '{}' for attachment: '{}' was not the next event, found: {:?}. Order of events was incorrect.",
650-
label,
651-
script.to_string(),
652-
event
645+
"Callback '{label}' for attachment: '{script}' was not the next event, found: {event:?}. Order of events was incorrect."
653646
));
654647
}
655648

656649
match &event.response {
657650
Ok(val) => {
658651
info!(
659-
"Callback '{}' for attachment: '{}' succeeded, with value: {:?}",
660-
label,
661-
script.to_string(),
662-
&val
652+
"Callback '{label}' for attachment: '{script}' succeeded, with value: {val:?}"
663653
);
664654

665655
if let Some(expected_string) = expect_string_value.as_ref() {
666656
if ScriptValue::String(Cow::Owned(expected_string.clone())) != *val
667657
{
668658
return Err(anyhow!(
669-
"Callback '{}' for attachment: '{}' expected: {}, but got: {:#?}",
670-
label,
671-
script.to_string(),
672-
expected_string,
673-
val
659+
"Callback '{label}' for attachment: '{script}' expected: {expected_string}, but got: {val:#?}",
674660
));
675661
}
676662
}
677663
}
678664
Err(e) => {
679665
return Err(anyhow!(
680-
"Callback '{}' for attachment: '{}' failed with error: {:#?}",
681-
label,
682-
script.to_string(),
683-
e
666+
"Callback '{label}' for attachment: '{script}' failed with error: {e:#?}",
684667
));
685668
}
686669
}
687670
} else {
688671
return Err(anyhow!(
689-
"No callback response event found for label: {} and attachment: {}",
690-
label,
691-
script.to_string()
672+
"No callback response event found for label: {label} and attachment: {script}"
692673
));
693674
}
694675
}
@@ -713,7 +694,7 @@ impl ScenarioStep {
713694
script.id()
714695
)
715696
})?;
716-
info!("Dropped script asset '{}' from context", name);
697+
info!("Dropped script asset '{name}' from context");
717698
}
718699
ScenarioStep::ReloadScriptFrom { script, path } => {
719700
let mut assets = app.world_mut().resource_mut::<Assets<ScriptAsset>>();
@@ -741,8 +722,7 @@ impl ScenarioStep {
741722
let next_event = context.event_log.script_responses_queue.pop_front();
742723
if next_event.is_some() {
743724
return Err(anyhow!(
744-
"Expected no callback responses to be emitted, but found: {:?}",
745-
next_event
725+
"Expected no callback responses to be emitted, but found: {next_event:?}"
746726
));
747727
} else {
748728
info!("No callback responses emitted as expected");
@@ -752,11 +732,10 @@ impl ScenarioStep {
752732
let success = app.world_mut().despawn(entity);
753733
if !success {
754734
return Err(anyhow!(
755-
"Failed to despawn entity with name '{}'. It may not exist.",
756-
entity
735+
"Failed to despawn entity with name '{entity}'. It may not exist.",
757736
));
758737
} else {
759-
info!("Despawning entity with name '{}'", entity);
738+
info!("Despawning entity with name '{entity}'",);
760739
}
761740
}
762741
ScenarioStep::AttachStaticScript { script } => {
@@ -846,22 +825,15 @@ impl ScenarioStep {
846825

847826
if residents != residents_num {
848827
return Err(anyhow!(
849-
"Expected {} residents for script attachment: {}, but found {}",
850-
residents_num,
851-
script.to_string(),
852-
residents
828+
"Expected {residents_num} residents for script attachment: {script}, but found {residents}",
853829
));
854830
} else {
855-
info!(
856-
"Script attachment: {} has {} residents as expected",
857-
script.to_string(),
858-
residents
859-
);
831+
info!("Script attachment: {script} has {residents} residents as expected",);
860832
}
861833
}
862834
ScenarioStep::Comment { comment } => {
863835
// Comments are ignored, do nothing, log it though for debugging
864-
info!("Comment: {}", comment);
836+
info!("Comment: {comment}");
865837
}
866838
}
867839
Ok(())

0 commit comments

Comments
 (0)