Skip to content

Commit

Permalink
Write important test output to travis console
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 14, 2015
1 parent 76ccf71 commit b8b760e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -41,3 +41,5 @@ before_script:
script:
- ./ci/travis/${TRAVIS_OS_NAME}/script.sh

after_script:
- ./ci/travis/${TRAVIS_OS_NAME}/after_script.sh
1 change: 1 addition & 0 deletions ci/travis/linux/after_script.sh
@@ -0,0 +1 @@
cat '/tmp/ctest-important.log'
Empty file added ci/travis/osx/after_script.sh
Empty file.
33 changes: 17 additions & 16 deletions tests/src/python/test_qgsdoccoverage.py
Expand Up @@ -16,7 +16,8 @@
import glob

from utilities import (TestCase,
unittest)
unittest,
printImportant)

try:
import xml.etree.cElementTree as ET
Expand All @@ -39,7 +40,7 @@ def elemIsDocumentableClass(elem):
if not elem.get('kind') == 'class':
return False

#public or protected classes should be documented
# public or protected classes should be documented
return elem.get('prot') in ('public', 'protected')


Expand All @@ -58,27 +59,27 @@ def elemIsDocumentableMember(elem):
if elem.get('kind') == 'variable':
return False

#only public or protected members should be documented
# only public or protected members should be documented
if not elem.get('prot') in ('public', 'protected'):
return False

#ignore reimplemented methods
#use two different tests, as doxygen will not detect reimplemented qt methods
# ignore reimplemented methods
# use two different tests, as doxygen will not detect reimplemented qt methods
if elem.find('reimplements') is not None:
return False
args = elem.find('argsstring')
if args is not None and args.text and ' override' in args.text:
return False

#ignore destructor
# ignore destructor
name = elem.find('name')
try:
if name.text and name.text.startswith('~'):
return False
except:
pass

#ignore constructors with no arguments
# ignore constructors with no arguments
definition = elem.find('definition')
argsstring = elem.find('argsstring')
try:
Expand All @@ -87,21 +88,21 @@ def elemIsDocumentableMember(elem):
except:
pass

#ignore certain obvious operators
# ignore certain obvious operators
try:
if name.text in ('operator=', 'operator=='):
return False
except:
pass

#ignore on_* slots
# ignore on_* slots
try:
if name.text.startswith('on_'):
return False
except:
pass

#ignore deprecated members
# ignore deprecated members
typeelem = elem.find('type')
try:
if typeelem.text and 'Q_DECL_DEPRECATED' in typeelem.text:
Expand Down Expand Up @@ -151,7 +152,7 @@ def parseFile(f):
print "\n"
elem.clear()
except ET.ParseError as e:
#sometimes Doxygen generates malformed xml (eg for < and > operators)
# sometimes Doxygen generates malformed xml (eg for < and > operators)
line_num, col = e.position
with open(f, 'r') as xml_file:
for i, l in enumerate(xml_file):
Expand Down Expand Up @@ -186,11 +187,11 @@ def testCoverage(self):
missing = documentable - documented

print "---------------------------------"
print "{} total documentable members".format(documentable)
print "{} total contain valid documentation".format(documented)
print "Total documentation coverage {}%".format(coverage)
print "---------------------------------"
print "{} members missing documentation, out of {} allowed".format(missing, ACCEPTABLE_MISSING_DOCS)
printImportant("{} total documentable members".format(documentable))
printImportant("{} total contain valid documentation".format(documented))
printImportant("Total documentation coverage {}%".format(coverage))
printImportant("---------------------------------")
printImportant("{} members missing documentation, out of {} allowed".format(missing, ACCEPTABLE_MISSING_DOCS))

assert missing <= ACCEPTABLE_MISSING_DOCS, 'FAIL: new undocumented members have been introduced, please add documentation for these members'

Expand Down
14 changes: 13 additions & 1 deletion tests/src/python/utilities.py
Expand Up @@ -174,7 +174,7 @@ def setCanvasCrs(theEpsgId, theOtfpFlag=False):

# Create CRS Instance
myCrs = QgsCoordinateReferenceSystem()
myCrs.createFromId(theEpsgId, QgsCoordinateReferenceSystem.EpsgCrsId)
myCrs.createFromId(theEpsgId, QgsCoordinateReferenceSystem.E)

# Reproject all layers to WGS84 geographic CRS
CANVAS.mapRenderer().setDestinationCrs(myCrs)
Expand Down Expand Up @@ -361,3 +361,15 @@ def openInBrowserTab(url):
subprocess.Popen([sys.executable, "-c", cmd],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)


def printImportant(info):
"""
Prints important information to stdout and to a file which in the end
should be printed on test result pages.
:param info: A string to print
"""

print(info)
with open(os.path.join(tempfile.gettempdir(), 'ctest-important.log'), 'a+') as f:
f.write(u'{}\n'.format(info))

0 comments on commit b8b760e

Please sign in to comment.