Files
continuwuity/src/admin/debug/tester.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
843 B
Rust
Raw Normal View History

use conduwuit::{Err, Result};
2024-04-29 13:56:04 -07:00
use crate::{admin_command, admin_command_dispatch};
2024-04-29 13:56:04 -07:00
2024-07-27 00:11:41 +00:00
#[admin_command_dispatch]
#[derive(Debug, clap::Subcommand)]
2025-05-24 00:28:09 +01:00
pub enum TesterCommand {
2024-08-28 04:09:46 +00:00
Panic,
Failure,
2024-04-29 13:56:04 -07:00
Tester,
2024-06-23 07:11:00 +00:00
Timer,
}
2024-08-28 04:09:46 +00:00
#[rustfmt::skip]
#[admin_command]
async fn panic(&self) -> Result {
2024-08-28 04:09:46 +00:00
panic!("panicked")
}
#[rustfmt::skip]
#[admin_command]
async fn failure(&self) -> Result {
2024-08-28 04:09:46 +00:00
Err!("failed")
}
2024-06-23 07:11:00 +00:00
#[inline(never)]
#[rustfmt::skip]
2024-07-27 00:11:41 +00:00
#[admin_command]
async fn tester(&self) -> Result {
2024-06-23 07:11:00 +00:00
self.write_str("Ok").await
2024-06-23 07:11:00 +00:00
}
#[inline(never)]
#[rustfmt::skip]
2024-07-27 00:11:41 +00:00
#[admin_command]
async fn timer(&self) -> Result {
2024-06-23 07:11:00 +00:00
let started = std::time::Instant::now();
2024-07-27 00:11:41 +00:00
timed(self.body);
2024-06-23 07:11:00 +00:00
let elapsed = started.elapsed();
self.write_str(&format!("completed in {elapsed:#?}")).await
2024-04-29 13:56:04 -07:00
}
2024-06-23 07:11:00 +00:00
#[inline(never)]
#[rustfmt::skip]
#[allow(unused_variables)]
fn timed(body: &[&str]) {
2024-04-29 13:56:04 -07:00
}