Esempio n. 1
0
 def testCmdErr(self):
     "handling of pipes when process has error"
     er = ExRun(verbFlags=set())
     ifp = er.getFile(self.getInputFile("numbers.txt"))
     ofp1 = er.getFile(self.getOutputFile(".txt.gz"))
     ofp2 = er.getFile(self.getOutputFile(".txt"))
     r1 = er.addCmd(
         (["sort", "-r", FileIn(ifp)], ["tee", FileOut(ofp1)]),
         stdout="/dev/null")
     r2 = er.addCmd(
         (["zcat", FileIn(ofp1, autoDecompress=False)], ["false"]),
         stdout=FileOut(ofp2))
     ex = None
     try:
         er.run()
     except ExRunException, ex:
         self.failUnlessEqual("Experiment failed: 1 error(s) encountered",
                              str(ex))
         ex1 = er.errors[0]
         self.failUnless(isinstance(ex1, ExRunException))
         ex2 = ex1.cause
         self.failUnless(isinstance(ex2, ExRunException))
         ex3 = ex2.cause
         self.failUnless(isinstance(ex3, ProcException))
         exre = "process exited 1: false"
         self.failUnless(str(ex3), exre)
Esempio n. 2
0
 def testArgs(self):
     er = ExRun(verbFlags=verbFlags)
     ifp = er.getFile(self.getInputFile("numbers.txt"))
     ofp1 = er.getFile(self.getOutputFile(".txt.gz"))
     ofp2 = er.getFile(self.getOutputFile(".txt"))
     er.addCmd((["sort", "-r", FileIn(ifp)], ["tee", FileOut(ofp1)]),
               stdout="/dev/null")
     er.addCmd(["sed", "-e", "s/^/= /", FileIn(ofp1)], stdout=FileOut(ofp2))
     try:
         er.run()
     except Exception, ex:
         prExceptions(er, ex)
         raise
Esempio n. 3
0
 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, ex:
         prExceptions(er, ex)
         raise
Esempio n. 4
0
 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, ex:
         prExceptions(er, ex)
         raise
Esempio n. 5
0
 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, ex:
         prExceptions(er, ex)
         raise
Esempio n. 6
0
 def testStdio(self):
     er = ExRun(verbFlags=verbFlags)
     ifp = er.getFile(self.getInputFile("numbers.txt"))
     ofp1 = er.getFile(self.getOutputFile(".txt.gz"))
     ofp2 = er.getFile(self.getOutputFile(".txt"))
     er.addCmd(["sort", "-r"], stdin=ifp, stdout=ofp1)
     er.addCmd((["zcat", FileIn(ofp1, autoDecompress=False)
                 ], ["sed", "-e", "s/^/= /"]),
               stdout=ofp2)
     try:
         er.run()
     except Exception, ex:
         prExceptions(er, ex)
         raise
Esempio n. 7
0
 def testSort2(self):
     "two commands"
     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((c1, c2), requires=ifp))
     try:
         er.run()
     except Exception, ex:
         prExceptions(er, ex)
         raise