You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The actual porting process is not too hard. The old test suite is just a set of shell scripts in test/ that call exiv2 repeatedly, collect the output of the whole script and compare it to a binary output file (it is under test/data/ and has the same name as the script, but with the ending .out instead of .sh).
and the corresponding output from test/data/bugfixes-test.out
------> Bug 426 <-------
Iptc.Application2.RecordVersion Short 1 2
Iptc.Application2.FixtureId String 22 2005 Oregon Coast Tour
Iptc.Application2.Byline String 14 Julie V. Early
Iptc.Application2.City String 21 159 km SW of Portland
Iptc.Application2.ProvinceState String 6 Oregon
Iptc.Application2.CountryName String 13 United States
Iptc.Application2.Contact String 16 Jeffrey J. Early
The new test suite on the other hand uses Python's unit test suite to perform the same task. In addition to that, it check the standard output & error separately and also checks the return value.
Each issue should have its own python test file, which has roughly this form:
This file should be located in an appropriate directory under tests/, in that directory must be an empty file called __init__.py and the file must have the prefix test_ (otherwise python's test collector will ignore it).
Most issues can be ported rather easily (using the excerpt from bugfixes-test.sh):
Create a new file under tests/ with an appropriate name. E.g. tests/bugfixes/redmine/test_issue_426.py
Insert the python class skeleton.
Identify the reproducer which is run, either its name is written in the script or it is created via prep_file. prep_file $num means that the file is called exiv2-bug$num.jpg. Write this name into the python class into the variable filename, prefixed with $data_path and wrap it in system_tests.path() (for Windows path support). For the example, you'll get: filename = system_tests.path("$data_path/exiv2-bug426.jpg").
Extract the command from the script, that is the part after runTest.
Run the reproducer, to obtain the stdout, stderr & return value and write them as python strings into the class.
For issue 426 we'll end up with something like this:
# -*- coding: utf-8 -*-importsystem_testsclassReadIPTfromJPEG(metaclass=system_tests.CaseMeta):
url="http://dev.exiv2.org/issues/426"filename=system_tests.path("$data_path/exiv2-bug426.jpg")
commands= ["exiv2 -u -pi $filename"]
stdout= ["""Iptc.Application2.RecordVersion Short 1 2Iptc.Application2.FixtureId String 22 2005 Oregon Coast TourIptc.Application2.Byline String 14 Julie V. EarlyIptc.Application2.City String 21 159 km SW of PortlandIptc.Application2.ProvinceState String 6 OregonIptc.Application2.CountryName String 13 United StatesIptc.Application2.Contact String 16 Jeffrey J. Early"""]
stderr= [""]
retval= [0]
Remarks
Not all output from exiv2 is useful. Especially stderr is often cluttered with error messages about which we do not really care. In that case, leave stderr empty and instead set the following inside the python class (thereby the actual output will be ignored except for error messages from ASAN and UBSAN):
We can close this one now. The python test suite in tests/system_tests.py is working extremely well. The remaining bash tests have been implemented in python in tests/bash_tests/. @1div0 has agreed to take on the maintenance of the python code for v1.00. I think Peter is going to enjoy working on this valuable and useful code.
We need to retire the old test suite so that we can move forward with #180 and other patches.
Unfortunately, that is a lot of grind work. So, if you happen to have a little time at your hand, please help.
Progress
The main focus should be on the regression tests:
The remaining ones have lower priority:
Porting guide
The actual porting process is not too hard. The old test suite is just a set of shell scripts in
test/
that callexiv2
repeatedly, collect the output of the whole script and compare it to a binary output file (it is undertest/data/
and has the same name as the script, but with the ending.out
instead of.sh
).Example from
test/bugfixes-test.sh
:and the corresponding output from
test/data/bugfixes-test.out
The new test suite on the other hand uses Python's unit test suite to perform the same task. In addition to that, it check the standard output & error separately and also checks the return value.
Each issue should have its own python test file, which has roughly this form:
This file should be located in an appropriate directory under
tests/
, in that directory must be an empty file called__init__.py
and the file must have the prefixtest_
(otherwise python's test collector will ignore it).Most issues can be ported rather easily (using the excerpt from
bugfixes-test.sh
):tests/
with an appropriate name. E.g.tests/bugfixes/redmine/test_issue_426.py
prep_file
.prep_file $num
means that the file is calledexiv2-bug$num.jpg
. Write this name into the python class into the variablefilename
, prefixed with$data_path
and wrap it insystem_tests.path()
(for Windows path support). For the example, you'll get:filename = system_tests.path("$data_path/exiv2-bug426.jpg")
.runTest
.For issue 426 we'll end up with something like this:
Remarks
The text was updated successfully, but these errors were encountered: