summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-14 00:24:38 -0500
committerMike Frysinger <vapier@google.com>2020-02-14 05:52:17 +0000
commitd8fda90eedcee2cc39ba13b9f8f7b7bab37310c3 (patch)
tree3eed85f120ee2d1941828cf63d6b9a0451eb03f0 /tests
parent9cc1d70476b0cfc12b28792d77c15d96d16e64df (diff)
downloadgit-repo-d8fda90eedcee2cc39ba13b9f8f7b7bab37310c3.tar.gz
repo: rework parser setup to handle `init -c`
We added support for `repo init -c` to main.py, but not to the launcher, so the -c option only works after the first init has run which kind of defeats its purpose. Rework the parser setup so that we can tell it whether it's for "init" or "gitc-init" and then add the -c option in the same way we do in main.py. This has the benefit of getting the parser entirely out of the module scope which makes it a lot easier to reason about, and it means we can write some unittests. Change-Id: Icbc2ec3aceb938d5a8f941d5fbce1548553dc5f7 Test: repo help init Test: repo help gitc-init Test: repo init -u https://android.googlesource.com/platform/manifest -c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/255113 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_wrapper.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py
index 4d2cf3fb..a98c4130 100644
--- a/tests/test_wrapper.py
+++ b/tests/test_wrapper.py
@@ -66,6 +66,20 @@ class RepoWrapperUnitTest(RepoWrapperTestCase):
66 self.assertEqual('', stderr.getvalue()) 66 self.assertEqual('', stderr.getvalue())
67 self.assertIn('repo launcher version', stdout.getvalue()) 67 self.assertIn('repo launcher version', stdout.getvalue())
68 68
69 def test_init_parser(self):
70 """Make sure 'init' GetParser works."""
71 parser = self.wrapper.GetParser(gitc_init=False)
72 opts, args = parser.parse_args([])
73 self.assertEqual([], args)
74 self.assertIsNone(opts.manifest_url)
75
76 def test_gitc_init_parser(self):
77 """Make sure 'gitc-init' GetParser works."""
78 parser = self.wrapper.GetParser(gitc_init=True)
79 opts, args = parser.parse_args([])
80 self.assertEqual([], args)
81 self.assertIsNone(opts.manifest_file)
82
69 def test_get_gitc_manifest_dir_no_gitc(self): 83 def test_get_gitc_manifest_dir_no_gitc(self):
70 """ 84 """
71 Test reading a missing gitc config file 85 Test reading a missing gitc config file