This commit is contained in:
VitalyR
2019-04-05 13:06:50 +08:00
parent e2726780b3
commit 3ef348ee02
9 changed files with 640 additions and 1 deletions

View File

@ -0,0 +1,3 @@
/target
**/*.rs.bk
.idea/*

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="JavaScriptSettings"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" /> <option name="languageLevel" value="ES6" />
</component> </component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
</component>
</project> </project>

View File

@ -1,7 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4"> <module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/benches" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>

View File

@ -0,0 +1,301 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "assert_cmd"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"escargot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"predicates 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cfg-if"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "dir-diff"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "escargot"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "itoa"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "predicates"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "predicates-core"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "predicates-tree"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand_core"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "remove_dir_all"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ryu"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "same-file"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde"
version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_derive"
version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_json"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.15.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tempdir"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "test-gen-license"
version = "0.1.0"
dependencies = [
"assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dir-diff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "treeline"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "walkdir"
version = "2.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-util"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2dc477793bd82ec39799b6f6b3df64938532fdf2ab0d49ef817eac65856a5a1e"
"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4"
"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
"checksum dir-diff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce6e50ca36311e494793f7629014dc78cd963ba85cd05968ae06a63b867f0b"
"checksum escargot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ceb9adbf9874d5d028b5e4c5739d22b71988252b25c9c98fe7cf9738bee84597"
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14"
"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum predicates 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa984b7cd021a0bf5315bcce4c4ae61d2a535db2a8d288fc7578638690a7b7c3"
"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178"
"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124"
"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915"
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7"
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4"
"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79"
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2"
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -0,0 +1,10 @@
[package]
name = "test-gen-license"
version = "0.1.0"
authors = ["VitalyR <vitalyankh@gmail.com>"]
edition = "2018"
[dependencies]
assert_cmd = "0.11.1"
dir-diff = "0.3.1"
tempdir = "0.3.7"

View File

@ -0,0 +1,9 @@
# Test for license generator tools
## 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.
## 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.

View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,248 @@
use assert_cmd::prelude::*;
use dir_diff;
use std::process::Command;
use tempdir;
use tempdir::TempDir;
#[test]
fn test_go_help() {
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("-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_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()
);
}
#[test]
fn test_go_create_license_996icu() {
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("--996icu").arg("--996icu").args("en-us");
assert!(!dir_diff::is_different(
&tmp_dir.path(),
"../../gen-license-go/licenses/996.icu.template.en-us.txt"
)
.unwrap());
}
#[test]
fn test_go_create_license_agpl() {
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("--agpl-3.0")
.arg("--996icu")
.args("en-us");
assert!(!dir_diff::is_different(
&tmp_dir.path(),
"../../gen-license-go/licenses/agpl-3.0.txt"
)
.unwrap());
}
#[test]
fn test_go_create_license_apache() {
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("--apache-2.0")
.arg("--996icu")
.args("en-us");
assert!(!dir_diff::is_different(
&tmp_dir.path(),
"../../gen-license-go/licenses/apache-2.0.txt"
)
.unwrap());
}
#[test]
fn test_go_create_license_bsd_2() {
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("--bsd-2-clause")
.arg("--996icu")
.args("en-us");
assert!(!dir_diff::is_different(
&tmp_dir.path(),
"../../gen-license-go/licenses/bsd-2-clause.txt"
)
.unwrap());
}
#[test]
fn test_go_create_license_bsd_3() {
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("bsd-3-clause")
.arg("--996icu")
.args("en-us");
assert!(!dir_diff::is_different(
&tmp_dir.path(),
"../../gen-license-go/licenses/bsd-3-clause.txt"
)
.unwrap());
}
#[test]
fn test_go_create_license_epl() {
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("epl-2.0").arg("--996icu").args("en-us");
assert!(
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/996.txt").unwrap()
);
}
#[test]
fn test_go_create_license_996() {
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("--996");
assert!(
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/996.txt").unwrap()
);
}
#[test]
fn test_go_create_license_996() {
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("--996");
assert!(
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/996.txt").unwrap()
);
}
#[test]
fn test_go_create_license_996() {
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("--996");
assert!(
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/996.txt").unwrap()
);
}
#[test]
fn test_go_create_license_996() {
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("--996");
assert!(
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/996.txt").unwrap()
);
}

View File

@ -0,0 +1,53 @@
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");
// 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
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_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()
);
}