From 66cd1e82276708c0a355989eb7eb672f56b6c770 Mon Sep 17 00:00:00 2001 From: everpcpc Date: Wed, 18 Oct 2023 08:09:47 +0800 Subject: [PATCH] fix(core): allow stage with empty path --- cli/src/session.rs | 2 +- core/src/stage.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cli/src/session.rs b/cli/src/session.rs index 4a11ccaa1..13fa6e3cc 100644 --- a/cli/src/session.rs +++ b/cli/src/session.rs @@ -198,7 +198,7 @@ impl Session { None => 0.0, Some(ss) => ss.running_time_ms, }; - println!("{:.6}", server_time_ms / 1000.0); + println!("{:.3}", server_time_ms / 1000.0); } } Ok(()) diff --git a/core/src/stage.rs b/core/src/stage.rs index ce1e8f103..83b36a590 100644 --- a/core/src/stage.rs +++ b/core/src/stage.rs @@ -36,9 +36,7 @@ impl TryFrom<&str> for StageLocation { .next() .ok_or_else(|| Error::Parsing(format!("Invalid stage location: {}", s)))? .trim_start_matches('@'); - let path = parts - .next() - .ok_or_else(|| Error::Parsing(format!("Invalid stage location: {}", s)))?; + let path = parts.next().unwrap_or_default(); Ok(Self { name: name.to_string(), path: path.to_string(), @@ -69,6 +67,15 @@ mod test { Ok(()) } + #[test] + fn parse_stage_empty_path() -> Result<()> { + let location = "@stage_name"; + let stage = StageLocation::try_from(location)?; + assert_eq!(stage.name, "stage_name"); + assert_eq!(stage.path, ""); + Ok(()) + } + #[test] fn parse_stage_fail() -> Result<()> { let location = "stage_name/path/to/file";