Test CLI build command

This commit is contained in:
evan-schott 2023-11-03 10:19:35 -07:00
parent da1419c2ab
commit c7d3cf96f2
2 changed files with 37 additions and 0 deletions

View File

@ -19,6 +19,7 @@ use leo_errors::Result;
use clap::Parser;
use colored::Colorize;
use leo_span::symbol::create_session_if_not_set_then;
use std::{path::PathBuf, process::exit};
/// CLI Arguments entry point - includes global parameters and subcommands
@ -133,3 +134,35 @@ pub fn run_with_args(cli: CLI) -> Result<()> {
Commands::Update { command } => command.try_execute(context),
}
}
#[test]
pub fn build_test() -> Result<()> {
const BUILD_DIRECTORY: &str = "utils/tmp/project";
let cli = CLI {
debug: false,
quiet: false,
command: Commands::Build { command: Build { options: Default::default() } },
path: Some(PathBuf::from(BUILD_DIRECTORY)),
};
create_session_if_not_set_then(|_| {
run_with_args(cli).expect("Failed to run build command");
});
Ok(())
}
#[test]
pub fn build_super_simple_test() -> Result<()> {
dbg!(std::env::current_dir().expect("TODO: panic message"));
const BUILD_DIRECTORY: &str = "utils/tmp/super_simple";
let cli = CLI {
debug: false,
quiet: false,
command: Commands::Build { command: Build { options: Default::default() } },
path: Some(PathBuf::from(BUILD_DIRECTORY)),
};
create_session_if_not_set_then(|_| {
run_with_args(cli).expect("Failed to run build command");
});
Ok(())
}

View File

@ -42,6 +42,10 @@ version = "0.8"
[dependencies.tracing]
version = "0.1"
[dependencies.retriever]
path = "../../utils/retriever"
version = "0.1"
[dev-dependencies.lazy_static]
version = "1.3.0"