示例#1
0
 def chooseDefaultHost(self):
     """
     @fn chooseDefaultHost(self)
     @brief Choose a default host according to the operating system
     """
     if (self.mParameters["host"] == "default"):
         self.mParameters["host"] = HOST_LIST[HOST_LIST_OS.index(OS_LIST.index(self.mParameters["operatingSystem"]))]
示例#2
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)
示例#3
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)