def test_rosws_info_hg(self): cmd = ["rosws", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() rosws_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'hg'], tokens[0:3], output) cli = RoswsCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_rosws_info_svn(self): cmd = ["rosws", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosws_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'svn'], tokens[0:3]) cli = RoswsCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_rosws_info_git(self): cmd = ["rosws", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO(); rosws_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'git'], tokens[0:3]) tokens2 = _nth_line_split(-1, output) self.assertEqual(1, len(tokens2)) self.assertEqual('../ros', tokens2[0]) cli = RoswsCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_info_only(self): workspace = os.path.join(self.test_root_path, 'ws7') cli = RoswsCLI() self.assertEqual(0, cli.cmd_init([workspace, self.simple_rosinstall])) # pkg_path sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--pkg-path-only'])) output = output.getvalue() self.assertEqual(os.path.join(workspace, 'gitrepo'), output.strip()) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=localname'])) output = output.getvalue() self.assertEqual('ros\ngitrepo', output.strip()) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=version'])) output = output.getvalue() self.assertEqual('', output.strip()) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=uri'])) output = output.getvalue() self.assertEqual('%s\n%s\n' % (os.path.join(self.test_root_path, 'ros'), os.path.join(self.test_root_path, 'gitrepo')), output) sys.stdout = output = StringIO() self.assertEqual(0, cli.cmd_info(workspace, ['--only=cur_revision'])) output = output.getvalue() self.assertEqual(82, len(output)) sys.stdout = sys.__stdout__ # pairs sys.stdout = output = StringIO(); self.assertEqual(0, cli.cmd_info(workspace, ['--only=localname,scmtype'])) output = output.getvalue() self.assertEqual('ros,git\ngitrepo,git', output.strip()) sys.stdout = output = StringIO(); self.assertEqual(0, cli.cmd_info(workspace, ['--only=scmtype,localname'])) output = output.getvalue() self.assertEqual('git,ros\ngit,gitrepo', output.strip())