def setUpClass(self): AbstractSCMTest.setUpClass() remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) create_git_repo(remote_path) self.rosinstall_filename = os.path.join(self.local_path, "shallow-test.rosinstall") _add_to_file( self.rosinstall_filename, "- git: {local-name: clone, uri: \"file://" + remote_path + "\"}") cmd = [ "wstool", "init", "ws-without-shallow", self.rosinstall_filename ] os.chdir(self.test_root_path) wstool_main(cmd) cmd = [ "wstool", "init", "--shallow", "ws-with-shallow", self.rosinstall_filename ] os.chdir(self.test_root_path) wstool_main(cmd)
def setUp(self): AbstractSCMTest.setUp(self) self.remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(self.remote_path) # create a "remote" repo subprocess.check_call(["git", "init"], cwd=self.remote_path) subprocess.check_call(["touch", "test.txt"], cwd=self.remote_path) subprocess.check_call(["git", "add", "*"], cwd=self.remote_path) subprocess.check_call(["git", "commit", "-m", "modified"], cwd=self.remote_path) po = subprocess.Popen(["git", "log", "-n", "1", "--pretty=format:\"%H\""], cwd=self.remote_path, stdout=subprocess.PIPE) self.version_init = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')[0:12] subprocess.check_call(["git", "tag", "footag"], cwd=self.remote_path) subprocess.check_call(["touch", "test2.txt"], cwd=self.remote_path) subprocess.check_call(["git", "add", "*"], cwd=self.remote_path) subprocess.check_call(["git", "commit", "-m", "modified"], cwd=self.remote_path) po = subprocess.Popen(["git", "log", "-n", "1", "--pretty=format:\"%H\""], cwd=self.remote_path, stdout=subprocess.PIPE) self.version_end = po.stdout.read().decode('UTF-8').rstrip('"').lstrip('"')[0:12] # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote}") self.clone_path = os.path.join(self.local_path, "clone") cmd = ["wstool", "update"] os.chdir(self.local_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__
def test_multi_status_untracked(self): '''tests status output for --untracked. In particular asserts that there are newlines between statuses, and no overlaps''' cmd = ["wstool", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\n?? clone_git/added-fs.txt\n? clone_svn/added-fs.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n? clone_hg/added-fs.txt\n? clone_bzr/added-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n?? clone_git2/added-fs.txt\n', output) cmd = ["wstool", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\n?? clone_git/added-fs.txt\n? clone_svn/added-fs.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n? clone_hg/added-fs.txt\n? clone_bzr/added-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n?? clone_git2/added-fs.txt\n', output) cli = WstoolCLI() self.assertEqual( 0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def setUpClass(self): AbstractSCMTest.setUpClass() self.remote_path = os.path.join(self.test_root_path, 'remote') self.new_remote_path = os.path.join(self.test_root_path, 'fooo') self.version = 'master' self.branch = 'test_branch' self.date = datetime.date.today().isoformat() os.makedirs(self.remote_path) create_git_repo(self.remote_path) # wstool the remote repo and fake ros entry = '''\ - other: {local-name: ../ros} - git: {local-name: clone, uri: ../remote, version: %s} ''' % self.version _add_to_file(os.path.join(self.local_path, '.rosinstall'), entry) cmd = ['wstool', 'update', '-t', 'ws'] os.chdir(self.test_root_path) wstool_main(cmd) self.clone_path = os.path.join(self.local_path, 'clone') modify_git_repo(self.clone_path) subprocess.check_call(['git', 'checkout', '-b', self.branch], cwd=self.clone_path) subprocess.check_call(['git', 'remote', 'set-url', 'origin', self.new_remote_path], cwd=self.clone_path)
def setUp(self): AbstractSCMTest.setUp(self) remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) # create a "remote" repo subprocess.check_call(["bzr", "init"], cwd=remote_path) subprocess.check_call(["touch", "test.txt"], cwd=remote_path) subprocess.check_call(["bzr", "add", "test.txt"], cwd=remote_path) subprocess.check_call(["bzr", "commit", "-m", "modified"], cwd=remote_path) self.version_init = "1" subprocess.check_call(["bzr", "tag", "footag"], cwd=remote_path) subprocess.check_call(["touch", "test2.txt"], cwd=remote_path) subprocess.check_call(["bzr", "add", "test2.txt"], cwd=remote_path) subprocess.check_call(["bzr", "commit", "-m", "modified"], cwd=remote_path) self.version_end = "2" # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- bzr: {local-name: clone, uri: ../remote}") cmd = ["wstool", "update"] os.chdir(self.local_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__
def setUp(self): AbstractSCMTest.setUp(self) remote_path = os.path.join(self.test_root_path, "remote") filler_path = os.path.join(self.test_root_path, "filler") self.svn_uri = "file://localhost" + remote_path # create a "remote" repo subprocess.check_call(["svnadmin", "create", remote_path], cwd=self.test_root_path) subprocess.check_call(["svn", "checkout", self.svn_uri, filler_path], cwd=self.test_root_path) subprocess.check_call(["touch", "test.txt"], cwd=filler_path) subprocess.check_call(["svn", "add", "test.txt"], cwd=filler_path) subprocess.check_call(["svn", "commit", "-m", "modified"], cwd=filler_path) subprocess.check_call(["touch", "test2.txt"], cwd=filler_path) subprocess.check_call(["svn", "add", "test2.txt"], cwd=filler_path) subprocess.check_call(["svn", "commit", "-m", "modified"], cwd=filler_path) self.version_init = "-r1" self.version_end = "-r2" # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- svn: {local-name: clone, uri: '" + self.svn_uri + "'}") cmd = ["wstool", "update"] os.chdir(self.local_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__
def setUp(self): AbstractSCMTest.setUp(self) remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) # create a "remote" repo subprocess.check_call(["hg", "init"], cwd=remote_path) subprocess.check_call(["touch", "test.txt"], cwd=remote_path) subprocess.check_call(["hg", "add", "test.txt"], cwd=remote_path) subprocess.check_call(["hg", "commit", "-m", "modified"], cwd=remote_path) po = subprocess.Popen(["hg", "log", "--template", "'{node|short}'", "-l1"], cwd=remote_path, stdout=subprocess.PIPE) self.version_init = po.stdout.read().decode('UTF-8').rstrip("'").lstrip("'") subprocess.check_call(["hg", "tag", "footag"], cwd=remote_path) subprocess.check_call(["touch", "test2.txt"], cwd=remote_path) subprocess.check_call(["hg", "add", "test2.txt"], cwd=remote_path) subprocess.check_call(["hg", "commit", "-m", "modified"], cwd=remote_path) po = subprocess.Popen(["hg", "log", "--template", "'{node|short}'", "-l1"], cwd=remote_path, stdout=subprocess.PIPE) self.version_end = po.stdout.read().decode('UTF-8').rstrip("'").lstrip("'") # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote}") cmd = ["wstool", "update"] os.chdir(self.local_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__
def test_rosinstall_invalid_fail(self): cmd = copy.copy(self.wstool_fn) cmd.extend([self.directory, "init", self.broken_rosinstall]) try: wstool_main(cmd) self.fail("expected exception") except MultiProjectException: pass
def test_rosinstall_delete_changes(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_rosinstall]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["merge", "-t", self.directory, self.simple_changed_uri_rosinstall, "--merge-replace", "-y"]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["update", "-t", self.directory, "--delete-changed-uri"]) self.assertEqual(0, wstool_main(cmd))
def test_multi_diff_rosinstall_outside(self): '''Test wstool diff output from outside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' cmd = ["wstool", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output)
def test_multi_diff_rosinstall_inside(self): '''Test wstool diff output from inside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' directory = self.test_root_path + "/ws" cmd = ["wstool", "diff"] os.chdir(directory) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() self.check_diff_output(output)
def test_wstool_info_svn(self): cmd = ["wstool", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'svn'], tokens[0:3]) cli = WstoolCLI() self.assertEqual(0, cli.cmd_info(os.path.join(self.test_root_path, 'ws'), []))
def test_wstool_diff_bzr_outside(self): """Test diff output for bzr when run outside workspace""" cmd = ["wstool", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_diff(os.path.join(self.test_root_path, 'ws'), []))
def test_wstool_status_hg_untracked(self): """Test untracked status output for hg when run outside workspace""" cmd = ["wstool", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertEqual('M clone/modified-fs.txt\nM clone/modified.txt\nA clone/added.txt\nR clone/deleted.txt\n! clone/deleted-fs.txt\n? clone/added-fs.txt\n', output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def test_wstool_status_svn_outside(self): """Test status output for svn when run outside workspace""" cmd = ["wstool", "status", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('A clone/added.txt\nD clone/deleted.txt\n! clone/deleted-fs.txt\nM clone/modified.txt\n', output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), []))
def test_wstool_diff_git_inside(self): """Test diff output for git when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["wstool", "diff"] os.chdir(directory) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.check_diff_output(output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_diff(directory, []))
def test_wstool_status_svn_untracked(self): """Test status output for svn when run outside workspace""" cmd = ["wstool", "status", "-t", "ws", "--untracked"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual('? clone/added-fs.txt\nA clone/added.txt\nD clone/deleted.txt\n! clone/deleted-fs.txt\nM clone/modified.txt\n', output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), ["--untracked"]))
def test_rosinstall_delete_changes(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_rosinstall]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend([ "merge", "-t", self.directory, self.simple_changed_uri_rosinstall, "--merge-replace", "-y" ]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["update", "-t", self.directory, "--delete-changed-uri"]) self.assertEqual(0, wstool_main(cmd))
def test_rosinstall_backup_changes(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_rosinstall]) self.assertEqual(0, wstool_main(cmd)) directory1 = tempfile.mkdtemp() self.directories["backup1"] = directory1 cmd = copy.copy(self.wstool_fn) cmd.extend(["merge", "-t", self.directory, self.simple_changed_uri_rosinstall, "--merge-replace", "-y"]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["update", "-t", self.directory, "--backup-changed-uri=%s" % directory1]) self.assertEqual(0, wstool_main(cmd)) self.assertEqual(len(os.listdir(directory1)), 1)
def test_multi_status_rosinstall_inside(self): """Test wstool status output when run inside workspace. In particular asserts that there are newlines between statuses, and no overlaps""" directory = self.test_root_path + "/ws" cmd = ["wstool", "status"] os.chdir(directory) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n', output)
def helper(self, spec, exact, expected_output): cmd = ['wstool', 'export', '-t', 'ws'] if spec: cmd += ['--spec'] if exact: cmd += ['--exact'] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue().encode('utf-8') expected_output = expected_output.encode('utf-8') self.assertEqual(expected_output, output)
def test_wstool_status_hg_inside(self): """Test status output for hg when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["wstool", "status"] os.chdir(directory) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.assertEqual('M clone/modified-fs.txt\nM clone/modified.txt\nA clone/added.txt\nR clone/deleted.txt\n! clone/deleted-fs.txt\n', output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_diff(directory, []))
def test_rosinstall_detailed_locapath_info(self): cmd = ["wstool", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'bzr', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check subprocess.check_call(["rm", "test2.txt"], cwd=clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'bzr', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- bzr: {local-name: clone, uri: ../remote, version: \"footag\"}") os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'bzr', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", "-rf", "clone"], cwd=self.local_path) os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'x', 'bzr', 'footag', os.path.join(self.test_root_path, 'remote')], tokens)
def test_wstool_status_bzr_inside(self): """Test status output for bzr when run inside workspace""" directory = self.test_root_path + "/ws" cmd = ["wstool", "status"] os.chdir(directory) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__ self.assertEqual('+N clone/added.txt\n D clone/deleted-fs.txt\n-D clone/deleted.txt\n M clone/modified-fs.txt\n M clone/modified.txt\n', output) cli = WstoolCLI() self.assertEqual(0, cli.cmd_status(directory, []))
def test_rosinstall_detailed_locapath_info(self): cmd = ["wstool", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'hg', 'default', '(-)', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check subprocess.check_call(["hg", "rm", "test2.txt"], cwd=clone_path) os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'hg', 'default', '(-)', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote, version: \"footag\"}") os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'hg', 'default', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", "-rf", "clone"], cwd=self.local_path) os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'x', 'hg', '(footag)', os.path.join(self.test_root_path, 'remote')], tokens)
def test_rosinstall_abort_changes(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_rosinstall]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["merge", "-t", self.directory, self.simple_changed_uri_rosinstall, "--merge-replace", "-y"]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["update", "-t", self.directory, "--abort-changed-uri"]) try: wstool_main(cmd) self.fail("expected exception") except MultiProjectException: pass
def test_multi_diff_wstool_outside(self): '''Test wstool diff output from outside workspace. In particular asserts that there are newlines between diffs, and no overlaps''' cmd = ["wstool", "diff", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.check_diff_output(output) cli = WstoolCLI() self.assertEqual( 0, cli.cmd_diff(os.path.join(self.test_root_path, 'ws'), []))
def test_multi_status_wstool_outside(self): """Test wstool status output when run outside workspace. In particular asserts that there are newlines between statuses, and no overlaps""" cmd = ["wstool", "status", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) sys.stdout = sys.__stdout__ output = output.getvalue() self.assertStatusListEqual( 'A clone_git/added.txt\n D clone_git/deleted-fs.txt\nD clone_git/deleted.txt\n M clone_git/modified-fs.txt\nM clone_git/modified.txt\nA clone_svn/added.txt\nD clone_svn/deleted.txt\n! clone_svn/deleted-fs.txt\nM clone_svn/modified.txt\nM clone_hg/modified-fs.txt\nM clone_hg/modified.txt\nA clone_hg/added.txt\nR clone_hg/deleted.txt\n! clone_hg/deleted-fs.txt\n+N clone_bzr/added.txt\n D clone_bzr/deleted-fs.txt\n-D clone_bzr/deleted.txt\n M clone_bzr/modified-fs.txt\n M clone_bzr/modified.txt\nA clone_git2/added.txt\n D clone_git2/deleted-fs.txt\nD clone_git2/deleted.txt\n M clone_git2/modified-fs.txt\nM clone_git2/modified.txt\n', output) cli = WstoolCLI() self.assertEqual( 0, cli.cmd_status(os.path.join(self.test_root_path, 'ws'), []))
def test_rosinstall_invalid_continue(self): cmd = copy.copy(self.wstool_fn) cmd.extend([ "-t", self.directory, "merge", self.broken_rosinstall, "--continue-on-error" ]) self.assertTrue(wstool_main(cmd))
def setUpClass(self): AbstractSCMTest.setUpClass() remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) create_bzr_repo(remote_path) # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- bzr: {local-name: clone, uri: %s}" % remote_path) cmd = ["wstool", "update", "-t", "ws"] os.chdir(self.test_root_path) wstool_main(cmd) clone_path = os.path.join(self.local_path, "clone") modify_bzr_repo(clone_path)
def setUpClass(self): AbstractSCMTest.setUpClass() remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) create_hg_repo(remote_path) # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote}") cmd = ["wstool", "update", "-t", "ws"] os.chdir(self.test_root_path) wstool_main(cmd) clone_path = os.path.join(self.local_path, "clone") modify_hg_repo(clone_path)
def setUpClass(self): AbstractSCMTest.setUpClass() remote_path_svn = os.path.join(self.test_root_path, "remote_svn") remote_path_git = os.path.join(self.test_root_path, "remote_git") remote_path_bzr = os.path.join(self.test_root_path, "remote_bzr") remote_path_hg = os.path.join(self.test_root_path, "remote_hg") os.makedirs(remote_path_git) os.makedirs(remote_path_svn) os.makedirs(remote_path_hg) os.makedirs(remote_path_bzr) filler_path = os.path.join(self.test_root_path, "filler") svn_uri = "file://localhost" + remote_path_svn create_svn_repo(self.test_root_path, remote_path_svn, filler_path, svn_uri) create_git_repo(remote_path_git) create_hg_repo(remote_path_hg) create_bzr_repo(remote_path_bzr) # wstool the remote repo and fake ros (using git twice to check all overlaps) rosinstall_spec = """- other: {local-name: ../ros} - git: {local-name: clone_git, uri: ../remote_git} - svn: {local-name: clone_svn, uri: '%s'} - hg: {local-name: clone_hg, uri: ../remote_hg} - bzr: {local-name: clone_bzr, uri: ../remote_bzr} - git: {local-name: clone_git2, uri: ../remote_git}""" % svn_uri _add_to_file(os.path.join(self.local_path, ".rosinstall"), rosinstall_spec) cmd = ["rosws", "update", "-t", "ws"] os.chdir(self.test_root_path) wstool_main(cmd) clone_path_git = os.path.join(self.local_path, "clone_git") clone_path_git2 = os.path.join(self.local_path, "clone_git2") clone_path_svn = os.path.join(self.local_path, "clone_svn") clone_path_hg = os.path.join(self.local_path, "clone_hg") clone_path_bzr = os.path.join(self.local_path, "clone_bzr") modify_git_repo(clone_path_git2) modify_git_repo(clone_path_git) modify_svn_repo(clone_path_svn) modify_hg_repo(clone_path_hg) modify_bzr_repo(clone_path_bzr)
def test_rosinstall_abort_changes(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_rosinstall]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend([ "merge", "-t", self.directory, self.simple_changed_uri_rosinstall, "--merge-replace", "-y" ]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend(["update", "-t", self.directory, "--abort-changed-uri"]) try: wstool_main(cmd) self.fail("expected exception") except MultiProjectException: pass
def setUpClass(self): AbstractSCMTest.setUpClass() remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) create_git_repo(remote_path) self.rosinstall_filename = os.path.join(self.local_path, "shallow-test.rosinstall") _add_to_file(self.rosinstall_filename, "- git: {local-name: clone, uri: \"file://" + remote_path + "\"}") cmd = ["wstool", "init", "ws-without-shallow", self.rosinstall_filename] os.chdir(self.test_root_path) wstool_main(cmd) cmd = ["wstool", "init", "--shallow", "ws-with-shallow", self.rosinstall_filename] os.chdir(self.test_root_path) wstool_main(cmd)
def setUpClass(self): AbstractSCMTest.setUpClass() remote_path = os.path.join(self.test_root_path, "remote") filler_path = os.path.join(self.test_root_path, "filler") svn_uri = "file://localhost" + remote_path create_svn_repo(self.test_root_path, remote_path, filler_path, svn_uri) # wstool the remote repo and fake ros _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- svn: {local-name: clone, uri: '" + svn_uri + "'}") cmd = ["wstool", "update", "-t", "ws"] os.chdir(self.test_root_path) wstool_main(cmd) clone_path = os.path.join(self.local_path, "clone") modify_svn_repo(clone_path)
def test_rosinstall_backup_changes(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_rosinstall]) self.assertEqual(0, wstool_main(cmd)) directory1 = tempfile.mkdtemp() self.directories["backup1"] = directory1 cmd = copy.copy(self.wstool_fn) cmd.extend([ "merge", "-t", self.directory, self.simple_changed_uri_rosinstall, "--merge-replace", "-y" ]) self.assertEqual(0, wstool_main(cmd)) cmd = copy.copy(self.wstool_fn) cmd.extend([ "update", "-t", self.directory, "--backup-changed-uri=%s" % directory1 ]) self.assertEqual(0, wstool_main(cmd)) self.assertEqual(len(os.listdir(directory1)), 1)
def setUp(self): AbstractSCMTest.setUp(self) self.remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(self.remote_path) # create a "remote" repo subprocess.check_call(["git", "init"], cwd=self.remote_path) subprocess.check_call(["touch", "test.txt"], cwd=self.remote_path) subprocess.check_call(["git", "add", "*"], cwd=self.remote_path) subprocess.check_call(["git", "commit", "-m", "modified"], cwd=self.remote_path) po = subprocess.Popen( ["git", "log", "-n", "1", "--pretty=format:\"%H\""], cwd=self.remote_path, stdout=subprocess.PIPE) self.version_init = po.stdout.read().decode('UTF-8').rstrip( '"').lstrip('"')[0:12] subprocess.check_call(["git", "tag", "footag"], cwd=self.remote_path) subprocess.check_call(["touch", "test2.txt"], cwd=self.remote_path) subprocess.check_call(["git", "add", "*"], cwd=self.remote_path) subprocess.check_call(["git", "commit", "-m", "modified"], cwd=self.remote_path) po = subprocess.Popen( ["git", "log", "-n", "1", "--pretty=format:\"%H\""], cwd=self.remote_path, stdout=subprocess.PIPE) self.version_end = po.stdout.read().decode('UTF-8').rstrip('"').lstrip( '"')[0:12] # wstool the remote repo and fake ros _add_to_file( os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote}" ) self.clone_path = os.path.join(self.local_path, "clone") cmd = ["wstool", "update"] os.chdir(self.local_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__
def setUp(self): AbstractSCMTest.setUp(self) remote_path = os.path.join(self.test_root_path, "remote") os.makedirs(remote_path) # create a "remote" repo subprocess.check_call(["hg", "init"], cwd=remote_path) subprocess.check_call(["touch", "test.txt"], cwd=remote_path) subprocess.check_call(["hg", "add", "test.txt"], cwd=remote_path) subprocess.check_call(["hg", "commit", "-m", "modified"], cwd=remote_path) po = subprocess.Popen( ["hg", "log", "--template", "'{node|short}'", "-l1"], cwd=remote_path, stdout=subprocess.PIPE) self.version_init = po.stdout.read().decode('UTF-8').rstrip( "'").lstrip("'") subprocess.check_call(["hg", "tag", "footag"], cwd=remote_path) subprocess.check_call(["touch", "test2.txt"], cwd=remote_path) subprocess.check_call(["hg", "add", "test2.txt"], cwd=remote_path) subprocess.check_call(["hg", "commit", "-m", "modified"], cwd=remote_path) po = subprocess.Popen( ["hg", "log", "--template", "'{node|short}'", "-l1"], cwd=remote_path, stdout=subprocess.PIPE) self.version_end = po.stdout.read().decode('UTF-8').rstrip("'").lstrip( "'") # wstool the remote repo and fake ros _add_to_file( os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote}" ) cmd = ["wstool", "update"] os.chdir(self.local_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() sys.stdout = sys.__stdout__
def test_install(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["init", self.directory, self.simple_tar_rosinstall]) self.assertEquals(0, wstool_main(cmd)) self.assertTrue(os.path.isdir(os.path.join(self.directory, "temptar"))) self.assertTrue(os.path.isfile(os.path.join(self.directory, ".rosinstall"))) stream = open(os.path.join(self.directory, '.rosinstall'), 'r') yamlsrc = yaml.load(stream) stream.close() self.assertEqual(1, len(yamlsrc)) self.assertEqual('tar', list(yamlsrc[0].keys())[0])
def test_rosinstall_detailed_locapath_info(self): cmd = ["wstool", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'svn', self.version_end, self.svn_uri], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check subprocess.check_call(["touch", "test3.txt"], cwd=clone_path) subprocess.check_call(["svn", "add", "test3.txt"], cwd=clone_path) os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'svn', self.version_end, self.svn_uri], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- svn: {local-name: clone, uri: '" + self.svn_uri + "', version: \"1\"}") os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'svn', '1', '(-)', self.version_end, "(%s)" % self.version_init, self.svn_uri], tokens) subprocess.check_call(["rm", "-rf", "clone"], cwd=self.local_path) os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'x', 'svn', '(-)', self.svn_uri], tokens)
def test_rosinstall_invalid_continue(self): cmd = copy.copy(self.wstool_fn) cmd.extend(["-t", self.directory, "merge", self.broken_rosinstall, "--continue-on-error"]) self.assertTrue(wstool_main(cmd))
def test_Rosinstall_help(self): cmd = copy.copy(self.wstool_fn) cmd.append("-h") self.assertEqual(0, wstool_main(cmd))
def test_wstool_detailed_localpath_info(self): cmd = ["wstool", "info", "-t", "ws", "--managed-only"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'git', 'master', '(-)', self.version_end, self.remote_path], tokens) # test when remote version is different subprocess.check_call(["git", "reset", "--hard", "HEAD~1"], cwd=self.clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'C', 'git', 'master', '(-)', self.version_init, self.remote_path], tokens) # return branch back to original revision subprocess.check_call(["git", "reset", "--hard", self.version_end], cwd=self.clone_path) # make local modifications check subprocess.check_call(["rm", "test2.txt"], cwd=self.clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'git', 'master', '(-)', self.version_end, self.remote_path], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote, version: \"footag\"}") # test when version is different sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens) # test when tracking branch is different from current branch subprocess.check_call(["git", "checkout", "-b", "test_branch"], cwd=self.clone_path) subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "origin"], cwd=self.clone_path) subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.merge", "master"], cwd=self.clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens) # test when remote is different from origin by rename subprocess.check_call(["git", "remote", "rename", "origin", "remote2"], cwd=self.clone_path) subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "remote2"], cwd=self.clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'remote2/master', '(footag)', self.version_end, "(%s)" % self.version_init, "(%s)" % self.remote_path], tokens) # return remote name to origin subprocess.check_call(["git", "remote", "rename", "remote2", "origin"], cwd=self.clone_path) # test when remote is different from origin, no fetch subprocess.check_call(["git", "remote", "add", "remote2", "../../remote"], cwd=self.clone_path) subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "remote2"], cwd=self.clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'test_branch', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens) # test when remote is different from origin, with fetch sys.stdout = output = StringIO() wstool_main(cmd + ['--fetch']) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'remote2/master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens) # return branch back to master subprocess.check_call(["git", "checkout", "master"], cwd=self.clone_path) # using a denormalized local-name here subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone/../clone, uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens) # using an absolute path to clone dir here subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+self.clone_path+"', uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual([self.clone_path, 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, self.remote_path], tokens) # using an absolute path here where relative path is shorter to display (also checks x for missing) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+os.path.join(self.local_path, "../foo")+"', uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) localname = os.path.join(os.path.dirname(self.local_path), 'foo') self.assertEqual([localname, 'x', 'git', '(footag)', self.remote_path], tokens)
def test_wstool_detailed_localpath_info(self): cmd = ["wstool", "info", "-t", "ws"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'git', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens, output) clone_path = os.path.join(self.local_path, "clone") # make local modifications check subprocess.check_call(["rm", "test2.txt"], cwd=clone_path) sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'M', 'git', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) # using a denormalized local-name here subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone/../clone, uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) # using an absolute path to clone dir here subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+clone_path+"', uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual([clone_path, 'MV', 'git', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) # using an absolute path here where relative path is shorter to display (also checks x for missing) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: '"+os.path.join(self.local_path, "../foo")+"', uri: ../remote, version: \"footag\"}") sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output)