Skip to content

Commit

Permalink
refs #6664 no wiki page is a failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Mar 5, 2013
1 parent d32d415 commit 8d92798
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 65 deletions.
30 changes: 20 additions & 10 deletions Code/Mantid/Build/wiki_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,15 @@ def make_redirect(from_page, to_page):
page = site.Pages[from_page]
contents = "#REDIRECT [[%s]]" % to_page
page.save(contents, summary = 'Bot: created redirect to the latest version.' )


#======================================================================
def page_exists(page):
# Determine if the wikipage exists or not.
revisions = page.revisions()
for rev in revisions:
return True
return False

#======================================================================
def last_page_editor(page):
#Get the last editor of the page.
Expand All @@ -320,7 +328,7 @@ def wiki_maker_page(page):
#======================================================================
def do_algorithm(args, algo, version=-1):
""" Do the wiki page
@param algo_tuple :: the name of the algorithm, and it's version as a tuple"""
@param algo :: the name of the algorithm, and it's version as a tuple"""
global mtd
is_latest_version = True
latest_version = -1
Expand All @@ -329,7 +337,6 @@ def do_algorithm(args, algo, version=-1):
if (version == -1): version = latest_version

print "Latest version of %s is %d. You are making version %d." % (algo, latest_version, version)

# What should the name on the wiki page be?
wiki_page_name = algo
if latest_version > 1:
Expand All @@ -345,6 +352,10 @@ def do_algorithm(args, algo, version=-1):

#Open the page with the name of the algo
page = site.Pages[wiki_page_name]
if not page_exists(page):
print "Error: Wiki Page wiki_page_name %s does not exist on the wiki." % wiki_page_name
reporter.addFailureNoPage(algo, wiki_page_name)
return

old_contents = page.edit() + "\n"

Expand Down Expand Up @@ -374,14 +385,13 @@ def do_algorithm(args, algo, version=-1):
if not last_modifier == None:
# Report a failure test case
reporter.addFailureTestCase(algo, version, last_modifier, ''.join(diff_list))

if args.dryrun:
print "Dry run of saving page to http://www.mantidproject.org/%s" % wiki_page_name
elif wiki_maker_edited_last or args.force or confirm("Do you want to replace the website wiki page?", True):
print "Saving page to http://www.mantidproject.org/%s" % wiki_page_name
page.save(new_contents, summary = 'Bot: replaced contents using the wiki_maker.py script.' )

if wiki_maker_edited_last or args.force or confirm("Do you want to replace the website wiki page?", True):
if not args.dryrun:
print "Saving page to http://www.mantidproject.org/%s" % wiki_page_name
page.save(new_contents, summary = 'Bot: replaced contents using the wiki_maker.py script.' )
else:
print "Dry run of saving page to http://www.mantidproject.org/%s" % wiki_page_name

saved_text = open(wiki_page_name+'.txt', 'w')
saved_text.write(new_contents)
saved_text.close()
Expand Down
70 changes: 15 additions & 55 deletions Code/Mantid/Build/wiki_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,75 +36,35 @@ def getResults(self):
docEl.setAttribute('time',str(self._time_taken))
return self._doc.toxml()

def __failureMessage__(self, algorithm, version, last_editor, diff):
return "Algorithm %s Version %i last edited by %s is out of sync.\n\nDifferences are:\n\n%s" % (algorithm, version, last_editor, diff)

def addSuccessTestCase(self, algorithm):
def __addGenericFailure__(self, contents, algorithm):
elem = self._doc.createElement('testcase')
elem.setAttribute('classname', 'WikiMaker')
elem.setAttribute('name', algorithm)
self._failures.append(algorithm)
failEl = self._doc.createElement('failure')
failEl.appendChild(self._doc.createTextNode(contents))
elem.appendChild(failEl)
time_taken = 0
elem.setAttribute('time',str(time_taken))
elem.setAttribute('totalTime',str(time_taken))
self._doc.documentElement.appendChild(elem)


def addFailureTestCase(self, algorithm, version, last_editor, diff):
def addSuccessTestCase(self, algorithm):
elem = self._doc.createElement('testcase')
elem.setAttribute('classname', 'WikiMaker')
elem.setAttribute('name', algorithm)
self._failures.append(algorithm)
failEl = self._doc.createElement('failure')
failEl.appendChild(self._doc.createTextNode(self.__failureMessage__(algorithm, version, last_editor, diff)))
elem.appendChild(failEl)
time_taken = 0
elem.setAttribute('time',str(time_taken))
elem.setAttribute('totalTime',str(time_taken))
self._doc.documentElement.appendChild(elem)






def addFailureTestCase(self, algorithm, version, last_editor, diff):
contents = "Algorithm %s Version %i last edited by %s is out of sync.\n\nDifferences are:\n\n%s" % (algorithm, version, last_editor, diff)
self.__addGenericFailure__(contents, algorithm)

""" def dispatchResults(self, result):
''' This relies on the order and names of the items to give the correct output '''
test_name = result.name.split('.')
if len(test_name) > 1:
class_name = '.'.join(test_name[:-1])
name = test_name[-1]
else:
class_name = result.name
name = result.name
elem = self._doc.createElement('testcase')
elem.setAttribute('classname',"SystemTests." + class_name)
elem.setAttribute('name',name)
if result.status == 'skipped':
self._skipped.append(result)
skipEl = self._doc.createElement('skipped')
if len(result.output) > 0:
if "Missing required file" in result.output:
skipEl.setAttribute('message', "MissingRequiredFile")
else:
skipEl.setAttribute('message', result.output)
skipEl.appendChild(self._doc.createTextNode(result.output))
elem.appendChild(skipEl)
elif result.status != 'success':
self._failures.append(result)
failEl = self._doc.createElement('failure')
failEl.setAttribute('file',result.filename)
output = ''
if len(result.output) > 0:
output += result.output
if len(output) > 0:
failEl.appendChild(self._doc.createTextNode(output))
elem.appendChild(failEl)
time_taken = 0.0
for t in result.resultLogs():
if t[0] == 'iteration time_taken':
time_taken = float(t[1].split(' ')[1])
self._time_taken += time_taken
elem.setAttribute('time',str(time_taken))
elem.setAttribute('totalTime',str(time_taken))
self._doc.documentElement.appendChild(elem)
"""

def addFailureNoPage(self, algorithm, expected_page):
contents = "Algorithm %s has no wiki page. Wiki page expected %s still needs creating." % (algorithm, expected_page)
self.__addGenericFailure__(contents, algorithm)

0 comments on commit 8d92798

Please sign in to comment.