Example #1
0
 def test_writing_2(self):
     mockInput = ['1', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y',
         'S', '5.01', 'S', '4.3', 'S', '3', 'M', '2', '3.99', 'Y']
     with mock_stdin(mockInput), suppress_stdout():
         configuration.createConfigFile(self.tempConfigFile)
     self.assertTrue(filecmp.cmp(self.tempConfigFile,
         os.path.join(self.testsDirectory, 'configurationTestWriting2.json'), shallow=False))
Example #2
0
 def test_writing_1(self):
     mockInput = ["1", "Y", "Y", "N", "Y", "Y", "Y", "N"]
     with mock_stdin(mockInput), suppress_stdout():
         configuration.createConfigFile(self.tempConfigFile)
     # check the generated file
     self.assertTrue(filecmp.cmp(self.tempConfigFile,
         os.path.join(self.testsDirectory, 'configurationTestWriting1.json'), shallow=False))
Example #3
0
def main():
    callerPath = os.getcwd()

    init(sys.argv[0])
    sys.path.insert(0, "platforms")
    sys.path.insert(0, os.getcwd())
    returnPath = os.getcwd()
    platformInstance = platformhandler.getInstance()
    if platformInstance is None:
        print "ERROR: Your OS is not supported by Robocheck"
        return

    if len(sys.argv) != 2 or "--help" in sys.argv:
        helpMessage()
        exit()

    configFilePath = os.path.abspath('config.json')
    if "--config" in sys.argv:
        configuration.createConfigFile(configFilePath)
        return
    cleanUp(platformInstance)
    couldRead = configuration.readConfigFile(configFilePath)
    if couldRead is False:
        return

    language = configuration.getLanguage()
    errorsToLookFor = configuration.getErrorsToLookFor()

    tools = modulehandler.getCompatibleModules(language, errorsToLookFor, platformInstance)

    os.mkdir(platformInstance.getTempPath() + "current-robocheck-test")
    os.chdir(callerPath)
    try:
        platformInstance.zipExtractAll(sys.argv[1])
    except Exception:
        print "ERROR: Archive was not Zip format or it was corrupted!"
        exit()

    platformInstance.cdToTemp()
    errorJsonList = []
    os.chdir("current-robocheck-test")
    try:
        sources = os.listdir('src')
        exes = os.listdir('bins')
    except Exception:
        print "ERROR: Archive did not have the expected folders!"
        cleanUp(platformInstance)
        exit()

    exesPath = "bins"
    srcsPath = 'src'

    errorList = []

    for tool in tools:
        errors = tool.runToolGetErrors(platformInstance, exes, sources, exesPath, srcsPath, errorsToLookFor)
        errorsToLookFor = getRemainingErrors(errorsToLookFor, errors)

        for err in errors:
            if err not in errorList:
                errorList.append(err)

    errorJsonList = configuration.getJson(errorList)
    errorJsonList = dict([("ErrorsFound",errorJsonList)])

    print json.dumps(errorJsonList, indent=2)

    os.chdir(callerPath)
    jsonOutput = open('robocheck-output.json', 'w')
    jsonOutput.write(json.dumps(errorJsonList, indent=2))
    jsonOutput.close()

    cleanUp(platformInstance)