mirror of
https://github.com/sagiegurari/duckscript
synced 2024-10-14 11:53:05 +00:00
test_file command is now documented and public
This commit is contained in:
parent
4bc3045a7c
commit
2879050cab
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
* New json_encode command #124
|
* New json_encode command #124
|
||||||
* New json_parse 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)
|
### v0.6.3 (2020-07-24)
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl Command for CommandImpl {
|
||||||
|
|
||||||
let test_script = format!(
|
let test_script = format!(
|
||||||
r#"
|
r#"
|
||||||
result = std::test::TestFile {} {}
|
result = test_file {} {}
|
||||||
assert result
|
assert result
|
||||||
"#,
|
"#,
|
||||||
&file, &test_name
|
&file, &test_name
|
||||||
|
|
33
duckscript_sdk/src/sdk/std/test/test_file/help.md
Normal file
33
duckscript_sdk/src/sdk/std/test/test_file/help.md
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
```sh
|
||||||
|
test_file file [test name]
|
||||||
|
```
|
||||||
|
|
||||||
|
This command can be used to run unit tests written in duckscript.<br>
|
||||||
|
It will run all test functions that start with **test_** in the given file.<br>
|
||||||
|
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
|
||||||
|
```
|
|
@ -30,8 +30,12 @@ impl Command for CommandImpl {
|
||||||
pckg::concat(&self.package, "TestFile")
|
pckg::concat(&self.package, "TestFile")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn aliases(&self) -> Vec<String> {
|
||||||
|
vec!["test_file".to_string()]
|
||||||
|
}
|
||||||
|
|
||||||
fn help(&self) -> String {
|
fn help(&self) -> String {
|
||||||
"".to_string()
|
include_str!("help.md").to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clone_and_box(&self) -> Box<dyn Command> {
|
fn clone_and_box(&self) -> Box<dyn Command> {
|
||||||
|
|
Loading…
Reference in a new issue