diff --git a/CHANGELOG.md b/CHANGELOG.md index 7887148..a03f313 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * New json_encode command #124 * New json_parse command #124 +* Module level documentation #125 +* test_file command is now documented and public. ### v0.6.3 (2020-07-24) diff --git a/duckscript_sdk/src/sdk/std/test/test_directory/mod.rs b/duckscript_sdk/src/sdk/std/test/test_directory/mod.rs index 1dfb80c..00c1ff0 100755 --- a/duckscript_sdk/src/sdk/std/test/test_directory/mod.rs +++ b/duckscript_sdk/src/sdk/std/test/test_directory/mod.rs @@ -77,7 +77,7 @@ impl Command for CommandImpl { let test_script = format!( r#" -result = std::test::TestFile {} {} +result = test_file {} {} assert result "#, &file, &test_name diff --git a/duckscript_sdk/src/sdk/std/test/test_file/help.md b/duckscript_sdk/src/sdk/std/test/test_file/help.md new file mode 100644 index 0000000..43d5c6e --- /dev/null +++ b/duckscript_sdk/src/sdk/std/test/test_file/help.md @@ -0,0 +1,33 @@ +```sh +test_file file [test name] +``` + +This command can be used to run unit tests written in duckscript.
+It will run all test functions that start with **test_** in the given file.
+Each such function is considered as a test and can run any type of code and check itself using assert commands. + +#### Parameters + +* The file name containing the test functions. +* Optional pattern for the test function to limit invocation of only those tests. + +#### Return Value + +**true** if successful. + +#### Examples + +This is an example of a test function: + +```sh +function test_set_get_unset + unset_env TEST_SET_GET_UNSET + value = get_env TEST_SET_GET_UNSET + assert_false ${value} + + value = set_env TEST_SET_GET_UNSET "test value" + assert ${value} + value = get_env TEST_SET_GET_UNSET + assert_eq ${value} "test value" +end +``` diff --git a/duckscript_sdk/src/sdk/std/test/test_file/mod.rs b/duckscript_sdk/src/sdk/std/test/test_file/mod.rs index 179a5cb..9166ce2 100755 --- a/duckscript_sdk/src/sdk/std/test/test_file/mod.rs +++ b/duckscript_sdk/src/sdk/std/test/test_file/mod.rs @@ -30,8 +30,12 @@ impl Command for CommandImpl { pckg::concat(&self.package, "TestFile") } + fn aliases(&self) -> Vec { + vec!["test_file".to_string()] + } + fn help(&self) -> String { - "".to_string() + include_str!("help.md").to_string() } fn clone_and_box(&self) -> Box {