def testSort2Rules(self): "two commands in separate rules" er = ExRun(verbFlags=verbFlags) ifp = er.getFile(self.getInputFile("numbers.txt")) ofp1 = er.getFile(self.getOutputFile(".txt")) ofp2 = er.getFile(self.getOutputFile(".linecnt")) c1 = Cmd((("sort", "-r", FileIn(ifp)), ("sort", "-nr")), stdout=ofp1) c2 = Cmd((("wc", "-l"), ("sed", "-e", "s/ //g")), stdin=ofp1, stdout=ofp2) er.addRule(CmdRule(c2)) er.addRule(CmdRule(c1, requires=ifp)) try: er.run() except Exception as ex: prExceptions(er, ex) raise self.diffExpected(".txt") self.diffExpected(".linecnt") self.checkGraphStates(er)
def testSort2RulesSub(self): "two commands in separate rules, with file ref subtitution" er = ExRun(verbFlags=verbFlags) ifp = er.getFile(self.getInputFile("numbers.txt")) ofp1 = er.getFile(self.getOutputFile(".txt")) ofp2 = er.getFile(self.getOutputFile(".linecnt")) c1 = Cmd((("sort", "-r", FileIn(ifp)), ("sort", "-nr"), ("tee", FileOut(ofp1))), stdout="/dev/null") c2 = Cmd((("cat", FileIn(ofp1)), ("wc", "-l"), ("sed", "-e", "s/ //g"), ("tee", FileOut(ofp2))), stdout="/dev/null") er.addRule(CmdRule(c2)) er.addRule(CmdRule(c1)) try: er.run() except Exception as ex: prExceptions(er, ex) raise self.diffExpected(".txt") self.diffExpected(".linecnt") self.checkGraphStates(er)
def testSortPipe(self): "pipeline command to sort a file" er = ExRun(verbFlags=verbFlags) ifp = er.getFile(self.getInputFile("numbers.txt")) ofp = er.getFile(self.getOutputFile(".txt")) c = Cmd((("sort", "-r", FileIn(ifp)), ("sort", "-nr")), stdout=ofp) er.addRule(CmdRule(c, requires=ifp, produces=ofp)) try: er.run() except Exception as ex: prExceptions(er, ex) raise self.diffExpected(".txt") self.checkGraphStates(er)
def testFilePrefix(self): "test prefixes to FileIn/FileOut" er = ExRun(verbFlags=verbFlags) ifp = er.getFile(self.getInputFile("numbers.txt")) ofp = er.getFile(self.getOutputFile(".txt")) c = Cmd(("dd", "if=" + FileIn(ifp), "of=" + FileOut(ofp))) er.addRule(CmdRule(c)) try: er.run() except Exception as ex: prExceptions(er, ex) raise self.diffExpected(".txt") self.checkGraphStates(er)
def testSort1(self): "single command to sort a file" er = ExRun(verbFlags=verbFlags) ifp = er.getFile(self.getInputFile("numbers.txt")) ofp = er.getFile(self.getOutputFile(".txt")) # auto add requires and produces c = Cmd(("sort", "-n"), stdin=ifp, stdout=ofp) er.addRule(CmdRule(c)) try: er.run() except Exception as ex: prExceptions(er, ex) raise self.diffExpected(".txt") self.checkGraphStates(er)
def __init__(self, ifp, ofp): CmdRule.__init__(self, requires=ifp, produces=ofp) self.ifp = ifp self.ofp = ofp
def __init__(self, ifp, ofp1, ofp2): CmdRule.__init__(self, requires=ifp, produces=(ofp1, ofp2)) self.ifp = ifp self.ofp1 = ofp1 self.ofp2 = ofp2