exactness: added simulate mode

Signed-off-by: Aharon Hillel <a.hillel@partner.samsung.com>

SVN revision: 66378
This commit is contained in:
Aharon Hillel 2011-12-20 09:12:18 +00:00 committed by Tom Hacohen
parent 17db9e1237
commit 17815fa441
2 changed files with 63 additions and 5 deletions

17
README
View File

@ -46,6 +46,20 @@ Testing with exactness composed of the following stages:
NOTE: You may change screenshot key from F2 to any other key
with TSUITE_SHOT_KEY env var.
After recording a new test you may use 'simulate' option to play test
with no effect to output files. Simulate option lets you to examine
a test-play on-screen without actually producing output PNG file.
To do this just run:
exactness -s [-b BaseDir] [TestName]
Example:
exactness -s test_check
This will play test_check.rec from cwd,
use the -b option to tell exactness to locate this file elsewhere.
2. Test Initiation.
The final stage of testing process is based on PNG image comparison
of original screenshots with current screenshots produced after code change.
@ -91,6 +105,7 @@ Testing with exactness composed of the following stages:
Write resulting PNG files at cwd/current (default) dir
along with comp_*.png files.
4. Comparing PNG files.
This is the final stage of testing in which we compare output
before code update and after the update.
@ -100,6 +115,7 @@ Testing with exactness composed of the following stages:
When all comparisons done you get final report of (N) files did not match.
In case difference was found, you may look at comp_*.png files in DestDir.
5. fail_if(expr) macro:
You may use fail_if(expr); macro to verify variable value on-the-fly.
For example, if your code contains:
@ -115,6 +131,7 @@ Testing with exactness composed of the following stages:
When tests completed, the user gets notification message if any tests failed.
In such case, please review the fail_*.txt files.
6. To view exactness help issue the command:
exactness --help
or

View File

@ -66,6 +66,20 @@ fi
return 0
}
do_simulation () {
# This will play simulation
# this will NOT produce screenshots
DEBUG echo do_simulation "\$*"
if [ -z "\$*" ]
then
exactness_raw --destdir "\$_dest_dir" --basedir "\$_base_dir" --tests
else
exactness_raw --destdir "\$_dest_dir" --basedir "\$_base_dir" --tests \$*
fi
return 0
}
do_play () {
# This will play record for all test if '-a' specified.
# or play record of tests specified as parameter.
@ -73,7 +87,6 @@ do_play () {
DEBUG echo base dir: "\$_base_dir"
DEBUG echo dest dir: "\$_dest_dir"
DEBUG echo do_play "\$_dest_dir" "\$*"
# Play recorded tests and produce PNG files.
# this will produce screenshots in "_dest_dir" folder
if [ -z "\$*" ]
@ -197,9 +210,21 @@ else
done
fi
echo "Processed \$ncomp comparisons"
echo "with \$nfail diff errors"
echo "\$nerr rec-files were not found"
if [ "\$ncomp" -ne 0 ]
then
echo "Processed \$ncomp comparisons"
fi
if [ "\$nfail" -ne 0 ]
then
echo "with \$nfail diff errors"
fi
if [ "\$nerr" -ne 0 ]
then
echo "\$nerr PNG-files were not found"
fi
return 0
}
@ -208,6 +233,7 @@ _record=
_play=
_compare=
_init=
_simulation=
_remove_fail=
_orig_dir="orig"
# Init dest_dir - should change on the fly
@ -222,7 +248,7 @@ nfail=0
which compare &> /dev/null
comp_unavail=\$?
while getopts 'ab:cd:hpri?' OPTION
while getopts 'ab:cd:hpris?' OPTION
do
case \$OPTION in
b) _base_dir="\$OPTARG"
@ -243,6 +269,9 @@ do
_play=1
_remove_fail=1
;;
s) _dest_dir="\$_orig_dir"
_simulation=1
;;
h) do_help
exit 0
;;
@ -256,6 +285,18 @@ shift \$((\$OPTIND - 1))
DEBUG echo _base_dir="\$_base_dir"
DEBUG echo _dest_dir="\$_dest_dir"
if [ "\$_simulation" ]
then
# When in simulation mode, we will just commit play (ignore other options)
_init=
_record=
_compare=
_remove_fail=
_play=
do_simulation "\$*"
# This will cause render simulation
fi
if [ ! -e "\$_base_dir" ]
then
echo "Base dir <\$_base_dir> - not found."