From c7d3cf96f28756f126db2c413788c65ff14548ab Mon Sep 17 00:00:00 2001 From: evan-schott <53463459+evan-schott@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:19:35 -0700 Subject: [PATCH] Test CLI build command --- leo/cli/cli.rs | 33 +++++++++++++++++++++++++++++++++ leo/package/Cargo.toml | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/leo/cli/cli.rs b/leo/cli/cli.rs index c87c2fe1ed..64d80837f0 100644 --- a/leo/cli/cli.rs +++ b/leo/cli/cli.rs @@ -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(()) +} diff --git a/leo/package/Cargo.toml b/leo/package/Cargo.toml index 59c97f519d..7f3910ac4e 100644 --- a/leo/package/Cargo.toml +++ b/leo/package/Cargo.toml @@ -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"