[GRASS-SVN] r61244 - in grass/trunk/lib/python: docs/src gunittest
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jul 12 13:21:53 PDT 2014
Author: wenzeslaus
Date: 2014-07-12 13:21:53 -0700 (Sat, 12 Jul 2014)
New Revision: 61244
Modified:
grass/trunk/lib/python/docs/src/gunittest_testing.rst
grass/trunk/lib/python/gunittest/invoker.py
grass/trunk/lib/python/gunittest/main.py
grass/trunk/lib/python/gunittest/reporters.py
Log:
gunittest: support older version of svn by getting relative URL from absolute one (ticket #2364), also improve documentation about data directory (ticket #2365)
Modified: grass/trunk/lib/python/docs/src/gunittest_testing.rst
===================================================================
--- grass/trunk/lib/python/docs/src/gunittest_testing.rst 2014-07-12 11:51:49 UTC (rev 61243)
+++ grass/trunk/lib/python/docs/src/gunittest_testing.rst 2014-07-12 20:21:53 UTC (rev 61244)
@@ -292,6 +292,19 @@
GRASS module).
+Data specific to one test
+-------------------------
+
+If the data required by the test are not part of standard location
+and cannot be part of the test file itself, this data should be stored
+in files in ``data`` subdirectory of ``testsuite`` directory.
+The test should access the data using a relative path from its location,
+i.e. all data will be accessed using ``data/...``. This ``data`` directory
+might be used directly when running test file directly in the directory
+in the source code or might be copied to the test current working directory
+when running tests by the main test invoking tool.
+
+
Analyzing quality of source code
--------------------------------
Modified: grass/trunk/lib/python/gunittest/invoker.py
===================================================================
--- grass/trunk/lib/python/gunittest/invoker.py 2014-07-12 11:51:49 UTC (rev 61243)
+++ grass/trunk/lib/python/gunittest/invoker.py 2014-07-12 20:21:53 UTC (rev 61244)
@@ -101,7 +101,9 @@
self.reporter.start_file_test(module)
# TODO: we might clean the directory here before test if non-empty
# TODO: use some grass function to run?
- p = subprocess.Popen([sys.executable, module.abs_file_path],
+ # add also '-Qwarn'?
+ p = subprocess.Popen([sys.executable, '-tt', '-3',
+ module.abs_file_path],
cwd=cwd, env=env,
stdout=stdout, stderr=stderr)
returncode = p.wait()
Modified: grass/trunk/lib/python/gunittest/main.py
===================================================================
--- grass/trunk/lib/python/gunittest/main.py 2014-07-12 11:51:49 UTC (rev 61243)
+++ grass/trunk/lib/python/gunittest/main.py 2014-07-12 20:21:53 UTC (rev 61244)
@@ -75,6 +75,8 @@
# TODO: enable passing omit to exclude also gunittest or nothing
program = GrassTestProgram(module='__main__', exit_at_end=False, grass_location='all')
+ # TODO: check if we are in the directory where the test file is
+ # this will ensure that data directory is available when it is requested
if doing_coverage:
cov.stop()
@@ -137,6 +139,8 @@
silent_rmtree(results_dir) # TODO: too brute force?
invoker = GrassTestFilesInvoker(start_dir='.')
+ # we can just iterate over all locations available in database
+ # but the we don't know the right location label/shortcut
invoker.run_in_location(gisdbase=gisdbase,
location=location,
location_shortcut=location_shortcut,
Modified: grass/trunk/lib/python/gunittest/reporters.py
===================================================================
--- grass/trunk/lib/python/gunittest/reporters.py 2014-07-12 11:51:49 UTC (rev 61243)
+++ grass/trunk/lib/python/gunittest/reporters.py 2014-07-12 20:21:53 UTC (rev 61244)
@@ -103,14 +103,23 @@
if not rc:
root = et.fromstring(stdout)
# TODO: get also date if this make sense
- # expecting only one <entry>
+ # expecting only one <entry> element
entry = root.find('entry')
info['revision'] = entry.get('revision')
info['url'] = entry.find('url').text
- relurl = entry.find('relative-url').text
- # relative path has ^ at the beginning
- if relurl.startswith('^'):
- relurl = relurl[1:]
+ relurl = entry.find('relative-url')
+ # element which is not found is None
+ # empty element would be bool(el) == False
+ if relurl is not None:
+ relurl = relurl.text
+ # relative path has ^ at the beginning in SVN version 1.8.8
+ if relurl.startswith('^'):
+ relurl = relurl[1:]
+ else:
+ # SVN version 1.8.8 supports relative-url but older do not
+ # so, get relative part from absolute URL
+ const_url_part = 'https://svn.osgeo.org/grass/'
+ relurl = info['url'][len(const_url_part):]
info['relative-url'] = relurl
return info
# TODO: add this to svnversion function
More information about the grass-commit
mailing list