diff options
| author | mat <git@matdoes.dev> | 2025-06-08 22:46:26 -0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-08 22:46:26 -0330 |
| commit | 3087b0c996dbd3fb9a1dbcac4bf5c32f992c2e5e (patch) | |
| tree | 7d3e889f0f6c45be331d4396f4bdc90496defeef /azalea-client/tests | |
| parent | 338f931c51ab3665c7c18124ca3e35bfd2ff5ca0 (diff) | |
| download | azalea-drasl-3087b0c996dbd3fb9a1dbcac4bf5c32f992c2e5e.tar.xz | |
add support for panicking on warn/error in simulation tests
Diffstat (limited to 'azalea-client/tests')
10 files changed, 24 insertions, 35 deletions
diff --git a/azalea-client/tests/change_dimension_to_nether_and_back.rs b/azalea-client/tests/change_dimension_to_nether_and_back.rs index fddbccde..e3b5d96e 100644 --- a/azalea-client/tests/change_dimension_to_nether_and_back.rs +++ b/azalea-client/tests/change_dimension_to_nether_and_back.rs @@ -1,4 +1,4 @@ -use azalea_client::{InConfigState, InGameState, test_simulation::*}; +use azalea_client::{InConfigState, InGameState, test_utils::prelude::*}; use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; use azalea_entity::LocalEntity; use azalea_protocol::packets::{ @@ -7,12 +7,11 @@ use azalea_protocol::packets::{ }; use azalea_registry::{DataRegistry, DimensionType}; use azalea_world::InstanceName; -use bevy_log::tracing_subscriber; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] fn test_change_dimension_to_nether_and_back() { - let _ = tracing_subscriber::fmt().try_init(); + init_tracing(); generic_test_change_dimension_to_nether_and_back(true); generic_test_change_dimension_to_nether_and_back(false); @@ -29,8 +28,6 @@ fn generic_test_change_dimension_to_nether_and_back(using_respawn: bool) { } }; - let _ = tracing_subscriber::fmt::try_init(); - let mut simulation = Simulation::new(ConnectionProtocol::Configuration); assert!(simulation.has_component::<InConfigState>()); assert!(!simulation.has_component::<InGameState>()); diff --git a/azalea-client/tests/client_disconnect.rs b/azalea-client/tests/client_disconnect.rs index 354ac788..fc17da0c 100644 --- a/azalea-client/tests/client_disconnect.rs +++ b/azalea-client/tests/client_disconnect.rs @@ -1,11 +1,10 @@ -use azalea_client::test_simulation::*; +use azalea_client::test_utils::prelude::*; use azalea_protocol::packets::ConnectionProtocol; use azalea_world::InstanceName; -use bevy_log::tracing_subscriber; #[test] fn test_client_disconnect() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Game); diff --git a/azalea-client/tests/despawn_entities_when_changing_dimension.rs b/azalea-client/tests/despawn_entities_when_changing_dimension.rs index 967e0aac..9143b3eb 100644 --- a/azalea-client/tests/despawn_entities_when_changing_dimension.rs +++ b/azalea-client/tests/despawn_entities_when_changing_dimension.rs @@ -1,4 +1,4 @@ -use azalea_client::test_simulation::*; +use azalea_client::test_utils::prelude::*; use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; use azalea_entity::metadata::Cow; use azalea_protocol::packets::{ @@ -7,12 +7,11 @@ use azalea_protocol::packets::{ }; use azalea_registry::{DataRegistry, DimensionType, EntityKind}; use bevy_ecs::query::With; -use bevy_log::tracing_subscriber; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] fn test_despawn_entities_when_changing_dimension() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Configuration); simulation.receive_packet(ClientboundRegistryData { diff --git a/azalea-client/tests/fast_login.rs b/azalea-client/tests/fast_login.rs index bc26079a..f11ada9c 100644 --- a/azalea-client/tests/fast_login.rs +++ b/azalea-client/tests/fast_login.rs @@ -1,4 +1,4 @@ -use azalea_client::{InConfigState, test_simulation::*}; +use azalea_client::{InConfigState, test_utils::prelude::*}; use azalea_core::resource_location::ResourceLocation; use azalea_entity::metadata::Health; use azalea_protocol::packets::{ @@ -6,12 +6,11 @@ use azalea_protocol::packets::{ config::{ClientboundFinishConfiguration, ClientboundRegistryData}, game::ClientboundSetHealth, }; -use bevy_log::tracing_subscriber; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] fn test_fast_login() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Configuration); assert!(simulation.has_component::<InConfigState>()); diff --git a/azalea-client/tests/login_to_dimension_with_same_name.rs b/azalea-client/tests/login_to_dimension_with_same_name.rs index 59d3123d..eb1db2a8 100644 --- a/azalea-client/tests/login_to_dimension_with_same_name.rs +++ b/azalea-client/tests/login_to_dimension_with_same_name.rs @@ -1,4 +1,6 @@ -use azalea_client::{InConfigState, InGameState, local_player::InstanceHolder, test_simulation::*}; +use azalea_client::{ + InConfigState, InGameState, local_player::InstanceHolder, test_utils::prelude::*, +}; use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; use azalea_entity::LocalEntity; use azalea_protocol::packets::{ @@ -8,12 +10,11 @@ use azalea_protocol::packets::{ }; use azalea_registry::{DataRegistry, DimensionType}; use azalea_world::InstanceName; -use bevy_log::tracing_subscriber; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] fn test_login_to_dimension_with_same_name() { - let _ = tracing_subscriber::fmt().try_init(); + init_tracing(); generic_test_login_to_dimension_with_same_name(true); generic_test_login_to_dimension_with_same_name(false); @@ -30,8 +31,6 @@ fn generic_test_login_to_dimension_with_same_name(using_respawn: bool) { } }; - let _ = tracing_subscriber::fmt::try_init(); - let mut simulation = Simulation::new(ConnectionProtocol::Configuration); assert!(simulation.has_component::<InConfigState>()); assert!(!simulation.has_component::<InGameState>()); diff --git a/azalea-client/tests/move_despawned_entity.rs b/azalea-client/tests/move_despawned_entity.rs index d590cb39..8c33566b 100644 --- a/azalea-client/tests/move_despawned_entity.rs +++ b/azalea-client/tests/move_despawned_entity.rs @@ -1,15 +1,15 @@ -use azalea_client::test_simulation::*; +use azalea_client::test_utils::prelude::*; use azalea_core::{position::ChunkPos, resource_location::ResourceLocation}; use azalea_entity::metadata::Cow; use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundMoveEntityRot}; use azalea_registry::{DataRegistry, DimensionType, EntityKind}; use azalea_world::MinecraftEntityId; use bevy_ecs::query::With; -use bevy_log::tracing_subscriber; +use tracing::Level; #[test] fn test_move_despawned_entity() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing_with_level(Level::ERROR); // a warning is expected here let mut simulation = Simulation::new(ConnectionProtocol::Game); simulation.receive_packet(make_basic_login_packet( @@ -26,7 +26,7 @@ fn test_move_despawned_entity() { // make sure it's spawned let mut cow_query = simulation.app.world_mut().query_filtered::<(), With<Cow>>(); let cow_iter = cow_query.iter(simulation.app.world()); - assert_eq!(cow_iter.count(), 1, "cow should be despawned"); + assert_eq!(cow_iter.count(), 1, "cow should be spawned"); // despawn the cow by receiving a login packet simulation.receive_packet(make_basic_login_packet( diff --git a/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs b/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs index 0090e37e..8e14f731 100644 --- a/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs +++ b/azalea-client/tests/receive_spawn_entity_and_start_config_packet.rs @@ -1,4 +1,4 @@ -use azalea_client::{InConfigState, test_simulation::*}; +use azalea_client::{InConfigState, test_utils::prelude::*}; use azalea_core::{position::Vec3, resource_location::ResourceLocation}; use azalea_protocol::packets::{ ConnectionProtocol, @@ -6,12 +6,11 @@ use azalea_protocol::packets::{ }; use azalea_registry::{DataRegistry, DimensionType, EntityKind}; use azalea_world::InstanceName; -use bevy_log::tracing_subscriber; use uuid::Uuid; #[test] fn test_receive_spawn_entity_and_start_config_packet() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Game); simulation.receive_packet(make_basic_login_packet( diff --git a/azalea-client/tests/receive_start_config_packet.rs b/azalea-client/tests/receive_start_config_packet.rs index 9b0c734d..485204e4 100644 --- a/azalea-client/tests/receive_start_config_packet.rs +++ b/azalea-client/tests/receive_start_config_packet.rs @@ -1,14 +1,13 @@ -use azalea_client::{InConfigState, packet::game::SendPacketEvent, test_simulation::*}; +use azalea_client::{InConfigState, packet::game::SendPacketEvent, test_utils::prelude::*}; use azalea_core::resource_location::ResourceLocation; use azalea_protocol::packets::{ConnectionProtocol, game::ClientboundStartConfiguration}; use azalea_registry::{DataRegistry, DimensionType}; use azalea_world::InstanceName; use bevy_ecs::event::Events; -use bevy_log::tracing_subscriber; #[test] fn test_receive_start_config_packet() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Game); simulation.receive_packet(make_basic_login_packet( diff --git a/azalea-client/tests/reply_to_ping_with_pong.rs b/azalea-client/tests/reply_to_ping_with_pong.rs index bc8bccd4..ac09336c 100644 --- a/azalea-client/tests/reply_to_ping_with_pong.rs +++ b/azalea-client/tests/reply_to_ping_with_pong.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use azalea_client::{ packet::{config::SendConfigPacketEvent, game::SendPacketEvent}, - test_simulation::*, + test_utils::prelude::*, }; use azalea_core::resource_location::ResourceLocation; use azalea_protocol::packets::{ @@ -13,13 +13,12 @@ use azalea_protocol::packets::{ game::{self, ServerboundGamePacket}, }; use bevy_ecs::observer::Trigger; -use bevy_log::tracing_subscriber; use parking_lot::Mutex; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] fn reply_to_ping_with_pong() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Configuration); diff --git a/azalea-client/tests/set_health_before_login.rs b/azalea-client/tests/set_health_before_login.rs index d81dd48f..60735781 100644 --- a/azalea-client/tests/set_health_before_login.rs +++ b/azalea-client/tests/set_health_before_login.rs @@ -1,4 +1,4 @@ -use azalea_client::{InConfigState, test_simulation::*}; +use azalea_client::{InConfigState, test_utils::prelude::*}; use azalea_core::resource_location::ResourceLocation; use azalea_entity::{LocalEntity, metadata::Health}; use azalea_protocol::packets::{ @@ -7,12 +7,11 @@ use azalea_protocol::packets::{ game::ClientboundSetHealth, }; use azalea_registry::{DataRegistry, DimensionType}; -use bevy_log::tracing_subscriber; use simdnbt::owned::{NbtCompound, NbtTag}; #[test] fn test_set_health_before_login() { - let _ = tracing_subscriber::fmt::try_init(); + init_tracing(); let mut simulation = Simulation::new(ConnectionProtocol::Configuration); assert!(simulation.has_component::<InConfigState>()); |
