diff --git a/Code/Mantid/Images/Mantid_Logo_Forum.pdn b/Code/Mantid/Images/Mantid_Logo_Forum.pdn new file mode 100644 index 0000000000000000000000000000000000000000..14f8e957d5f55c14b8e7dd6b2a6ffdac0219ab59 Binary files /dev/null and b/Code/Mantid/Images/Mantid_Logo_Forum.pdn differ diff --git a/Code/Mantid/Images/Mantid_Logo_Forum.png b/Code/Mantid/Images/Mantid_Logo_Forum.png new file mode 100644 index 0000000000000000000000000000000000000000..6746064bf0a8c7dfa3ea23297675950d7dddc0cc Binary files /dev/null and b/Code/Mantid/Images/Mantid_Logo_Forum.png differ diff --git a/Code/Mantid/Testing/Data/DocTest/EQSANS_6071_event.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/EQSANS_6071_event.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..1bdb2ff8cfcfecb79d197266a2eb5f381f46a07a --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/EQSANS_6071_event.nxs.md5 @@ -0,0 +1 @@ +ac963bf816b36ca7353f6922ce856604 diff --git a/Code/Mantid/Testing/Data/DocTest/GEM38370_Focussed.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/GEM38370_Focussed.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..8b3eff95d1995a2a864ec295fc8b11a0c0e8cb41 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/GEM38370_Focussed.nxs.md5 @@ -0,0 +1 @@ +01acf5f7645c9901efece0ed8dd00ced diff --git a/Code/Mantid/Testing/Data/DocTest/GEM40979.raw.md5 b/Code/Mantid/Testing/Data/DocTest/GEM40979.raw.md5 new file mode 100644 index 0000000000000000000000000000000000000000..48fcaddffbc0eae7564ccacba91582fc5e3a789e --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/GEM40979.raw.md5 @@ -0,0 +1 @@ +6df0f1c2fc472af200eec43762e9a874 diff --git a/Code/Mantid/Testing/Data/DocTest/HRP39182.RAW.md5 b/Code/Mantid/Testing/Data/DocTest/HRP39182.RAW.md5 new file mode 100644 index 0000000000000000000000000000000000000000..5e148277d0301b15aac686f02cfee701332910de --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/HRP39182.RAW.md5 @@ -0,0 +1 @@ +b6f6a905288dd986b5340673d08f93cb diff --git a/Code/Mantid/Testing/Data/DocTest/LOQ48097.raw.md5 b/Code/Mantid/Testing/Data/DocTest/LOQ48097.raw.md5 new file mode 100644 index 0000000000000000000000000000000000000000..21355d16411f76572a78d001aaeb6de9fb3a978b --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/LOQ48097.raw.md5 @@ -0,0 +1 @@ +435f4d573bfe6e64b014223d793e02a2 diff --git a/Code/Mantid/Testing/Data/DocTest/LogWS.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/LogWS.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..2c541b454d8e05ca41d65f40d996d5992bd02ea7 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/LogWS.nxs.md5 @@ -0,0 +1 @@ +602cbf8646a81b25e221bba3fe691a93 diff --git a/Code/Mantid/Testing/Data/DocTest/MAR11015.raw.md5 b/Code/Mantid/Testing/Data/DocTest/MAR11015.raw.md5 new file mode 100644 index 0000000000000000000000000000000000000000..6596285d57fc01f8449bff67a40afa19a16438ea --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/MAR11015.raw.md5 @@ -0,0 +1 @@ +22402246b0d14072b1fd9e6d920c3bb6 diff --git a/Code/Mantid/Testing/Data/DocTest/MAR11060.raw.md5 b/Code/Mantid/Testing/Data/DocTest/MAR11060.raw.md5 new file mode 100644 index 0000000000000000000000000000000000000000..18eef2419f9e02871dfb575b62d5d60f16c8e955 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/MAR11060.raw.md5 @@ -0,0 +1 @@ +3541bd5715fb57d8cdf884c500d8e485 diff --git a/Code/Mantid/Testing/Data/DocTest/PG3_4871_event.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/PG3_4871_event.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..bf7dbc2c85dfcd02d59fd3d931a5db2016ddff02 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/PG3_4871_event.nxs.md5 @@ -0,0 +1 @@ +a3d0edcb36ab8e9e3342cd8a4440b779 diff --git a/Code/Mantid/Testing/Data/DocTest/SXD23767.raw.md5 b/Code/Mantid/Testing/Data/DocTest/SXD23767.raw.md5 new file mode 100644 index 0000000000000000000000000000000000000000..eff1660e91f420bacc8b9b3b3da67e6d41503c68 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/SXD23767.raw.md5 @@ -0,0 +1 @@ +3950f6d890c10dd67c320cab6054d3d8 diff --git a/Code/Mantid/Testing/Data/DocTest/Training_Exercise3a_SNS.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/Training_Exercise3a_SNS.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..4ac89fcb0f9965811ef1fbb8fa5e25b37cff0c65 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/Training_Exercise3a_SNS.nxs.md5 @@ -0,0 +1 @@ +fb38e6a49b8d90ad5cbe7ad5674ab09d diff --git a/Code/Mantid/Testing/Data/DocTest/Training_Exercise3b_SNS.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/Training_Exercise3b_SNS.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..c7e9172c23dd59999975dad327319e601eb59824 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/Training_Exercise3b_SNS.nxs.md5 @@ -0,0 +1 @@ +7906ac610fe7805b872dc47f19164a91 diff --git a/Code/Mantid/Testing/Data/DocTest/peaks_qLab.nxs.md5 b/Code/Mantid/Testing/Data/DocTest/peaks_qLab.nxs.md5 new file mode 100644 index 0000000000000000000000000000000000000000..23dc6f7b89a553df6920be689885c6cf6f5f2531 --- /dev/null +++ b/Code/Mantid/Testing/Data/DocTest/peaks_qLab.nxs.md5 @@ -0,0 +1 @@ +9ae79fe97b23970e6977217254207c60 diff --git a/Code/Mantid/docs/source/concepts/PropertiesFile.rst b/Code/Mantid/docs/source/concepts/PropertiesFile.rst index 59990e7afae65e21147b9303ce32575b7c62db42..7a3d332535971cf791d651cc4efa9de41f5440ec 100644 --- a/Code/Mantid/docs/source/concepts/PropertiesFile.rst +++ b/Code/Mantid/docs/source/concepts/PropertiesFile.rst @@ -126,6 +126,7 @@ to alter and those properties are detailed below. +-------------------------------------------+---------------------------------------------------+-----------------------+ |logging.channels.fileChannel.path | The Path to the log file. |../logs/mantid.log | +-------------------------------------------+---------------------------------------------------+-----------------------+ + The logging priority levels for the file logging and console logging can also be adjusted in python using the commands: .. testcode:: LoggingConfigExample @@ -135,8 +136,6 @@ The logging priority levels for the file logging and console logging can also be #Set the file to only log at critical level (2=critical) ConfigService.setConsoleLogLevel(2) -.. testoutput:: AddSampleLogExample - MantidPlot Properties diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/doctest.py b/Code/Mantid/docs/sphinxext/mantiddoc/doctest.py index 613fc3cd70602983d25f0291dd7e9b599ea9bf6e..3bd4bea3581dcdcfd5a281f716c43a475eca4ae0 100644 --- a/Code/Mantid/docs/sphinxext/mantiddoc/doctest.py +++ b/Code/Mantid/docs/sphinxext/mantiddoc/doctest.py @@ -42,7 +42,7 @@ Document: bar/FooDoc -------------------- ********************************************************************** - File "bar/FooDoc.rst", line 127, in Ex2 + File "bar/FooDoc.rst", line 127, in Ex2[31] Failed example: print "Multi-line failed" print "test" @@ -62,13 +62,13 @@ ********************************************************************** 2 items had failures: 1 of 1 in Ex1 - 1 of 1 in Ex2 + 1 of 1 in Ex2[31] 2 tests in 2 items. 0 passed and 2 failed. ***Test Failed*** 2 failures. 2 items passed all tests: 1 tests in Ex1 (cleanup code) - 1 tests in Ex2 (cleanup code) + 1 tests in Ex2[31] (cleanup code) 2 tests in 2 items. 2 passed and 0 failed. Test passed. @@ -152,7 +152,7 @@ NUMBER_PASSED_RE = re.compile(r"^(\d+) items passed all tests:$") TEST_PASSED_END_RE = re.compile(r"Test passed.") TEST_FAILED_END_RE = re.compile(r"\*\*\*Test Failed\*\*\* (\d+) failures.") -FAILURE_LOC_RE = re.compile(r"^File \"(.+)\",\s+line\s+(\d+),\s+in\s+(\w+)(\s\((setup|cleanup) code\))?$") +FAILURE_LOC_RE = re.compile(r"^File \"(.+)\",\s+line\s+(\d+),\s+in\s+(\S+)(\s\((setup|cleanup) code\))?$") MIX_FAIL_RE = re.compile(r'^\s+(\d+)\s+of\s+(\d+)\s+in\s+(\w+)$') #------------------------------------------------------------------------------- diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/tests/test_doctest.py b/Code/Mantid/docs/sphinxext/mantiddoc/tests/test_doctest.py index 66f3de9031e3d3a4677cd52f05943bb645218430..cf0a9505450405ad16bc2a21ba0edfcc74864a79 100644 --- a/Code/Mantid/docs/sphinxext/mantiddoc/tests/test_doctest.py +++ b/Code/Mantid/docs/sphinxext/mantiddoc/tests/test_doctest.py @@ -149,7 +149,7 @@ ALL_FAIL_EX = \ """Document: algorithms/AllFailed ------------------------------ ********************************************************************** -File "algorithms/AllFailed.rst", line 127, in Ex2 +File "algorithms/AllFailed.rst", line 127, in Ex2[31] Failed example: print "Multi-line failed" print "test" @@ -169,13 +169,13 @@ Got: ********************************************************************** 2 items had failures: 1 of 1 in Ex1 - 1 of 1 in Ex2 + 1 of 1 in Ex2[31] 2 tests in 2 items. 0 passed and 2 failed. ***Test Failed*** 2 failures. 2 items passed all tests: 1 tests in Ex1 (cleanup code) - 1 tests in Ex2 (cleanup code) + 1 tests in Ex2[31] (cleanup code) 2 tests in 2 items. 2 passed and 0 failed. Test passed. @@ -275,9 +275,9 @@ class DocTestOutputParserTest(unittest.TestCase): self.assertEquals(2, suite.ntests) cases = suite.testcases - expected_names = ["Ex2", "Ex1"] + expected_names = ["Ex2[31]", "Ex1"] expected_errors = [ -"""File "algorithms/AllFailed.rst", line 127, in Ex2 +"""File "algorithms/AllFailed.rst", line 127, in Ex2[31] Failed example: print "Multi-line failed" print "test" diff --git a/Code/Tools/scripts/TestWikiPython.py b/Code/Tools/scripts/TestWikiPython.py new file mode 100644 index 0000000000000000000000000000000000000000..ff44eabe84669c17f9de58bd14b2ee19f5153da7 --- /dev/null +++ b/Code/Tools/scripts/TestWikiPython.py @@ -0,0 +1,169 @@ +########################################################################################### +# Extracts code blocks marked as python from mediawiki pages and checks they run +# run with -h for command line arguments +# +########################################################################################## +import os +import re +import sys +import urllib2 +import urlparse +import argparse +import json + +def readWebPage(url): + # set your environment HTTP_PROXY to be your proxy + # for ral HTTP_PROXY=http://wwwcache.rl.ac.uk:8080 + aResp = urllib2.urlopen(url) + web_pg = aResp.read() + return web_pg + + +def getTestablePages(url): + retList = [] + print "Reading Testable pages from " + url + output = readWebPage(url) + jsonObj = json.loads(output) + for member in jsonObj['query']['categorymembers']: + retList.append(member['title']) + return retList + + +def convertURLToRaw(url): + return url.replace(" ","%20") + "?action=raw" +def writeTestRst(filepath,mediawikiText,pageName): + ''' + for a block of wiki text, writes out all tests found to an rst page + :param mediawikiText: mediawiki text + :param filepath: the filepath to write out the rst file to, if None then print to stdout + :return: None + ''' + try: + if filepath is not None: + sys.stdout = open(filepath, 'w') + print ":orphan:\n" + findCodeSections(mediawikiText,pageName) + finally: + sys.stdout = sys.__stdout__ + +def findCodeSections(mediawikiText,pageName): + ''' + Finds code sections that look like this: + + #<div style="border:1pt dashed blue; background:#f9f9f9;padding: 1em 0;"> + # <!--skip--> + # <!-- setup + # x=1 + # y=2 + # file.open() + # --> + # <source lang="python"> + # x = 'The meaning of life is ... ' + # answer = 42 + # y = x + str(answer) # This converts the number 5 to a string and joins + # # it with the first string and then assigns y to a + # # new string containing the concatenated string + # </source> + # <!-- teardown + # print y # print statements can be in the teardown if you do not want them visible + # file.close() + # --> + # <!-- result + # the lazy dog + # --> + # </div> + ''' + + wikiTestPattern = re.compile( + r'''(<!--\s*skip\s*-->)?\s* # optional skip section (group 1) + (<!--\s*testsetup\s*(.*?)\s*-->)?\s* # optional setup section (group 2), just setup code (group 3) + <source.*?lang="python".*?>\s*(.*?)\s*<\/source>\s* # mandatory source section, code (group 4) + (<!--\s*testcleanup\s*(.*?)\s*-->)?\s* # optional teardown section (group 5), code (group 6) + (<!--\s+testoutput\s*(.*?)\s*-->)? # optional result section (group 7), text group (8) + ''', re.IGNORECASE + re.DOTALL + re.VERBOSE) + + for m in re.finditer(wikiTestPattern, mediawikiText): + (line,col) = coords_of_str_index(mediawikiText, m.start(0)) + testName = pageName + "[" + str(line) + "]" + #print the test + if m.group(1) is not None: + print ".. Skipping Test ", testName + print + else: + printDirective("testsetup",testName,m.group(3),True) + printDirective("testcode",testName,m.group(4),False) + printDirective("testcleanup",testName,m.group(6),True) + printDirective("testoutput",testName,m.group(8),True, "+ELLIPSIS, +NORMALIZE_WHITESPACE") + print + +def printDirective (directive, name, contents, hideIfNone = False,options = None): + if not(hideIfNone and contents is None): + print ".. {}:: {}".format(directive,name) + if options is not None: + print " :options: {}".format(options) + print + if contents is not None: + for line in contents.split("\n"): + print " " + line + print + +def coords_of_str_index(string, index): + """Get (line_number, col) of `index` in `string`.""" + lines = string.splitlines(True) + curr_pos = 0 + for linenum, line in enumerate(lines): + if curr_pos + len(line) > index: + return linenum + 1, index-curr_pos + curr_pos += len(line) + +def ensureDirectoriesExist(path): + try: + os.makedirs(path) + except OSError: + pass + +################################################################################################################ + +parser = argparse.ArgumentParser(description='Extracts code blocks marked as python from mediawiki pages and tests they run.') +parser.add_argument('-i', '--i', + help='The title of a mediawiki page, if not specified it will search the Tested Examples category') +parser.add_argument('-s', '--s', + help='The url of a mantid mediawiki site') +parser.add_argument('-o', '--o', + help='Provide a path to output to an output directory') + +args = parser.parse_args() +urlList = []; +baseUrl = "http://www.mantidproject.org/" +if args.s is not None: + baseUrl = args.s +if args.i is None: + urlList = getTestablePages(baseUrl + + "api.php?action=query&list=categorymembers&format=json&cmlimit=500&cmtitle=Category:Tested%20Examples") +else: + urlList.append(args.i) + +outputDir = None +if args.o is not None: + ensureDirectoriesExist(args.o) + if not os.path.isdir(args.o): + print "Output directory not found", args.o + print "Output will be to stdout" + else: + outputDir = args.o + +for url in urlList: + pageName = "mwTest_" + url.replace(" ","_").replace(":","") + print "Parsing ", pageName, + + outputFile = None + if outputDir is not None: + outputFile = os.path.join(outputDir, pageName+".rst") + print "->", outputFile + + #run pandoc and get the output in rst + mediawikiText = readWebPage(convertURLToRaw(baseUrl + url)) + writeTestRst(outputFile,mediawikiText,pageName) + + +