def test_parse_log_error(self): """Test basic parse_log_for_error functionality.""" errors = ft.parse_log_for_error("error failed", True) self.assertEqual(len(errors), 1) # I expect tests to be run from the base easybuild directory self.assertEqual(os.getcwd(), ft.find_base_dir())
def install_R_package(self, cmd, inp=None): """Install R package as specified, and check for errors.""" cmdttdouterr, _ = run_cmd(cmd, log_all=True, simple=False, inp=inp, regexp=False) cmderrors = parse_log_for_error(cmdttdouterr, regExp="^ERROR:") if cmderrors: cmd = "R -q --no-save" stdin = """ remove.library(%s) """ % self.name # remove package if errors were detected # it's possible that some of the dependencies failed, but the package itself was installed run_cmd(cmd, log_all=False, log_ok=False, simple=False, inp=stdin, regexp=False) self.log.error( "Errors detected during installation of R package %s!" % self.name) else: self.log.debug("R package %s installed succesfully" % self.name)
def runTest(self): """ verify all the possible extract commands also run_cmd should work with some basic echo/exit combos """ cmd = ft.extract_cmd("test.zip") self.assertEqual("unzip -qq test.zip", cmd) cmd = ft.extract_cmd("/some/path/test.tar") self.assertEqual("tar xf /some/path/test.tar", cmd) cmd = ft.extract_cmd("test.tar.gz") self.assertEqual("tar xzf test.tar.gz", cmd) cmd = ft.extract_cmd("test.tgz") self.assertEqual("tar xzf test.tgz", cmd) cmd = ft.extract_cmd("test.bz2") self.assertEqual("bunzip2 test.bz2", cmd) cmd = ft.extract_cmd("test.tbz") self.assertEqual("tar xjf test.tbz", cmd) cmd = ft.extract_cmd("test.tar.bz2") self.assertEqual("tar xjf test.tar.bz2", cmd) (out, ec) = ft.run_cmd("echo hello") self.assertEqual(out, "hello\n") # no reason echo hello could fail self.assertEqual(ec, 0) (out, ec) = ft.run_cmd_qa("echo question", {"question":"answer"}) self.assertEqual(out, "question\n") # no reason echo hello could fail self.assertEqual(ec, 0) self.assertEqual(True, ft.run_cmd("echo hello", simple=True)) self.assertEqual(False, ft.run_cmd("exit 1", simple=True, log_all=False, log_ok=False)) name = ft.convert_name("test+test-test") self.assertEqual(name, "testplustestmintest") name = ft.convert_name("test+test-test", True) self.assertEqual(name, "TESTPLUSTESTMINTEST") errors = ft.parse_log_for_error("error failed", True) self.assertEqual(len(errors), 1) # I expect tests to be run from the base easybuild directory self.assertEqual(os.getcwd(), ft.find_base_dir())
def install_R_package(self, cmd, inp=None): """Install R package as specified, and check for errors.""" cmdttdouterr, _ = run_cmd(cmd, log_all=True, simple=False, inp=inp, regexp=False) cmderrors = parse_log_for_error(cmdttdouterr, regExp="^ERROR:") if cmderrors: cmd = "R -q --no-save" stdin = """ remove.library(%s) """ % self.name # remove package if errors were detected # it's possible that some of the dependencies failed, but the package itself was installed run_cmd(cmd, log_all=False, log_ok=False, simple=False, inp=stdin, regexp=False) self.log.error("Errors detected during installation of R package %s!" % self.name) else: self.log.debug("R package %s installed succesfully" % self.name)