self.invokeChecker(self.inputFilePath) self.assertOutput(lambda output: 0 != output.returncode, 'return code was zero.') if __name__ == '__main__': args = arg_parser.parse_args(sys.argv[1:]) args = vars(args) if not os.path.exists(args['CHECKER']): print("Could not find: " + args['CHECKER']) exit(1) checker = OMRChecker(os.path.abspath(args['CHECKER'])) goodFiles = gen_data.genFileList('testing/input/good') badFiles = gen_data.genFileList('testing/input/bad') tests = [TestReturnZero(inputFilePath) for inputFilePath in goodFiles] + [ TestReturnNotZero(inputFilePath) for inputFilePath in badFiles ] testSuite = tooltester.TestSuite(checker, tests) runner = tooltester.SuiteRunner(testSuite, args['MCOMMAND'], args['MRETURN'], args['MSTDERR'], args['MSTDOUT']) runner.runTests() runner.printSummary() if runner.testsFailed != 0: exit(1)
self.assertOutput(lambda output: 0 == output.returncode, 'return code was not zero.') self.assertFalse( os.path.exists(self.inputFilePath + '.OMRRewritten'), 'unexpected file generated: ' + self.inputFilePath + '.OMRRewriter') if __name__ == '__main__': args = arg_parser.parse_args(sys.argv[1:]) args = vars(args) checker = OMRRewriter(args['REWRITER']) iscpp = (lambda fileName: fileName[-3:] == 'cpp') goodNoFix = gen_data.genFileList('testing/input/good_no_fix', iscpp) goodCanFix = gen_data.genFileList('testing/input/good_can_fix', iscpp) badWithFix = gen_data.genFileList('testing/input/bad_with_fix', iscpp) badWithoutFix = gen_data.genFileList('testing/input/bad_without_fix', iscpp) tests = [TestNoOutputFile(inputFilePath) for inputFilePath in goodNoFix] + \ [TestOutputFile(inputFilePath) for inputFilePath in goodCanFix] + \ [TestOutputFile(inputFilePath) for inputFilePath in badWithFix] + \ [TestNoOutputFile(inputFilePath) for inputFilePath in badWithoutFix] testSuite = tooltester.TestSuite(checker, tests) runner = tooltester.SuiteRunner(testSuite, args['MCOMMAND'], args['MRETURN'], args['MSTDERR'], args['MSTDOUT']) runner.runTests()
super(TestNoOutputFile, self).__init__(inputFilePath, rewriter) def run(self): self.invokeRewriter(self.inputFilePath) self.assertOutput(lambda output: 0 == output.returncode, 'return code was not zero.') self.assertFalse(os.path.exists(self.inputFilePath + '.OMRRewritten'), 'unexpected file generated: ' + self.inputFilePath + '.OMRRewriter') if __name__ == '__main__': args = arg_parser.parse_args(sys.argv[1:]) args = vars(args) checker = OMRRewriter(args['REWRITER']) iscpp = (lambda fileName: fileName[-3:] == 'cpp') goodNoFix = gen_data.genFileList('testing/input/good_no_fix', iscpp) goodCanFix = gen_data.genFileList('testing/input/good_can_fix', iscpp) badWithFix = gen_data.genFileList('testing/input/bad_with_fix', iscpp) badWithoutFix = gen_data.genFileList('testing/input/bad_without_fix', iscpp) tests = [TestNoOutputFile(inputFilePath) for inputFilePath in goodNoFix] + \ [TestOutputFile(inputFilePath) for inputFilePath in goodCanFix] + \ [TestOutputFile(inputFilePath) for inputFilePath in badWithFix] + \ [TestNoOutputFile(inputFilePath) for inputFilePath in badWithoutFix] testSuite = tooltester.TestSuite(checker, tests) runner = tooltester.SuiteRunner(testSuite, args['MCOMMAND'], args['MRETURN'], args['MSTDERR'], args['MSTDOUT']) runner.runTests() runner.printSummary() if runner.testsFailed != 0: exit(1)
class TestReturnNotZero(CheckerTestCase): def __init__(self, inputFilePath, checker=None): super(TestReturnNotZero, self).__init__(inputFilePath, checker) def run(self): self.invokeChecker(self.inputFilePath) self.assertOutput(lambda output: 0 != output.returncode, 'return code was zero.') if __name__ == '__main__': args = arg_parser.parse_args(sys.argv[1:]) args = vars(args) if not os.path.exists(args['CHECKER']): print("Could not find: " + args['CHECKER']) exit(1) checker = OMRChecker(os.path.abspath(args['CHECKER'])) goodFiles = gen_data.genFileList('testing/input/good') badFiles = gen_data.genFileList('testing/input/bad') tests = [TestReturnZero(inputFilePath) for inputFilePath in goodFiles] + [TestReturnNotZero(inputFilePath) for inputFilePath in badFiles] testSuite = tooltester.TestSuite(checker, tests) runner = tooltester.SuiteRunner(testSuite, args['MCOMMAND'], args['MRETURN'], args['MSTDERR'], args['MSTDOUT']) runner.runTests() runner.printSummary() if runner.testsFailed != 0: exit(1)