Skip to content

Commit

Permalink
test(garden-sea): add version smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefreak committed Nov 3, 2023
1 parent 0ce9756 commit 6d32cb9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
29 changes: 27 additions & 2 deletions garden-sea/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
env::{Args, self},
env,
ffi::OsString,
path::Path,
process::{Child, Command},
Expand All @@ -10,7 +10,10 @@ use eyre::{Result, WrapErr};

use crate::{log::debug, signal};

pub(crate) fn spawn_garden(path: &Path, sea_args: Args) -> Result<Child> {
pub(crate) fn spawn_garden<T>(path: &Path, sea_args: T) -> Result<Child>
where
T: Iterator<Item = String>,
{
#[cfg(unix)]
let node = "bin/node";
#[cfg(windows)]
Expand Down Expand Up @@ -74,3 +77,25 @@ pub(crate) fn wait(mut child: Child) -> Result<Option<i32>> {

return Ok(None);
}

#[cfg(test)]
mod tests {
use crate::{node::spawn_garden, extract::extract_archives_if_needed};

use super::wait;

#[test]
fn test_garden_version() {
let directories = directories::ProjectDirs::from("io", "garden", "garden-test")
.expect("Failed to get temporary directory");

let root_path = directories.data_dir();

// This test mostly ensures that we have no panic due to corrupt archives in release builds.
let result = extract_archives_if_needed(root_path).expect("Failed self-extract");

let child = spawn_garden(&result, ["garden".into(), "version".into()].into_iter()).expect("Failed to spawn garden");
let return_code = wait(child).expect("Failed waiting for garden").unwrap();
assert!(return_code == 0);
}
}
1 change: 1 addition & 0 deletions garden-sea/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use lazy_static::lazy_static;
use crate::log::debug;
use crate::terminate;

#[cfg(windows)]
#[derive(Debug)]
enum Signal {
CtrlC,
Expand Down

0 comments on commit 6d32cb9

Please sign in to comment.