def test_extract_cmd(self): """Test various extract commands.""" tests = [ ('test.zip', "unzip -qq test.zip"), ('/some/path/test.tar', "tar xf /some/path/test.tar"), ('test.tar.gz', "tar xzf test.tar.gz"), ('test.TAR.GZ', "tar xzf test.TAR.GZ"), ('test.tgz', "tar xzf test.tgz"), ('test.gtgz', "tar xzf test.gtgz"), ('test.bz2', "bunzip2 test.bz2"), ('test.tbz', "tar xjf test.tbz"), ('test.tbz2', "tar xjf test.tbz2"), ('test.tb2', "tar xjf test.tb2"), ('test.tar.bz2', "tar xjf test.tar.bz2"), ('test.gz', "gunzip -c test.gz > test"), ('untar.gz', "gunzip -c untar.gz > untar"), ("/some/path/test.gz", "gunzip -c /some/path/test.gz > test"), ('test.xz', "unxz test.xz"), ('test.tar.xz', "unxz test.tar.xz --stdout | tar x"), ('test.txz', "unxz test.txz --stdout | tar x"), ('test.iso', "7z x test.iso"), ('test.tar.Z', "tar xZf test.tar.Z"), ] for (fn, expected_cmd) in tests: cmd = ft.extract_cmd(fn) self.assertEqual(expected_cmd, cmd) self.assertEqual("unzip -qq -o test.zip", ft.extract_cmd('test.zip', True))
def test_extract_cmd(self): """Test various extract commands.""" tests = [ ('test.zip', "unzip -qq test.zip"), ('/some/path/test.tar', "tar xf /some/path/test.tar"), ('test.tar.gz', "tar xzf test.tar.gz"), ('test.TAR.GZ', "tar xzf test.TAR.GZ"), ('test.tgz', "tar xzf test.tgz"), ('test.gtgz', "tar xzf test.gtgz"), ('test.bz2', "bunzip2 -c test.bz2 > test"), ('/some/path/test.bz2', "bunzip2 -c /some/path/test.bz2 > test"), ('test.tbz', "tar xjf test.tbz"), ('test.tbz2', "tar xjf test.tbz2"), ('test.tb2', "tar xjf test.tb2"), ('test.tar.bz2', "tar xjf test.tar.bz2"), ('test.gz', "gunzip -c test.gz > test"), ('untar.gz', "gunzip -c untar.gz > untar"), ("/some/path/test.gz", "gunzip -c /some/path/test.gz > test"), ('test.xz', "unxz test.xz"), ('test.tar.xz', "unxz test.tar.xz --stdout | tar x"), ('test.txz', "unxz test.txz --stdout | tar x"), ('test.iso', "7z x test.iso"), ('test.tar.Z', "tar xZf test.tar.Z"), ] for (fn, expected_cmd) in tests: cmd = ft.extract_cmd(fn) self.assertEqual(expected_cmd, cmd) self.assertEqual("unzip -qq -o test.zip", ft.extract_cmd('test.zip', True))
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_extract_cmd(self): """Test various extract commands.""" tests = [ ('test.zip', "unzip -qq test.zip"), ('/some/path/test.tar', "tar xf /some/path/test.tar"), ('test.tar.gz', "tar xzf test.tar.gz"), ('test.tgz', "tar xzf test.tgz"), ('test.gtgz', "tar xzf test.gtgz"), ('test.bz2', "bunzip2 test.bz2"), ('test.tbz', "tar xjf test.tbz"), ('test.tbz2', "tar xjf test.tbz2"), ('test.tb2', "tar xjf test.tb2"), ('test.tar.bz2', "tar xjf test.tar.bz2"), ] for (fn, expected_cmd) in tests: cmd = ft.extract_cmd(fn) self.assertEqual(expected_cmd, cmd)
def test_extract_cmd(self): """Test various extract commands.""" tests = [ ('test.zip', "unzip -qq test.zip"), ('/some/path/test.tar', "tar xf /some/path/test.tar"), ('test.tar.gz', "tar xzf test.tar.gz"), ('test.tgz', "tar xzf test.tgz"), ('test.gtgz', "tar xzf test.gtgz"), ('test.bz2', "bunzip2 test.bz2"), ('test.tbz', "tar xjf test.tbz"), ('test.tbz2', "tar xjf test.tbz2"), ('test.tb2', "tar xjf test.tb2"), ('test.tar.bz2', "tar xjf test.tar.bz2"), ] for (fn, expected_cmd) in tests: cmd = ft.extract_cmd(fn) self.assertEqual(expected_cmd, cmd)
def test_extract_cmd(self): """Test various extract commands.""" tests = [ ("test.zip", "unzip -qq test.zip"), ("/some/path/test.tar", "tar xf /some/path/test.tar"), ("test.tar.gz", "tar xzf test.tar.gz"), ("test.tgz", "tar xzf test.tgz"), ("test.gtgz", "tar xzf test.gtgz"), ("test.bz2", "bunzip2 test.bz2"), ("test.tbz", "tar xjf test.tbz"), ("test.tbz2", "tar xjf test.tbz2"), ("test.tb2", "tar xjf test.tb2"), ("test.tar.bz2", "tar xjf test.tar.bz2"), ("test.gz", "gunzip -c test.gz > test"), ("/some/path/test.gz", "gunzip -c /some/path/test.gz > test"), ("test.xz", "unxz test.xz"), ("test.tar.xz", "unxz test.tar.xz --stdout | tar x"), ("test.txz", "unxz test.txz --stdout | tar x"), ("test.iso", "7z x test.iso"), ] for (fn, expected_cmd) in tests: cmd = ft.extract_cmd(fn) self.assertEqual(expected_cmd, cmd)
def test_extract_cmd(self): """Test various extract commands.""" 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)
def test_extract_cmd(self): """Test various extract commands.""" 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)