diff --git a/archived/licenses[WIP]/tools/test-gen-license/README.md b/archived/licenses[WIP]/tools/test-gen-license/README.md index 9f08c1c..7d30127 100644 --- a/archived/licenses[WIP]/tools/test-gen-license/README.md +++ b/archived/licenses[WIP]/tools/test-gen-license/README.md @@ -3,7 +3,7 @@ ## The purpose The 999.ICU project has many(now, the number is 3) license generator tools and it seems that the number of that will continue to grow. Thus I write this test tool to validate the functionality of the tools. -I hope the newly added tools must add test file and pass it. +I hope the newly added tools must add a test file and pass the tests. ## Usage For example, if you would like to add a license generator tool written by `ruby`, you just need to copy the `test_go.rs` file and rename it as `test_ruby.rs`, and replace the parameter in `arg()` of the test function. \ No newline at end of file diff --git a/archived/licenses[WIP]/tools/test-gen-license/tests/test_py.rs b/archived/licenses[WIP]/tools/test-gen-license/src/lib.rs similarity index 51% rename from archived/licenses[WIP]/tools/test-gen-license/tests/test_py.rs rename to archived/licenses[WIP]/tools/test-gen-license/src/lib.rs index e01dc2d..244a51c 100644 --- a/archived/licenses[WIP]/tools/test-gen-license/tests/test_py.rs +++ b/archived/licenses[WIP]/tools/test-gen-license/src/lib.rs @@ -1,19 +1,23 @@ +pub mod test_go; +pub mod test_py; +pub mod test_rust; + use assert_cmd::prelude::*; use dir_diff; use std::process::Command; use tempdir; use tempdir::TempDir; -/// todo: The python test is to be finished.. I'm having lunch now! #[test] -fn test_go_help() { - let path = "../gen_license/genlicense/__init_.py"; - let mut cmd = Command::new("python"); - cmd.arg("-h"); +fn test_rust_help() { + /// todo: compile rust executive file + let path = "cargo"; + let mut cmd = Command::new("run"); + /// todo: add directory + cmd.dir(""); // assert_eq!(output, help); let assert = cmd.assert(); assert.success().stdout( - /// todo: replace this r#"gen-license-go is a 996.icu license generator implemented in Go, this generator is developed to generate various open-source licenses including MIT, Apache, etc. More importantly, the main purpose of this tool is to incorporate those aforesaid licenses into @@ -34,20 +38,3 @@ Flags: Use "gen-license-go [command] --help" for more information about a command."#, ); } - -#[test] -fn test_go_create_license_mit() { - let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); - let path = if cfg!(targe_os = "windows") { - "../gen-license-go/bin/windows/gen-license-go.exe" - } else if cfg!(target_os = "linux") { - "../gen-license-go/bin/linux/gen-license-go" - } else { - "../gen-license-go/bin/osx/gen-license-go" - }; - let mut cmd = Command::new(&path); - cmd.arg("gen").arg("mit").arg("--996icu").args("en-us"); - assert!( - !dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap() - ); -} diff --git a/archived/licenses[WIP]/tools/test-gen-license/src/main.rs b/archived/licenses[WIP]/tools/test-gen-license/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/archived/licenses[WIP]/tools/test-gen-license/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/archived/licenses[WIP]/tools/test-gen-license/tests/test_go.rs b/archived/licenses[WIP]/tools/test-gen-license/src/test_go.rs similarity index 100% rename from archived/licenses[WIP]/tools/test-gen-license/tests/test_go.rs rename to archived/licenses[WIP]/tools/test-gen-license/src/test_go.rs diff --git a/archived/licenses[WIP]/tools/test-gen-license/src/test_py.rs b/archived/licenses[WIP]/tools/test-gen-license/src/test_py.rs new file mode 100644 index 0000000..280d925 --- /dev/null +++ b/archived/licenses[WIP]/tools/test-gen-license/src/test_py.rs @@ -0,0 +1,76 @@ +use assert_cmd::prelude::*; +use dir_diff; +use std::process::Command; +use tempdir; +use tempdir::TempDir; + +#[test] +fn test_go_help() { + let path = "../gen_license/genlicense/__init_.py"; + let mut cmd = Command::new("python"); + cmd.arg("-h"); + // assert_eq!(output, help); + let assert = cmd.assert(); + assert.success().stdout( + r#"gen-license-go is a 996.icu license generator implemented in Go, +this generator is developed to generate various open-source licenses including MIT, Apache, etc. +More importantly, the main purpose of this tool is to incorporate those aforesaid licenses into +a brand new license: 996.icu, defined by this repository. + +Usage: + gen-license-go [flags] + gen-license-go [command] + +Available Commands: + gen gen is a 996.icu license generator-command. + help Help about any command + +Flags: + -h, --help help for gen-license-go + -l, --list list all licenses (default true) + +Use "gen-license-go [command] --help" for more information about a command."#, + ); +} + +#[test] +fn test_py_create_license_mit() { + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); + let path = "../gen_license/genlicense/__init_.py"; + let mut cmd = Command::new("python"); + cmd.arg("gen").arg("mit").arg("--996icu").args("en-us"); + assert!( + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap() + ); +} + +#[test] +fn test_py_create_license_mit() { + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); + let path = "../gen_license/genlicense/__init_.py"; + let mut cmd = Command::new("python"); + cmd.arg("gen").arg("mit").arg("--996icu").args("en-us"); + assert!( + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap() + ); +} +#[test] +fn test_py_create_license_epl() { + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); + let path = "../gen_license/genlicense/__init_.py"; + let mut cmd = Command::new("python"); + cmd.arg("gen").arg("epl").arg("--996icu").args("en-us"); + assert!( + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license/licenses/epl-2.txt").unwrap() + ); +} +#[test] +fn test_py_create_license_gpl() { + let tmp_dir = TempDir::new("foo").expect("create temp dir failed"); + let path = "../gen_license/genlicense/__init_.py"; + let mut cmd = Command::new("python"); + cmd.arg("gen").arg("gpl").arg("--996icu").args("en-us"); + assert!( + !dir_diff::is_different(&tmp_dir.path(), "../../gen-license/licenses/gpl.txt").unwrap() + ); +} diff --git a/archived/licenses[WIP]/tools/test-gen-license/src/test_rust.rs b/archived/licenses[WIP]/tools/test-gen-license/src/test_rust.rs new file mode 100644 index 0000000..e69de29