From b56ddc3b5967a45225b341095d05260157694af3 Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 6 Jun 2021 22:24:53 +0900 Subject: [PATCH 1/4] Create a template for integration tests. --- tests/integration.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/integration.rs diff --git a/tests/integration.rs b/tests/integration.rs new file mode 100644 index 000000000..26a1f06ab --- /dev/null +++ b/tests/integration.rs @@ -0,0 +1,17 @@ +use std::env; +use std::process::{Command, Stdio}; + +#[test] +fn main() { + let path_result = env::current_dir(); + let path = match path_result { + Ok(path) => path.display().to_string(), + Err(_) => panic!("Path is not found"), + }; + let status = Command::new(path + "/target/x86_64-unknown-linux-gnu/debug/youki") + .stdout(Stdio::null()) + .arg("-h") + .status() + .expect("failed to execute process"); + assert!(status.success()); +} From 6b5d59d751a5bf6e836dee3c3145f4c7ed9179ca Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 6 Jun 2021 23:47:17 +0900 Subject: [PATCH 2/4] refactore --- tests/integration.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 26a1f06ab..76e6eac45 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,14 +1,16 @@ use std::env; use std::process::{Command, Stdio}; +use std::path::PathBuf; #[test] fn main() { - let path_result = env::current_dir(); - let path = match path_result { - Ok(path) => path.display().to_string(), - Err(_) => panic!("Path is not found"), + let current_dir_path_result = env::current_dir(); + let current_dir_path = match current_dir_path_result { + Ok(path_buf) => path_buf, + Err(_) => panic!("directory is not found"), }; - let status = Command::new(path + "/target/x86_64-unknown-linux-gnu/debug/youki") + let youki_path = current_dir_path.join(PathBuf::from("youki")); + let status = Command::new(youki_path) .stdout(Stdio::null()) .arg("-h") .status() From 02701d97f3db432d4db3f378bc024fe8a6bf3697 Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 6 Jun 2021 23:48:55 +0900 Subject: [PATCH 3/4] Run fmt --- tests/integration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration.rs b/tests/integration.rs index 76e6eac45..497ffdac6 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,6 +1,6 @@ use std::env; -use std::process::{Command, Stdio}; use std::path::PathBuf; +use std::process::{Command, Stdio}; #[test] fn main() { From 1c1aa2d2fa6c49d9eaffdd4623808024d08de705 Mon Sep 17 00:00:00 2001 From: oliver Date: Mon, 7 Jun 2021 18:23:10 +0900 Subject: [PATCH 4/4] Added doc on how to run integration tests --- tests/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/README.md diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 000000000..bacb5bc9e --- /dev/null +++ b/tests/README.md @@ -0,0 +1,8 @@ +# Integration test + +## Usage +Here is a preview implementation of the integration test. + +``` +$ cargo test --test integration +```