Skip to content

Commit

Permalink
new: don't write ci annotations (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson authored May 14, 2024
1 parent 4e42c3d commit 5bb0ca6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 18 deletions.
52 changes: 41 additions & 11 deletions bin/src/commands/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ pub fn cli() -> Command {
pub fn execute(matches: &ArgMatches) -> Result<Report, Error> {
let mut report = Report::new();

if !std::io::stdin().is_terminal() {
let test_mode = matches.get_flag("in-test");

if !test_mode && !std::io::stdin().is_terminal() {
report.error(TerminalNotInput::code());
return Ok(report);
}
Expand All @@ -52,20 +54,48 @@ pub fn execute(matches: &ArgMatches) -> Result<Report, Error> {
}

println!("Example: Advanced Banana Environment");
let full_name: String = Input::new().with_prompt("Project Name").interact_text()?;
let full_name: String = if test_mode {
String::from("Advanced Banana Environment")
} else {
Input::new().with_prompt("Project Name").interact_text()?
};

println!("Example: ABE Team");
let author: String = Input::new().with_prompt("Author").interact_text()?;
let author: String = if test_mode {
String::from("ABE Team")
} else {
Input::new().with_prompt("Author").interact_text()?
};

println!("Example: abe");
let prefix: String = Input::new().with_prompt("Prefix").interact_text()?;

let mainprefix: String = Input::new()
.with_prompt("Main Prefix")
.with_initial_text("z")
.interact_text()?;

let license = Licenses::select(&author);
let prefix: String = if test_mode {
String::from("abe")
} else {
Input::new().with_prompt("Prefix").interact_text()?
};

let mainprefix: String = if test_mode {
String::from("z")
} else {
Input::new()
.with_prompt("Main Prefix")
.with_initial_text("z")
.interact_text()?
};

let license = if test_mode {
Some(
String::from_utf8(
Licenses::get("apl-sa.txt")
.expect("apl-sa should exist")
.data
.to_vec(),
)
.expect("license should be utf8"),
)
} else {
Licenses::select(&author)
};

create_dir(path)?;
create_dir(path.join("addons"))?;
Expand Down
5 changes: 4 additions & 1 deletion bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn cli() -> Command {
global = global
.arg(
clap::Arg::new("in-test")
.hide(true)
.global(true)
.help("we are in a test")
.action(ArgAction::SetTrue)
Expand Down Expand Up @@ -142,7 +143,9 @@ pub fn execute(matches: &ArgMatches) -> Result<(), Error> {
};
if let Some(report) = report? {
report.write_to_stdout();
report.write_ci_annotations()?;
if !matches.subcommand_name().is_some_and(|s| s == "new") {
report.write_ci_annotations()?;
}
if report.failed() {
std::process::exit(1);
}
Expand Down
15 changes: 9 additions & 6 deletions bin/tests/build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#![allow(clippy::unwrap_used)]

use sealed_test::prelude::*;

use hemtt::cli;

#[test]
/// # Panics
/// Will panic if there is an issue with the test
pub fn build() {
std::env::set_current_dir("tests/alpha").unwrap();
#[sealed_test]
fn build_alpha() {
std::env::set_current_dir(format!("{}/tests/alpha", env!("CARGO_MANIFEST_DIR"))).unwrap();
hemtt::execute(&cli().get_matches_from(vec!["hemtt", "dev", "--in-test"])).unwrap();
hemtt::execute(&cli().get_matches_from(vec!["hemtt", "build", "--in-test"])).unwrap();
}

std::env::set_current_dir("../bravo").unwrap();
#[sealed_test]
fn build_bravo() {
std::env::set_current_dir(format!("{}/tests/bravo", env!("CARGO_MANIFEST_DIR"))).unwrap();
hemtt::execute(&cli().get_matches_from(vec!["hemtt", "script", "test"])).unwrap();
hemtt::execute(&cli().get_matches_from(vec!["hemtt", "release", "--in-test"])).unwrap();
}
10 changes: 10 additions & 0 deletions bin/tests/new.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![allow(clippy::unwrap_used)]

use hemtt::cli;

use sealed_test::prelude::*;

#[sealed_test]
fn new() {
hemtt::execute(&cli().get_matches_from(vec!["hemtt", "new", "test", "--in-test"])).unwrap();
}

0 comments on commit 5bb0ca6

Please sign in to comment.