Parse additional stestr paramters
Change-Id: Ib8eadad94fbf2d694a8cd8cef1fb0d80851f222f
This commit is contained in:
parent
7407fe8f02
commit
6988b6fa4e
|
@ -40,6 +40,13 @@ class FixtureUtil(base.TobikoCMD):
|
|||
subcommand_parser = subparsers.add_parser(
|
||||
subcommand_name, help=(subcommand_name + ' fixtures'))
|
||||
subcommand_parser.set_defaults(subcommand=subcommand_name)
|
||||
subcommand_parser.add_argument(
|
||||
'filters',
|
||||
nargs='*',
|
||||
help=("A list of string regex filters to initially apply "
|
||||
"on the test list. Tests that match any of the "
|
||||
"regexes will be used. (assuming any other filtering "
|
||||
"specified also uses it)."))
|
||||
subcommand_parser.add_argument(
|
||||
'--config', '-c',
|
||||
default='.stestr.conf',
|
||||
|
@ -53,10 +60,41 @@ class FixtureUtil(base.TobikoCMD):
|
|||
help=("Select the repo backend to use"))
|
||||
subcommand_parser.add_argument(
|
||||
'--repo-url', '-u',
|
||||
default=None,
|
||||
help=("Set the repo url to use. An acceptable value for "
|
||||
"this depends on the repository type used."))
|
||||
|
||||
subcommand_parser.add_argument(
|
||||
'--test-path', '-t',
|
||||
help=("Set the test path to use for unittest discovery. If "
|
||||
"both this and the corresponding config file option "
|
||||
"are set, this value will be used."))
|
||||
subcommand_parser.add_argument(
|
||||
'--top-dir',
|
||||
help=("Set the top dir to use for unittest discovery. If "
|
||||
"both this and the corresponding config file option "
|
||||
"are set, this value will be used."))
|
||||
subcommand_parser.add_argument(
|
||||
'--group-regex', '--group_regex', '-g',
|
||||
help=("Set a group regex to use for grouping tests together "
|
||||
"in the stestr scheduler. If both this and the "
|
||||
"corresponding config file option are set this value "
|
||||
"will be used."))
|
||||
subcommand_parser.add_argument(
|
||||
'--blacklist-file', '-b',
|
||||
help=("Path to a blacklist file, this file contains a "
|
||||
"separate regex exclude on each newline."))
|
||||
subcommand_parser.add_argument(
|
||||
'--whitelist-file', '-w',
|
||||
help=("Path to a whitelist file, this file contains a "
|
||||
"separate regex on each newline."))
|
||||
subcommand_parser.add_argument(
|
||||
'--black-regex', '-B',
|
||||
help=("Test rejection regex. If a test cases name matches "
|
||||
"on re.search() operation , it will be removed from "
|
||||
"the final test list. Effectively the black-regexp is "
|
||||
"added to black regexp list, but you do need to edit "
|
||||
"a file. The black filtering happens after the "
|
||||
"initial white selection, which by default is "
|
||||
"everything."))
|
||||
return parser
|
||||
|
||||
def execute(self):
|
||||
|
@ -69,7 +107,17 @@ class FixtureUtil(base.TobikoCMD):
|
|||
return self.cleanup_fixtures()
|
||||
|
||||
def discovertest_cases(self):
|
||||
return tobiko.discover_testcases(config=self.args.config)
|
||||
return tobiko.discover_testcases(
|
||||
config=self.args.config,
|
||||
repo_type=self.args.repo_type,
|
||||
repo_url=self.args.repo_url,
|
||||
test_path=self.args.test_path,
|
||||
top_dir=self.args.top_dir,
|
||||
group_regex=self.args.group_regex,
|
||||
blacklist_file=self.args.blacklist_file,
|
||||
whitelist_file=self.args.whitelist_file,
|
||||
black_regex=self.args.black_regex,
|
||||
filters=self.args.filters)
|
||||
|
||||
def list_fixtures(self, stream=sys.stdout):
|
||||
stream = stream or sys.stdout
|
||||
|
|
|
@ -47,17 +47,26 @@ class FixtureUtilTest(unit.TobikoUnitTest):
|
|||
argv = [self.command_name, subcommand] + list(argv or [])
|
||||
return self.patch('sys.argv', argv)
|
||||
|
||||
def test_init(self, argv=None, subcommand=None,
|
||||
def test_init(self, argv=None, subcommand=None, filters=None,
|
||||
config_file='.stestr.conf', repo_type='file',
|
||||
repo_url=None):
|
||||
repo_url=None, test_path=None, top_dir=None,
|
||||
group_regex=None, blacklist_file=None,
|
||||
whitelist_file=None, black_regex=None):
|
||||
self.patch_argv(argv=argv, subcommand=subcommand)
|
||||
cmd = self.command_class()
|
||||
self.mock_error.assert_not_called()
|
||||
self.assertIsNotNone(cmd.args)
|
||||
self.assertEqual(filters or [], cmd.args.filters)
|
||||
self.assertEqual(config_file, cmd.args.config)
|
||||
self.assertEqual(subcommand or 'list', cmd.args.subcommand)
|
||||
self.assertEqual(repo_type, cmd.args.repo_type)
|
||||
self.assertEqual(repo_url, cmd.args.repo_url)
|
||||
self.assertEqual(test_path, cmd.args.test_path)
|
||||
self.assertEqual(top_dir, cmd.args.top_dir)
|
||||
self.assertEqual(group_regex, cmd.args.group_regex)
|
||||
self.assertEqual(blacklist_file, cmd.args.blacklist_file)
|
||||
self.assertEqual(whitelist_file, cmd.args.whitelist_file)
|
||||
self.assertEqual(black_regex, cmd.args.black_regex)
|
||||
|
||||
def test_init_with_c(self):
|
||||
self.test_init(argv=['-c', 'some-config-file'],
|
||||
|
@ -91,3 +100,54 @@ class FixtureUtilTest(unit.TobikoUnitTest):
|
|||
|
||||
def test_init_with_cleanup(self):
|
||||
self.test_init(subcommand='cleanup')
|
||||
|
||||
def test_init_with_filters(self):
|
||||
self.test_init(argv=['a', 'b', 'c'], filters=['a', 'b', 'c'])
|
||||
|
||||
def test_init_with_t(self):
|
||||
self.test_init(argv=['-t', 'some/test/path'],
|
||||
test_path='some/test/path')
|
||||
|
||||
def test_init_with_test_path(self):
|
||||
self.test_init(argv=['--test-path', 'some/test/path'],
|
||||
test_path='some/test/path')
|
||||
|
||||
def test_init_with_top_dir(self):
|
||||
self.test_init(argv=['--top-dir', 'some/top/dir'],
|
||||
top_dir='some/top/dir')
|
||||
|
||||
def test_init_with_g(self):
|
||||
self.test_init(argv=['-g', 'some-regex'],
|
||||
group_regex='some-regex')
|
||||
|
||||
def test_init_with_group_regex(self):
|
||||
self.test_init(argv=['--group-regex', 'some-regex'],
|
||||
group_regex='some-regex')
|
||||
|
||||
def test_init_with_group_regex2(self):
|
||||
self.test_init(argv=['--group_regex', 'some-regex'],
|
||||
group_regex='some-regex')
|
||||
|
||||
def test_init_with_b(self):
|
||||
self.test_init(argv=['-b', 'some/blacklist-file'],
|
||||
blacklist_file='some/blacklist-file')
|
||||
|
||||
def test_init_with_blacklist_file(self):
|
||||
self.test_init(argv=['--blacklist-file', 'some/blacklist-file'],
|
||||
blacklist_file='some/blacklist-file')
|
||||
|
||||
def test_init_with_w(self):
|
||||
self.test_init(argv=['-w', 'some/whitelist-file'],
|
||||
whitelist_file='some/whitelist-file')
|
||||
|
||||
def test_init_with_whitelist_file(self):
|
||||
self.test_init(argv=['--whitelist-file', 'some/whitelist-file'],
|
||||
whitelist_file='some/whitelist-file')
|
||||
|
||||
def test_init_with_B(self):
|
||||
self.test_init(argv=['-B', 'some-black-regex'],
|
||||
black_regex='some-black-regex')
|
||||
|
||||
def test_init_with_blacklist_regex(self):
|
||||
self.test_init(argv=['--black-regex', 'some-black-regex'],
|
||||
black_regex='some-black-regex')
|
||||
|
|
Loading…
Reference in New Issue