-
Notifications
You must be signed in to change notification settings - Fork 1
Testing script source directly in test cases
- Source code in the act phase
- Executing a script file in a sandbox directory
- Setting the actor in a test suite
- Any language for which you have an interpreter can be used
Exactly can include source code as the "act" phase by using the "interpreter" actor.
Here is a test case with a bash script:
[conf]
actor = source % bash
[act]
echo 'sh
ash
bash'
[assert]
exit-code == 0
stdout equals <<EOF
sh
ash
bash
EOF
If 'my-bash-test.case' contains this test case Exactly can run it:
> exactly my-bash-test.case
PASS
Since the "act" phase is the default phase, a script source file is a valid test case, only it got no assertions. So, for example, a shell script 'my-script.sh' may be executed by Exactly:
> exactly --actor /bin/sh my-script.sh
PASS
Exactly will execute the script inside the temporary sandbox directory, as usual. So this is a way to test run a script in a sandbox.
The PASS outcome is not very useful though, since it will be the one and only outcome.
It is more useful to use the --act option to skip the PASS/FAIL information, and instead output
the output from the script:
> exactly --actor /bin/sh --act my-script.sh
<output from script>
Stdout, stderr and the exit code from Exactly will be that of 'my-script.sh'.
Unfortunately, there is currently no way to supply command line arguments to the my-script.sh program.
A test suite can specify which actor to use for every test case in it.
[conf]
actor = source % bash
[cases]
my-first-bash-test.case
my-second-bash-test.case
'hello.case' tests some Haskell:
[conf]
actor = source % runhaskell
[act]
import Data.List
main = mapM_ (putStrLn . hello) [1..3]
where
hello n = concat $ intersperse ", " $ replicate n "hello"
[assert]
exit-code == 0
stdout equals <<EOF
hello
hello, hello
hello, hello, hello
EOF
There are probably better ways to test your Haskell program, but hopefully this gives a hint of how actors can be used!