def init(args): global gSelenium global gOutputFile global gTestsuiteHeaderXSLT global gErrorFragment global gXHTMLContainerXSLT testFile = args[-1] mode = args[-2] if mode == "XML": gOutputFile = "Li+.xhtml" doc = etree.parse(testFile) ns = etree.QName(doc.getroot()).namespace if ns == NS_MATHML or ns == NS_SVG: gXHTMLContainerXSLT = etree.XSLT(etree.parse("xhtmlContainer.xsl")) elif ns == NS_XHTML: gXHTMLContainerXSLT = None else: raise BaseException("Unknown namespace") elif mode == "HTML": # LiPlusXML has converted the document into XHTML gOutputFile = "Li+.xhtml" gXHTMLContainerXSLT = None else: raise BaseException("Unknown document format") gErrorFragment = args[-3] l = len(args) - 3 if l > 0: mathjaxPath = args[0] else: mathjaxPath = DEFAULT_MATHJAX_PATH operatingSystem = OS_LIST[0] if l > 1: browser = args[1] else: browser = BROWSER_LIST[0] if l > 2: font = args[2] else: font = FONT_LIST[0] if l > 3: outputJax = args[3] else: outputJax = OUTPUT_JAX_LIST[0] if l > 4: timeOut = int(args[4]) else: timeOut = DEFAULT_TIMEOUT * 1000 gSelenium = seleniumMathJax.seleniumMathJax( True, False, "localhost", SELENIUM_SERVER_PORT, mathjaxPath, MATHJAX_TEST_LOCAL_URI + "testsuite/", operatingSystem, browser, "default", "default", "default", font, outputJax, timeOut, False) gSelenium.start() gSelenium.pre() gTestsuiteHeaderXSLT = etree.XSLT(etree.parse("testsuiteHeader.xsl"))
if __name__ == "__main__": config = ConfigParser.ConfigParser() config.readfp(open("options.cfg")) section = "seleniumMathJax" browser = config.get(section, "browser") browserStartCommand = config.get(section, "browserStartCommand") if browserStartCommand == "auto": browserStartCommand = getBrowserStartCommandFromBrowser(browser) selenium = seleniumMathJax.seleniumMathJax( config.get(section, "host"), config.getint(section, "port"), browserStartCommand, config.get(section, "browserURL"), config.get(section, "mathJaxPath"), browser, config.getboolean(section, "useNativeMathML"), config.getint(section, "timeOut"), config.getboolean(section, "fullScreenMode")) selenium.start() output = config.get("testsuite", "outputFile") if output == "auto": output = getOutputFileName(selenium.mBrowser) fp = file(output, "wb") suite = unittest.TestSuite() addReftests(suite, selenium, reftest.treeReftest, "LaTeXToMathML/") addReftests(suite, selenium, reftest.visualReftest, "MathMLToDisplay/")
def main(aArgs, aTransmitToTaskHandler): """ @fn main(aArgs, aTransmitToTaskHandler) @brief main routine of the runTestsuite.py script. @param aArgs command line arguments given by Python's argparse @param aTransmitToTaskHandler whether the testing instance should transmit information to the task handler. """ global TASK_HANDLER_HOST global TASK_HANDLER_PORT # if the option --printList is passed, only generate the file # reftestList.txt if hasattr(aArgs, "printList"): printReftestList() exit(0) # if the option --printNotes is passed, only generate the # testsuiteNotes html page. if hasattr(aArgs, "printNotes"): printNotes() exit(0) # if the option --printListOfTests is passed, only generate a ListOfTests # from a file containing test URIs if hasattr(aArgs, "printListOfTests"): if not aArgs.printListOfTests: print("No input file!", file=sys.stderr) exit(0) printListOfTests(aArgs.printListOfTests) exit(0) # create the date directory now = datetime.utcnow(); directory = MATHJAX_WEB_PATH + "results/" if not os.path.exists(directory): os.makedirs(directory) # create the subdirectory if aArgs.output and re.match("^([0-9]|[a-z]|[A-Z]|-|/){1,50}/$", aArgs.output): directory += aArgs.output else: directory += now.strftime("%Y-%m-%d/%H-%M-%S/") if not os.path.exists(directory): os.makedirs(directory) # execute testing instances for all the config files configFileList = aArgs.config.split(",") for configFile in configFileList: configFile = configFile if (not os.path.isfile(configFile)): print("Warning: config file " + configFile + " not found!", file=sys.stderr) continue # Load configuration file config = ConfigParser.ConfigParser() config.readfp(open(configFile)) # framework section section = "framework" useGrid = getBooleanOption(config, section, "useGrid") host = config.get(section, "host") # host == "default" is handled below port = config.getint(section, "port") if (port == -1): port = SELENIUM_SERVER_PORT mathJaxPath = config.get(section, "mathJaxPath") if (mathJaxPath == "default"): mathJaxPath = DEFAULT_MATHJAX_PATH mathJaxTestPath = config.get(section, "mathJaxTestPath") if (mathJaxTestPath == "default"): mathJaxTestPath = MATHJAX_TEST_LOCAL_URI + "testsuite/" timeOut = config.getint(section, "timeOut") if (timeOut == -1): timeOut = DEFAULT_TIMEOUT timeOut = timeOut * 1000 # convert in ms useWebDriver = getBooleanOption(config, section, "useWebDriver") fullScreenMode = getBooleanOption(config, section, "fullScreenMode") formatOutput = getBooleanOption(config, section, "formatOutput") compressOutput = getBooleanOption(config, section, "compressOutput") # platform section section = "platform" operatingSystem = config.get(section, "operatingSystem") if (operatingSystem == "default"): operatingSystem = OS_LIST[0] if (host == "default"): host = HOST_LIST[HOST_LIST_OS.index(OS_LIST.index(operatingSystem))] browserList = config.get(section, "browser").split() browserVersionList = config.get(section, "browserVersion").split() browserModeList = config.get(section, "browserMode").split() browserPath = config.get(section, "browserPath") fontList = config.get(section, "font").split() outputJaxList = config.get(section, "outputJax").split() # testsuite section section = "testsuite" runSlowTests = getBooleanOption(config, section, "runSlowTests") runSkipTests = getBooleanOption(config, section, "runSkipTests") listOfTests = config.get(section, "listOfTests") startID = config.get(section, "startID") if (startID == "default"): startID = "" # When more than one browser is specified, browserPath is ignored. if (len(browserList) > 1 and browserPath != "default"): print("Warning: browserPath ignored", file=sys.stderr) browserPath = "default" for browser in browserList: if (browser == "default"): browser = BROWSER_LIST[0] for font in fontList: if (font == "default"): font = FONT_LIST[0] for outputJax in outputJaxList: if (outputJax == "default"): outputJax = OUTPUT_JAX_LIST[0] for browserVersion in browserVersionList: # browserModeList is only relevant for MSIE if not(browser == "MSIE"): browserModeList2 = ["default"] else: browserModeList2 = browserModeList for browserMode in browserModeList2: # Create a Selenium instance selenium = \ seleniumMathJax.seleniumMathJax(useWebDriver, useGrid, host, port, mathJaxPath, mathJaxTestPath, operatingSystem, browser, browserVersion, browserMode, browserPath, font, outputJax, timeOut, fullScreenMode) if aTransmitToTaskHandler: taskHandler = [TASK_HANDLER_HOST, TASK_HANDLER_PORT, str(os.getpid())] else: taskHandler = None # Create the test suite suite = reftest.reftestSuite(taskHandler, runSlowTests, runSkipTests, listOfTests, startID) # use the specified file name if hasattr(aArgs, "filename"): filename = aArgs.filename else: filename = getOutputFileName(directory, selenium, suite) runTestingInstance(directory, selenium, suite, formatOutput, compressOutput, filename)
def main(aArgs, aTransmitToTaskHandler): """ @fn main(aArgs, aTransmitToTaskHandler) @brief main routine of the runTestsuite.py script. @param aArgs command line arguments given by Python's argparse @param aTransmitToTaskHandler whether the testing instance should transmit information to the task handler. """ global TASK_HANDLER_HOST global TASK_HANDLER_PORT # if the option --printList is passed, only generate the file # reftestList.txt if hasattr(aArgs, "printList"): printReftestList() exit(0) # if the option --printNotes is passed, only generate the # testsuiteNotes html page. if hasattr(aArgs, "printNotes"): printNotes() exit(0) # if the option --printListOfTests is passed, only generate a ListOfTests # from a file containing test URIs if hasattr(aArgs, "printListOfTests"): if not aArgs.printListOfTests: print("No input file!", file=sys.stderr) exit(0) printListOfTests(aArgs.printListOfTests) exit(0) # create the date directory now = datetime.utcnow(); directory = MATHJAX_WEB_PATH + "results/" if not os.path.exists(directory): os.makedirs(directory) # create the subdirectory if aArgs.output and re.match("^([0-9]|[a-z]|[A-Z]|-|/){1,50}/$", aArgs.output): directory += aArgs.output else: directory += now.strftime("%Y-%m-%d/%H-%M-%S/") if not os.path.exists(directory): os.makedirs(directory) # execute testing instances for all the config files configFileList = aArgs.config.split(",") for configFile in configFileList: configFile = configFile if (not os.path.isfile(configFile)): print("Warning: config file " + configFile + " not found!", file=sys.stderr) continue # Load configuration file config = ConfigParser.ConfigParser() config.readfp(open(configFile)) # framework section section = "framework" useGrid = getBooleanOption(config, section, "useGrid") host = config.get(section, "host") # host == "default" is handled below port = config.getint(section, "port") if (port == -1): port = SELENIUM_SERVER_PORT mathJaxPath = config.get(section, "mathJaxPath") if (mathJaxPath == "default"): mathJaxPath = DEFAULT_MATHJAX_PATH mathJaxTestPath = config.get(section, "mathJaxTestPath") if (mathJaxTestPath == "default"): mathJaxTestPath = MATHJAX_TEST_LOCAL_URI + "testsuite/" timeOut = config.getint(section, "timeOut") if (timeOut == -1): timeOut = DEFAULT_TIMEOUT timeOut = timeOut * 1000 # convert in ms useWebDriver = getBooleanOption(config, section, "useWebDriver") fullScreenMode = getBooleanOption(config, section, "fullScreenMode") formatOutput = getBooleanOption(config, section, "formatOutput") compressOutput = getBooleanOption(config, section, "compressOutput") # platform section section = "platform" operatingSystem = config.get(section, "operatingSystem") if (operatingSystem == "default"): operatingSystem = OS_LIST[0] if (host == "default"): host = HOST_LIST[HOST_LIST_OS.index(OS_LIST.index(operatingSystem))] browserList = config.get(section, "browser").split() browserVersionList = config.get(section, "browserVersion").split() browserModeList = config.get(section, "browserMode").split() browserPath = config.get(section, "browserPath") fontList = config.get(section, "font").split() outputJaxList = config.get(section, "outputJax").split() # testsuite section section = "testsuite" runSlowTests = getBooleanOption(config, section, "runSlowTests") runSkipTests = getBooleanOption(config, section, "runSkipTests") listOfTests = config.get(section, "listOfTests") startID = config.get(section, "startID") if (startID == "default"): startID = "" # When more than one browser is specified, browserPath is ignored. if (len(browserList) > 1 and browserPath != "default"): print("Warning: browserPath ignored", file=sys.stderr) browserPath = "default" for browser in browserList: if (browser == "default"): browser = BROWSER_LIST[0] for font in fontList: if (font == "default"): font = FONT_LIST[0] for outputJax in outputJaxList: if (outputJax == "default"): outputJax = OUTPUT_JAX_LIST[0] for browserVersion in browserVersionList: # browserModeList is only relevant for MSIE if not(browser == "MSIE"): browserModeList2 = ["default"] else: browserModeList2 = browserModeList for browserMode in browserModeList2: # Create a Selenium instance selenium = \ seleniumMathJax.seleniumMathJax(useWebDriver, useGrid, host, port, mathJaxPath, mathJaxTestPath, operatingSystem, browser, browserVersion, browserMode, browserPath, font, outputJax, timeOut, fullScreenMode) if aTransmitToTaskHandler: taskHandler = [TASK_HANDLER_HOST, TASK_HANDLER_PORT, str(os.getpid())] else: taskHandler = None # Create the test suite suite = reftest.reftestSuite(taskHandler, runSlowTests, runSkipTests, listOfTests, startID) # use the specified file name if hasattr(aArgs, "filename"): filename = aArgs.filename else: filename = getOutputFileName(directory, selenium, suite) runTestingInstance(directory, selenium, suite, formatOutput, compressOutput, filename)
def init(args): global gSelenium global gOutputFile global gTestsuiteHeaderXSLT global gErrorFragment global gXHTMLContainerXSLT testFile = args[-1] mode = args[-2] if mode == "XML": gOutputFile = "Li+.xhtml" doc = etree.parse(testFile) ns = etree.QName(doc.getroot()).namespace if ns == NS_MATHML or ns == NS_SVG: gXHTMLContainerXSLT = etree.XSLT(etree.parse("xhtmlContainer.xsl")) elif ns == NS_XHTML: gXHTMLContainerXSLT = None else: raise BaseException("Unknown namespace") elif mode == "HTML": # LiPlusXML has converted the document into XHTML gOutputFile = "Li+.xhtml" gXHTMLContainerXSLT = None else: raise BaseException("Unknown document format") gErrorFragment = args[-3] l = len(args) - 3 if l > 0: mathjaxPath = args[0] else: mathjaxPath = DEFAULT_MATHJAX_PATH operatingSystem = OS_LIST[0] if l > 1: browser = args[1] else: browser = BROWSER_LIST[0] if l > 2: font = args[2] else: font = FONT_LIST[0] if l > 3: outputJax = args[3] else: outputJax = OUTPUT_JAX_LIST[0] if l > 4: timeOut = int(args[4]) else: timeOut = DEFAULT_TIMEOUT * 1000 gSelenium = seleniumMathJax.seleniumMathJax(True, False, "localhost", SELENIUM_SERVER_PORT, mathjaxPath, MATHJAX_TEST_LOCAL_URI + "testsuite/", operatingSystem, browser, "default", "default", "default", font, outputJax, timeOut, False) gSelenium.start() gSelenium.pre() gTestsuiteHeaderXSLT = etree.XSLT(etree.parse("testsuiteHeader.xsl"))