diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-02-04 11:45:10 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-02-11 15:22:34 +1000 |
commit | e2b20f67f3cd1a7b59009d78cd284fc4f527faa2 (patch) | |
tree | a1745f21552de1d30a4283564497ccc7f1d5da05 /registry | |
parent | 25661a66bfbb41eed20eb547a1fb26f55d3916dc (diff) |
registry: add --registry argument to support multiple registries per file
Doesn't work for all commands yet.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'registry')
-rwxr-xr-x | registry/xit-bug-registry-test | 21 | ||||
-rw-r--r-- | registry/xit.py | 16 |
2 files changed, 30 insertions, 7 deletions
diff --git a/registry/xit-bug-registry-test b/registry/xit-bug-registry-test index 0d985f1..9bbd351 100755 --- a/registry/xit-bug-registry-test +++ b/registry/xit-bug-registry-test @@ -290,6 +290,7 @@ class TestXITTestRegistry(unittest.TestCase): class TestXITTestRegistryCLI(unittest.TestCase): + EXIT_GENERAL_FAILURE = 1 EXIT_TOO_FEW_ARGS_ERROR_CODE = 2 REGISTRY_SOURCE_FILE = "server-registry.xml" REGISTRY_FILENAME = "/tmp/tmp.registry.xml" @@ -324,10 +325,24 @@ class TestXITTestRegistryCLI(unittest.TestCase): self.cli.run(self.args) self.assertEquals(e.exception.code, self.EXIT_TOO_FEW_ARGS_ERROR_CODE) + # with a registry that doesn't exist + with self.assertRaises(SystemExit) as e: + self.cli.run(self.args + ["-r", "doesnotexist"]) + self.assertEquals(e.exception.code, self.EXIT_TOO_FEW_ARGS_ERROR_CODE); + + # with a registry that does exist + with self.assertRaises(SystemExit) as e: + self.cli.run(self.args + ["-r", "server"]) + self.assertEquals(e.exception.code, self.EXIT_TOO_FEW_ARGS_ERROR_CODE); + def test_list_registry(self): - args = self.args - args.append("list") - self.cli.run(args) + self.cli.run(self.args + ["list"]) + + with self.assertRaises(SystemExit) as e: + self.cli.run(self.args + ["-r", "doesnotexist", "list"]) + self.assertEquals(e.exception.code, self.EXIT_GENERAL_FAILURE); + + self.cli.run(self.args + ["-r", "server", "list"]) def test_show_info(self): args = self.args diff --git a/registry/xit.py b/registry/xit.py index c1b6763..7cb33d8 100644 --- a/registry/xit.py +++ b/registry/xit.py @@ -851,6 +851,7 @@ class XITTestRegistryCLI: "compare the test result with the registry of known test " "successes/failures.\n") parser.add_argument("-f", "--file", help="file containing XIT test registry, modified in-place (default: stdin/stdout) ", action="store", required=False) + parser.add_argument("-r", "--regname", metavar="registry-name", default=None, help="Work on the named test registry (defaults to first if not given) ", action="store", required=False) subparsers = parser.add_subparsers(title="Actions", help=None) list_subparser = subparsers.add_parser("list", help="List all test cases") @@ -936,13 +937,20 @@ class XITTestRegistryCLI: if args.file == None: print >> sys.stderr, "Reading from stdin" args.file = sys.stdin - return self.load_registry_from_file(args.file) + regname = None + return self.load_registry_from_file(args.file, args.regname) - - def load_registry_from_file(self, path): + def load_registry_from_file(self, path, regname = None): registries = XITTestRegistry.fromXML(path) if len(registries) > 1: - print >> sys.stderr, "More than one registry found in input file, this is not supported yet. Using first one only." + if regname != None: + for r in registries: + if r.name == regname: + return r + print >> sys.stderr, "Failed to find requested registry %s." % regname + sys.exit(1) + else: + print >> sys.stderr, "Multiple registries found, but no name given. Using first." elif len(registries) == 0: print >> sys.stderr, "Failed to parse input file." sys.exit(1) |