<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 20, 2015 at 5:08 PM, Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@gmail.com" target="_blank">markus.metz.giswork@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On Sat, Jan 17, 2015 at 10:21 PM, Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:<br>
><br>
><br>
> On Sat, Jan 17, 2015 at 2:40 PM, Markus Metz <<a href="mailto:markus.metz.giswork@gmail.com">markus.metz.giswork@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Fri, Jan 16, 2015 at 11:25 PM, Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>><br>
>> wrote:<br>
>> > On Fri, Jan 16, 2015 at 10:01 AM, Markus Metz<br>
>> > <<a href="mailto:markus.metz.giswork@gmail.com">markus.metz.giswork@gmail.com</a>> wrote:<br>
>> >><br>
>> >> The fixes are all thoroughly tested (I guess I have never<br>
>> >> before tested vector topology so thoroughly...).<br>
>> ><br>
>> ><br>
>> > Hi Markus,<br>
>> ><br>
>> > will you be able to turn your tests into testsuite scripts? It is<br>
>> > additional<br>
>> > work but it gives us possibility to ensure that nobody will break what<br>
>> > you<br>
>> > did and it should save it your time in the long run.<br>
>><br>
>> I modified v.generalize in my local copy to become a topology<br>
>> debugging tool. The debugging tools could be activated with an<br>
>> environment variable which would need to be set by the test suite.<br>
>><br>
> Setting environmental variable should be easy in the test suite. I'm not<br>
> sure about the v.generalize modification. Topology debugging tool sound's<br>
> generally useful. Perhaps it could be part of v.generalize interface or a<br>
> standalone module (build with v.generalize in the same way as r.colors and<br>
> r3.colors are) but for tests it really doesn't matter.<br>
><br>
>> If I turn the tests into a test suite script, I will use a vector from<br>
>> the the full version of the North Carolina sample dataset. Is this ok?<br>
><br>
><br>
> This is ok. MarkusN says we should use the new dataset but I think it is not<br>
> yet stable.<br>
>><br>
>><br>
>> ><br>
>> > Let me know if you miss something in testing framework which would help<br>
>> > you<br>
>> > to write the tests.<br>
>><br>
>> I would like to provide a command and the test suite must check the<br>
>> return status. If someone else could then turn this into a testsuite<br>
>> script, that would be great!<br>
>><br>
> Any .sh or .py script you put to testsuite directory anywhere in GRASS<br>
> source code will be executed as test, so in your case, it should be enough<br>
> just to put the command to .sh file together with the appropriate export<br>
> command for the environmental variable. I'm afraid this feature is not<br>
> really documented (except for emails) because I did it in last minute and it<br>
> is not the best practice. Anyway, posting command is fine if the only thing<br>
> needed is to check return status.<br>
<br>
</div></div>For nc_spm_08, the test commands would be (as shell script):<br>
<br>
g.region -p rast=landuse96_28m@PERMANENT<br>
r.to.vect in=landuse96_28m@PERMANENT out=landuse96_28m type=area<br>
export GRASS_VECTOR_TOPO_DEBUG=1<br>
# check return code of<br>
v.generalize in=landuse96_28m out=landuse96_28m_dp method=douglas threshold=21<br>
if [ $? -ne 0 ] ; then<br>
exit 1<br>
fi<br>
<br></blockquote><div><div>Done in r64269 [1]. To run, start GRASS and execute [2]:<br></div><br> cd lib/vector/<br> python -m grass.gunittest.main --location my_nc_spm_08_grass7_location_for_tests --location-type nc<br><br>This will create a proper report from all tests in all testsuite directories inside the tree starting at lib/vector/. Find the report in testreport/index.html. Alternatively, execute just the script you want:<br><br> cd lib/vector/testsuite/<br> sh -e -x test_topology_vgeneralize.sh<br><br></div><div>Running directly would be possible but you want to set -e flag for failing on the first non-zero return status as it is done inside testing framework [3]. <br></div><div><br></div><div>I was not really sure what it is testing some library things or the v.generalize debug feature itself. I though the former, so I put it to lib/vector. Please, move it somewhere else, if it tests something different. (Test suite directory should be in the directory with tested code.)<br></div><div><br></div><div>As I said, shell script is not ideal because it will not work on MS Windows in GRASS GIS 7 unless you install it but it is at least something. Rewriting to Python would be better and actually not so difficult if only plain Python is used but this would still miss the advantages of the testing framework. Rewriting using gunittest is relatively simple too but I just don't have time to do that.<br></div><div><br></div><div>Vaclav<br></div><div><br>[1] <a href="http://trac.osgeo.org/grass/changeset/64269">http://trac.osgeo.org/grass/changeset/64269</a><br>[2] <a href="http://grass.osgeo.org/grass71/manuals/libpython/gunittest_testing.html#testing-with-gunittest-package-in-general">http://grass.osgeo.org/grass71/manuals/libpython/gunittest_testing.html#testing-with-gunittest-package-in-general</a><br>[3] <a href="http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/gunittest/invoker.py?rev=62358#L148">http://trac.osgeo.org/grass/browser/grass/trunk/lib/python/gunittest/invoker.py?rev=62358#L148</a><br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The vectors in the sample datasets are "too good", I did not find a<br>
vector to provoke any errors, thus the r.to.vect step.<br>
<br>
Real world datasets, particularly vectors with administrative areas or<br>
land cover/land use classification, are in this respect more suitable<br>
because they contain lots of topological errors. Unfortunately, these<br>
datasets are too large to be included in the sample datasets.<br>
</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Markus M<br>
><br>
> Vaclav<br>
><br>
>> Markus M<br>
><br>
><br>
</blockquote></div><br></div></div>