mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
allow extra test args
This commit is contained in:
parent
8100c9b66e
commit
818092fda8
2 changed files with 16 additions and 16 deletions
18
src/args.rs
18
src/args.rs
|
|
@ -18,7 +18,7 @@ pub enum HazeArgs {
|
|||
},
|
||||
Test {
|
||||
options: CloudOptions,
|
||||
path: Option<String>,
|
||||
args: Vec<String>,
|
||||
},
|
||||
Exec {
|
||||
filter: Option<String>,
|
||||
|
|
@ -90,11 +90,8 @@ impl HazeArgs {
|
|||
HazeCommand::Test => {
|
||||
let mut args = args.peekable();
|
||||
let options = CloudOptions::parse(&mut args)?;
|
||||
let path = args.next().map(S::into);
|
||||
if let Some(leftover) = args.next() {
|
||||
return Err(Report::msg(format!("unrecognized option {}", leftover)));
|
||||
}
|
||||
Ok(HazeArgs::Test { options, path })
|
||||
let args = args.map(S::into).collect();
|
||||
Ok(HazeArgs::Test { options, args })
|
||||
}
|
||||
HazeCommand::Exec => Ok(HazeArgs::Exec {
|
||||
filter,
|
||||
|
|
@ -188,7 +185,7 @@ fn test_arg_parse() {
|
|||
HazeArgs::parse(vec!["haze", "test"].into_iter()).unwrap(),
|
||||
HazeArgs::Test {
|
||||
options: Default::default(),
|
||||
path: None
|
||||
args: vec![]
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
@ -217,4 +214,11 @@ fn test_arg_parse() {
|
|||
command: vec!["foo".to_string(), "bar".to_string()],
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
HazeArgs::parse(vec!["haze", "test", "foo", "bar"].into_iter()).unwrap(),
|
||||
HazeArgs::Test {
|
||||
options: Default::default(),
|
||||
args: vec!["foo".into(), "bar".into()]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
14
src/main.rs
14
src/main.rs
|
|
@ -144,7 +144,7 @@ async fn main() -> Result<()> {
|
|||
None => eprintln!("{} is not running", cloud.id),
|
||||
}
|
||||
}
|
||||
HazeArgs::Test { options, path } => {
|
||||
HazeArgs::Test { options, mut args } => {
|
||||
let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||
println!("Waiting for servers to start");
|
||||
cloud.wait_for_start(&mut docker).await?;
|
||||
|
|
@ -164,7 +164,8 @@ async fn main() -> Result<()> {
|
|||
cloud.destroy(&mut docker).await?;
|
||||
return Err(e);
|
||||
}
|
||||
if let Some(app) = path
|
||||
if let Some(app) = args
|
||||
.first()
|
||||
.as_ref()
|
||||
.and_then(|path| path.strip_prefix("apps/"))
|
||||
.map(|path| &path[0..path.find('/').unwrap_or(path.len())])
|
||||
|
|
@ -175,13 +176,8 @@ async fn main() -> Result<()> {
|
|||
println!("Enabling {}", app);
|
||||
cloud.enable_app(&mut docker, app).await?;
|
||||
}
|
||||
cloud
|
||||
.exec(
|
||||
&mut docker,
|
||||
vec!["tests".to_string(), path.unwrap_or_default()],
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
args.insert(0, "tests".to_string());
|
||||
cloud.exec(&mut docker, args, false).await?;
|
||||
cloud.destroy(&mut docker).await?;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue