Example #1
0
def printReftestList():
    """
    @fn printReftestList()
    @brief generate the file web/reftestList.js
    """
    print("Generating reftestList.js...", end="")

    suite = reftest.reftestSuite()
    fp = file(MATHJAX_WEB_PATH + "reftestList.js", "w")
    stdout = sys.stdout
    sys.stdout = fp
    print("// " + WARNING_GENERATED_FILE)
    print("/**")
    print(" * @file reftestList.js")
    print(" * @brief array representing the test suite.")
    print(" *")
    print(" * This file is generated by runTestsuite.py -p")
    print(" *")
    print(" * @var Array gTestSuite")
    print(" * An array representing the file hierarchy of the test suite")
    print(" */")
    print("var gTestSuite = [\"testsuite/\"", end="")
    suite.addReftests("printList",
                      MATHJAX_TESTSUITE_PATH, "reftest.list", -1)
    print("]")
    sys.stdout = stdout
    fp.close()

    print("done")
Example #2
0
def printReftestList():
    """
    @fn printReftestList()
    @brief generate the file web/reftestList.js
    """
    print("Generating reftestList.js...", end="")

    suite = reftest.reftestSuite()
    fp = file(MATHJAX_WEB_PATH + "reftestList.js", "w")
    stdout = sys.stdout
    sys.stdout = fp
    print("// " + WARNING_GENERATED_FILE)
    print("/**")
    print(" * @file reftestList.js")
    print(" * @brief array representing the test suite.")
    print(" *")
    print(" * This file is generated by runTestsuite.py -p")
    print(" *")
    print(" * @var Array gTestSuite")
    print(" * An array representing the file hierarchy of the test suite")
    print(" */")
    print("var gTestSuite = [\"testsuite/\"", end="")
    suite.addReftests("printList",
                      MATHJAX_TESTSUITE_PATH, "reftest.list", -1)
    print("]")
    sys.stdout = stdout
    fp.close()

    print("done")
Example #3
0
def printListOfTests(aFile):
    """
    @fn printListOfTests(aFile)
    @brief generate a listOftests from a file
    """
    lines = []
    for line in open(aFile, "r"):
        line = line.rstrip('\n')
        lines.append(line)
    suite = reftest.reftestSuite()
    suite.addReftests(["printListOfTests", lines],
                      MATHJAX_TESTSUITE_PATH, "reftest.list", -1)
    print
Example #4
0
def printListOfTests(aFile):
    """
    @fn printListOfTests(aFile)
    @brief generate a listOftests from a file
    """
    lines = []
    for line in open(aFile, "r"):
        line = line.rstrip('\n')
        lines.append(line)
    suite = reftest.reftestSuite()
    suite.addReftests(["printListOfTests", lines],
                      MATHJAX_TESTSUITE_PATH, "reftest.list", -1)
    print
Example #5
0
def printNotes():
    """
    @fn printNotes()
    @brief generate the file web/reftestList.js
    """
    print "Generating testsuiteNodes.js...",

    suite = reftest.reftestSuite()
    fp = file(MATHJAX_WEB_PATH + "testsuiteNotes.html", "w")
    stdout = sys.stdout
    sys.stdout = fp
    print '<!doctype>'
    print '<!-- ' + WARNING_GENERATED_FILE + '-->'
    print '<html>'
    print '<head>'
    print '  <meta http-equiv="Content-type" content="text/html;charset=UTF-8">'
    print '  <title>Testsuite Notes</title>'
    print '  <link rel="stylesheet" type="text/css" href="default.css"/>'
    print '</head>'
    print '<body>'
    print '<div class="related">'
    print '  <h3>Navigation</h3>'
    print '  <ul>'
    print '    <li><a href="./">Back to home</a></li> '
    print '  </ul>'
    print '</div>'

    print '<div class="body testsuiteNotes">'
    print '  <h1>Testsuite Notes</h1>'

    suite.addReftests("printNotes",
                      MATHJAX_TESTSUITE_PATH, "reftest.list", -1)
    sys.stdout = stdout
    fp.close()

    print '</div>'
    print '</body>'
    print '</html>'

    print "done"
Example #6
0
def printNotes():
    """
    @fn printNotes()
    @brief generate the file web/reftestList.js
    """
    print("Generating testsuiteNodes.js...", end="")

    suite = reftest.reftestSuite()
    fp = file(MATHJAX_WEB_PATH + "testsuiteNotes.html", "w")
    stdout = sys.stdout
    sys.stdout = fp
    print('<!doctype>')
    print('<!-- ' + WARNING_GENERATED_FILE + '-->')
    print('<html>')
    print('<head>')
    print(' <meta http-equiv="Content-type" content="text/html;charset=UTF-8">')
    print(' <title>Testsuite Notes</title>')
    print(' <link rel="stylesheet" type="text/css" href="default.css"/>')
    print('</head>')
    print('<body>')
    print('<div class="related">')
    print('  <h3>Navigation</h3>')
    print('  <ul>')
    print('    <li><a href="./">Back to home</a></li> ')
    print('  </ul>')
    print('</div>')

    print('<div class="body testsuiteNotes">')
    print('  <h1>Testsuite Notes</h1>')

    suite.addReftests("printNotes",
                      MATHJAX_TESTSUITE_PATH, "reftest.list", -1)
    print('</div>')
    print('</body>')
    print('</html>')
    sys.stdout = stdout
    fp.close()

    print("done")
Example #7
0
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)
Example #8
0
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)