def generateNegativeTestData(depth, error): removeOldNegativeTestFiles(error) # remove old testfiles for given error templatefiles = generateRawTemplates(depth) env = Environment(loader=FileSystemLoader('.')) count = 0 for file in templatefiles: # after this command, the placeholders of the file are replaced with jinja placeholders transList = generateJinjaTemplateFile(file, error) fsmlFilePath = os.path.join( "./testdata/negative/fsm", error, "sample" + file.split("template")[2] + ".fsml") try: fsm = createSpecificFSM(transList) # generate wrong .fsml File if error == 'determinism': fsm = addDeterminismError(fsm) if error == 'duplicateids': fsm = addDuplicateIdError(fsm) if error == 'reachability': fsm = addReachabilityError(fsm) if error == 'resolution': fsm = addResolutionError(fsm) if error == 'infeasible' or error == 'illegal': fsmlFilePath = os.path.join( "./testdata/negative/input", error, "fsm", "sample" + file.split("template")[2] + ".fsml") if error == 'infeasible': wrongInput = generateInfeasibleInput(fsm) else: wrongInput = generateIllegalInput(fsm) inputFile = open( os.path.join("./testdata/negative/input", error, "input" + file.split("template")[2] + ".json"), 'w') inputFile.write(json.dumps(wrongInput)) inputFile.close() fsmlFile = open(fsmlFilePath, 'w') template = env.get_template(file) fsmlData = template.render(states=fsm) fsmlFile.write(fsmlData) fsmlFile.close() count += 1 except ValueError: os.remove(file) print str(count) + " test-data files generated"
def generateNegativeTestData(depth, error): removeOldNegativeTestFiles(error) # remove old testfiles for given error templatefiles = generateRawTemplates(depth) env = Environment(loader=FileSystemLoader('.')) count = 0 for file in templatefiles: # after this command, the placeholders of the file are replaced with jinja placeholders transList = generateJinjaTemplateFile(file, error) fsmlFilePath = os.path.join("./testdata/negative/fsm", error, "sample"+file.split("template")[2]+".fsml") try: fsm = createSpecificFSM(transList) # generate wrong .fsml File if error=='determinism': fsm = addDeterminismError(fsm) if error=='duplicateids': fsm = addDuplicateIdError(fsm) if error=='reachability': fsm = addReachabilityError(fsm) if error=='resolution': fsm = addResolutionError(fsm) if error=='infeasible' or error=='illegal': fsmlFilePath = os.path.join("./testdata/negative/input", error, "fsm", "sample"+file.split("template")[2]+".fsml") if error=='infeasible': wrongInput = generateInfeasibleInput(fsm) else: wrongInput = generateIllegalInput(fsm) inputFile = open(os.path.join("./testdata/negative/input", error, "input"+file.split("template")[2]+".json"), 'w') inputFile.write(json.dumps(wrongInput)) inputFile.close() fsmlFile = open(fsmlFilePath, 'w') template = env.get_template(file) fsmlData = template.render(states=fsm) fsmlFile.write(fsmlData) fsmlFile.close() count += 1 except ValueError: os.remove(file) print str(count)+" test-data files generated"
def generatePositiveTestData(depth): removeOldCorrectTestFiles() templatefiles = generateRawTemplates(depth) env = Environment(loader=FileSystemLoader('.')) count = 0 for file in templatefiles: # after this command, the placeholders of the file are replaced with jinja placeholders transList = generateJinjaTemplateFile(file) try: # generate correct .fsml File fsm = createSpecificFSM(transList) template = env.get_template(file) fsmlData = template.render(states=fsm) fsmlFile = open( os.path.join("./testdata/positive/fsm", "sample" + file.split("template")[2] + ".fsml"), 'w') fsmlFile.write(fsmlData) fsmlFile.close() # generate correct input .json File correctInput, correctOutput = generateCorrectInput(fsm) inputFile = open( "./testdata/positive/input/input" + file.split("template")[2] + ".json", 'w') inputFile.write(json.dumps(correctInput)) inputFile.close() outputFile = open( "./testdata/positive/output/output" + file.split("template")[2] + ".json", 'w') outputFile.write(json.dumps(correctOutput)) outputFile.close() count += 1 except ValueError: os.remove(file) print str(count) + " test-data files generated"
def generatePositiveTestData(depth): removeOldCorrectTestFiles() templatefiles = generateRawTemplates(depth) env = Environment(loader=FileSystemLoader('.')) count = 0 for file in templatefiles: # after this command, the placeholders of the file are replaced with jinja placeholders transList = generateJinjaTemplateFile(file) try: # generate correct .fsml File fsm = createSpecificFSM(transList) template = env.get_template(file) fsmlData = template.render(states=fsm) fsmlFile = open(os.path.join("./testdata/positive/fsm", "sample"+file.split("template")[2]+".fsml"), 'w') fsmlFile.write(fsmlData) fsmlFile.close() # generate correct input .json File correctInput, correctOutput = generateCorrectInput(fsm) inputFile = open("./testdata/positive/input/input"+file.split("template")[2]+".json", 'w') inputFile.write(json.dumps(correctInput)) inputFile.close() outputFile = open("./testdata/positive/output/output"+file.split("template")[2]+".json", 'w') outputFile.write(json.dumps(correctOutput)) outputFile.close() count += 1 except ValueError: os.remove(file) print str(count)+" test-data files generated"