def runTest(self): from outputtest import execute output, retVal = execute("echo a") self.assertEquals(output, "a\n") self.assertEquals(retVal, True) output, retVal = execute("cat multiline.txt") self.assertEquals(output, "aap\nbeer\n") self.assertEquals(retVal, True) output, retVal = execute("thiscommanddoesntexist") self.assertEquals(retVal, False) cmd = "while [ 1 -lt 2 ]; do echo 1; done;" self.assertRaises(RuntimeError, execute, cmd, timeout=1)
def evalTest(path): """ runs a single test name should contain the testname, ie the filename of the *.exp, *.cmd etc """ res = TestResult() res.name = os.path.basename(path) fp = os.path.join(path, res.name) try: res.cmd = readFile(fp + '.cmd') res.got, ret = execute(res.cmd) res.sources = grabSources(path) if not ret: res.status = ERROR res.color = "black" res.what = "Failed to excute" else: res.exp = readFile(fp + '.exp') res.what = compare(res.got, res.exp) if res.what == "": res.color = "green" res.status = PASS else: res.color = "red" res.status = FAIL except Exception, e: res.status = ERROR res.color = "black" res.what = "Error: " + str(e)