def runner(nomeFunc, mainString, testResult, fun_name):
    # Executa tudo no arquivo test.py com o comando "python3 test.py"
    grafo = Grafo()
    #walker = Ast_walker(grafo)
    codeAst = ast.parse(inspect.getsource(nomeFunc))
    ##listCoverage = getCoverage(nomeFunc, mainString,fun_name, mod_name)
    #walker.visit(codeAst) #dentro do walker fazer com que o nó possua as informações
                          #da Sintaxe Abstrata do código para poder gerar dados com base nisso
    
    cfg = CFGBuilder().build_from_file('foo.py', './foo.py')
    grafo = cfg._build_visual()
    
    #grafo.render(filename='g1.dot')
    paths = []#ACOSymple.createGraph(grafo)

    dataGenerator(paths, ast.dump(codeAst))
    
    #del grafo
    
Example #2
0
"""
def getConditions(graph):
    # Get Cutset
    condDict = {}
    for node in graph:
        reLi = re.findall("\d -> \d", node)
        if reLi:
            arr = reLi[0].split("->")
            stTuple = (int(arr[0]),int(arr[1]))
            condDict[stTuple] = re.findall("\"[^\"]*\"", node)[0].split("\"")[1]
    return condDict


cfg = CFGBuilder().build_from_file('z3_test.py', './z3_test.py')

graph = cfg._build_visual()
# graph.render('z3_graph.gv', view=True)  
# print(graph.graph_attr)

# first pass - save nodes with location
# second pass - find back-edges and put cut points at locations

# Get Code Frag definitions
cDict = getCodeDef(graph)
print(cDict)

# Get condition statements parsed
condDict = getConditions(graph)
cutSet = set()

# Find cutset