Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
foxzool committed Jun 11, 2024
1 parent 99ab4e5 commit 2f9fcd2
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/test_bevy_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ fn test_receive_bytes_send_through_serial_port_from_bevy_app() -> Result<(), Str
run_in_background_with_deadline(std::time::Duration::from_millis(2000), || {
with_local_serial_connected_ports(|serial_port_name, serial_port_name2: String| {
let mut app = App::new();
// The app should only update for 10 ticks before exiting gracefully or panicing. Typically
// calling .run() will never return, which is bad for a test and CI.
// The app should only update for 10 ticks before exiting gracefully or panicing.
// Typically calling .run() will never return, which is bad for a test and
// CI.
app.add_plugins((MinimalPlugins, SerialPortPlugin))
.insert_resource(TestPTTYPortNames {
sender: String::from(serial_port_name),
Expand All @@ -37,14 +38,17 @@ fn test_receive_bytes_send_through_serial_port_from_bevy_app() -> Result<(), Str
/// A simple bevy app that: sends data to a serial port, exits if that data is received within 10
/// update "ticks" , and panics otherwise.
mod receive_or_panic_bevy_app_impl {
use bevy::app::AppExit;
use bevy::prelude::{EventReader, EventWriter, Local, Res, ResMut, Resource};
use bevy::utils::tracing::info;
use bevy::{
app::AppExit,
prelude::{EventReader, EventWriter, Local, Res, ResMut, Resource},
utils::tracing::info,
};
use bevy_serialport::{
DataBits, FlowControl, Parity, SerialData, SerialPortRuntime, SerialPortSetting,
SerialResource, StopBits,
};
use bytes::Bytes;
use std::num::NonZero;

Check failure on line 51 in tests/test_bevy_integration.rs

View workflow job for this annotation

GitHub Actions / lint

use of unstable library feature 'generic_nonzero'
#[derive(Debug, Resource)]
pub(super) struct TestPTTYPortNames {
pub sender: String,
Expand All @@ -65,7 +69,8 @@ mod receive_or_panic_bevy_app_impl {
}
for message in serial_ev.read().filter(|x| x.port == port_names.receiver) {
info!("receive {:?}", message);
shutdown_writer.send(AppExit); // Exit the app gracefully to pass the test
// Exit the app gracefully to pass the test
shutdown_writer.send(AppExit::Error(NonZero::new(100).unwrap()));

Check failure on line 73 in tests/test_bevy_integration.rs

View workflow job for this annotation

GitHub Actions / lint

use of unstable library feature 'generic_nonzero'
}
}

Expand Down Expand Up @@ -114,10 +119,7 @@ mod receive_or_panic_bevy_app_impl {

#[cfg(target_os = "linux")] // Whatever linux-specific hacks I need to get tests to work
mod internal_nonsense {
use std::panic::UnwindSafe;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use std::{panic::UnwindSafe, sync::mpsc, thread, time::Duration};
use tempdir::TempDir;
pub(super) type TimeoutError = String;
pub(super) type TimeoutResult<T> = Result<T, TimeoutError>;
Expand Down

0 comments on commit 2f9fcd2

Please sign in to comment.