Example #1
0
def verifyTestScript(options):
    '''
    Verifyies test script.
    '''
    main.openspeak = openspeak.OpenSpeak()
    openspeakfile = main.testDir + "/" + main.TEST + "/" + main.TEST + ".ospk"
    testfile = main.testDir + "/" + main.TEST + "/" + main.TEST + ".py"
    if os.path.exists(openspeakfile):
        main.openspeak.compiler(openspeakfile=openspeakfile, writetofile=1)
    elif os.path.exists(testfile):
        print ''
    else:
        print "\nThere is no :\"" + main.TEST + "\" test, Please Provide OpenSpeak Script/ test script"
        __builtin__.testthread = None
        main.exit()

    try:
        testModule = __import__(main.classPath, globals(), locals(),
                                [main.TEST], -1)
    except (ImportError):
        print "There was an import error, it might mean that there is no test like " + main.TEST
        main.exit()

    testClass = getattr(testModule, main.TEST)
    main.testObject = testClass()
    load_parser()
    main.params = main.parser.parseParams(main.classPath)
    main.topology = main.parser.parseTopology(main.classPath)
Example #2
0
def verifyTestScript(options):
    '''
    Verifyies test script.
    '''
    main.openspeak = openspeak.OpenSpeak()
    openspeakfile = main.testDir + "/" + main.TEST + "/" + main.TEST + ".ospk"
    testfile = main.testDir + "/" + main.TEST + "/" + main.TEST + ".py"
    if os.path.exists(openspeakfile):
        # Openspeak file found, compiling to python
        main.openspeak.compiler(openspeakfile=openspeakfile, writetofile=1)
    elif os.path.exists(testfile):
        # No openspeak found, using python file instead
        pass
    else:
        print "\nThere is no \"" + main.TEST + "\" test script.\nPlease provide a " +\
              "Python or OpenSpeak test script in the tests folder: " +\
              main.testDir + "/" + main.TEST + "/"
        __builtin__.testthread = None
        main.exit()
    try:
        testModule = __import__(main.classPath, globals(), locals(),
                                [main.TEST], -1)
    except ImportError:
        print "There was an import error, it might mean that there is " +\
              "no test named " + main.TEST
        main.exit()

    testClass = getattr(testModule, main.TEST)
    main.testObject = testClass()
    load_parser()
    main.params = main.parser.parseParams(main.classPath)
    main.topology = main.parser.parseTopology(main.classPath)
Example #3
0
def verifyTestScript( options ):
    '''
    Verifyies test script.
    '''
    main.openspeak = openspeak.OpenSpeak()
    directory = main.testDir + "/" + main.TEST
    if os.path.exists( directory ):
        pass
    else:
        directory = ""
        for root, dirs, files in os.walk( main.testDir, topdown=True ):
            if not directory:
                for name in dirs:
                    if name == main.TEST:
                        directory = ( os.path.join( root, name ) )
                        index = directory.find( "/tests/" ) + 1
                        main.classPath = directory[ index: ].replace( '/', '.' ) + "." + main.TEST
                        break
    openspeakfile = directory + "/" + main.TEST + ".ospk"
    main.testDir = directory
    main.testFile = directory + "/" + main.TEST + ".py"
    if os.path.exists( openspeakfile ):
        # Openspeak file found, compiling to python
        main.openspeak.compiler( openspeakfile=openspeakfile, writetofile=1 )
    elif os.path.exists( main.testFile ):
        # No openspeak found, using python file instead
        pass
    else:
        print "\nThere is no \"" + main.TEST + "\" test script.\nPlease provide a " + \
              "Python or OpenSpeak test script in the tests folder: " + \
              main.testDir + "/" + main.TEST + "/"
        __builtin__.testthread = None
        main.exit()
    try:
        testModule = __import__( main.classPath,
                                 globals(),
                                 locals(),
                                 [ main.TEST ],
                                 -1 )
    except ImportError:
        print "There was an import error, it might mean that there is " + \
              "no test named " + main.TEST
        main.exit()

    testClass = getattr( testModule, main.TEST )
    main.testObject = testClass()
    load_parser()
    main.paramsFile = main.TEST + ".params" if options.paramsFile is None else options.paramsFile
    main.topoFile = main.TEST + ".topo" if options.topoFile is None else options.topoFile
    main.params = main.parser.parseFile( main.testDir + "/" + main.paramsFile )
    main.topology = main.parser.parseFile( main.testDir + "/" + main.topoFile )