Testing library tlib documentation
tlib.test
This function is a wrapped version of wlib.test.mkTestScript specific to the nix-wrapper-modules repository.
The tlib variable recieved by the tests in the nix-wrapper-modules repository contains all the values in
wlib.test, plus this function.
Unlike wlib.test.mkTestScript this version returns a derivation rather than a string,
and has more options available for the first argument.
This function takes tests provided as an attribute set in testSet, renders it to a bash script,
and executes the rendered script using pkgs.runCommand.
If the command runs successfully, the test set passes. Otherwise, a detailed error message describing the failed assertion is shown in the logs.
Type
test :: (String | AttrSet) -> TestSet -> Derivation
where:
TestSet :: Test | attrsOf (TestSet | Test)
Test :: Assertion | [ Assertion ]
Assertion :: String | { cond :: String; msg :: String; }
Arguments
- settings
-
Either a string or an attrs.
If it is a string, it will be taken as the name of the derivation built by
runCommand.If it is a set, at least one of the keys
nameorwrapperneed to be set with a string value.- If you are defining tests for wrappers you should set
settings.wrapperto the name of the wrapper. This way, thewrapper.meta.platformsis considered during test execution, and the test will only be run if the system it is running on is supported. - If
settings.wrapperis not set, the test will always be run. This makes sense if you are testing core options or library functions. - If only
settings.wrapperis set, the name will be derived from this value by suffixing it with-test. - If
settings.nameis set, it will be taken as the name of the derivation. - If both are set,
settings.nametakes precedence.
There is also an optional boolean option
settings.debug(default =false). If it is set totrue, the generated bash script is built as an executable script that can be inspected and run inresultwhen running a specific test.The test can be disabled by setting
settings.enable = false. - If you are defining tests for wrappers you should set
- testSet
-
The set of tests to run.