Skip to content

Commit b094bd8

Browse files
committed
add more function to test tools
1 parent 80cc632 commit b094bd8

File tree

6 files changed

+87
-27
lines changed

6 files changed

+87
-27
lines changed

archived/licenses[WIP]/tools/test-gen-license/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## The purpose
44
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.
55

6-
I hope the newly added tools must add test file and pass it.
6+
I hope the newly added tools must add a test file and pass the tests.
77

88
## Usage
99
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.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
pub mod test_go;
2+
pub mod test_py;
3+
pub mod test_rust;
4+
15
use assert_cmd::prelude::*;
26
use dir_diff;
37
use std::process::Command;
48
use tempdir;
59
use tempdir::TempDir;
610

7-
/// todo: The python test is to be finished.. I'm having lunch now!
811
#[test]
9-
fn test_go_help() {
10-
let path = "../gen_license/genlicense/__init_.py";
11-
let mut cmd = Command::new("python");
12-
cmd.arg("-h");
12+
fn test_rust_help() {
13+
/// todo: compile rust executive file
14+
let path = "cargo";
15+
let mut cmd = Command::new("run");
16+
/// todo: add directory
17+
cmd.dir("");
1318
// assert_eq!(output, help);
1419
let assert = cmd.assert();
1520
assert.success().stdout(
16-
/// todo: replace this
1721
r#"gen-license-go is a 996.icu license generator implemented in Go,
1822
this generator is developed to generate various open-source licenses including MIT, Apache, etc.
1923
More importantly, the main purpose of this tool is to incorporate those aforesaid licenses into
@@ -34,20 +38,3 @@ Flags:
3438
Use "gen-license-go [command] --help" for more information about a command."#,
3539
);
3640
}
37-
38-
#[test]
39-
fn test_go_create_license_mit() {
40-
let tmp_dir = TempDir::new("foo").expect("create temp dir failed");
41-
let path = if cfg!(targe_os = "windows") {
42-
"../gen-license-go/bin/windows/gen-license-go.exe"
43-
} else if cfg!(target_os = "linux") {
44-
"../gen-license-go/bin/linux/gen-license-go"
45-
} else {
46-
"../gen-license-go/bin/osx/gen-license-go"
47-
};
48-
let mut cmd = Command::new(&path);
49-
cmd.arg("gen").arg("mit").arg("--996icu").args("en-us");
50-
assert!(
51-
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap()
52-
);
53-
}

archived/licenses[WIP]/tools/test-gen-license/src/main.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
use assert_cmd::prelude::*;
2+
use dir_diff;
3+
use std::process::Command;
4+
use tempdir;
5+
use tempdir::TempDir;
6+
7+
#[test]
8+
fn test_go_help() {
9+
let path = "../gen_license/genlicense/__init_.py";
10+
let mut cmd = Command::new("python");
11+
cmd.arg("-h");
12+
// assert_eq!(output, help);
13+
let assert = cmd.assert();
14+
assert.success().stdout(
15+
r#"gen-license-go is a 996.icu license generator implemented in Go,
16+
this generator is developed to generate various open-source licenses including MIT, Apache, etc.
17+
More importantly, the main purpose of this tool is to incorporate those aforesaid licenses into
18+
a brand new license: 996.icu, defined by this repository.
19+
20+
Usage:
21+
gen-license-go [flags]
22+
gen-license-go [command]
23+
24+
Available Commands:
25+
gen gen is a 996.icu license generator-command.
26+
help Help about any command
27+
28+
Flags:
29+
-h, --help help for gen-license-go
30+
-l, --list list all licenses (default true)
31+
32+
Use "gen-license-go [command] --help" for more information about a command."#,
33+
);
34+
}
35+
36+
#[test]
37+
fn test_py_create_license_mit() {
38+
let tmp_dir = TempDir::new("foo").expect("create temp dir failed");
39+
let path = "../gen_license/genlicense/__init_.py";
40+
let mut cmd = Command::new("python");
41+
cmd.arg("gen").arg("mit").arg("--996icu").args("en-us");
42+
assert!(
43+
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap()
44+
);
45+
}
46+
47+
#[test]
48+
fn test_py_create_license_mit() {
49+
let tmp_dir = TempDir::new("foo").expect("create temp dir failed");
50+
let path = "../gen_license/genlicense/__init_.py";
51+
let mut cmd = Command::new("python");
52+
cmd.arg("gen").arg("mit").arg("--996icu").args("en-us");
53+
assert!(
54+
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license-go/licenses/mit.txt").unwrap()
55+
);
56+
}
57+
#[test]
58+
fn test_py_create_license_epl() {
59+
let tmp_dir = TempDir::new("foo").expect("create temp dir failed");
60+
let path = "../gen_license/genlicense/__init_.py";
61+
let mut cmd = Command::new("python");
62+
cmd.arg("gen").arg("epl").arg("--996icu").args("en-us");
63+
assert!(
64+
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license/licenses/epl-2.txt").unwrap()
65+
);
66+
}
67+
#[test]
68+
fn test_py_create_license_gpl() {
69+
let tmp_dir = TempDir::new("foo").expect("create temp dir failed");
70+
let path = "../gen_license/genlicense/__init_.py";
71+
let mut cmd = Command::new("python");
72+
cmd.arg("gen").arg("gpl").arg("--996icu").args("en-us");
73+
assert!(
74+
!dir_diff::is_different(&tmp_dir.path(), "../../gen-license/licenses/gpl.txt").unwrap()
75+
);
76+
}

archived/licenses[WIP]/tools/test-gen-license/src/test_rust.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)