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 test_find_base_dir(self): """test if we find the correct base dir""" tmpdir = tempfile.mkdtemp() foodir = os.path.join(tmpdir, 'foo') os.mkdir(foodir) os.mkdir(os.path.join(tmpdir, '.bar')) os.mkdir(os.path.join(tmpdir, 'easybuild')) os.chdir(tmpdir) self.assertTrue(os.path.samefile(foodir, ft.find_base_dir()))
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 test_cwd(self): """tests should be run from the base easybuild directory""" # used to be part of test_parse_log_error self.assertEqual(os.getcwd(), ft.find_base_dir())