summaryrefslogtreecommitdiff
path: root/ttrun/cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'ttrun/cmd.py')
-rw-r--r--ttrun/cmd.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/ttrun/cmd.py b/ttrun/cmd.py
new file mode 100644
index 0000000..a237b1b
--- /dev/null
+++ b/ttrun/cmd.py
@@ -0,0 +1,48 @@
1# Copyright (c) 2016 Red Hat, Inc
2#
3# This file is part of ttrun
4#
5# ttrun is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# ttrun is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17
18import argparse
19import subprocess
20import sys
21
22import testtools
23
24
25def parse_arguments():
26 parser = argparse.ArgumentParser(
27 description='Simple CLI to run tests with testtools')
28 parser.add_argument(
29 '-e', dest='environment', help='tox environment to use')
30 parser.add_argument('tests', nargs='*', help='Tests to run')
31 return parser.parse_args()
32
33
34def main():
35 args = parse_arguments()
36
37 if args.environment:
38 return subprocess.call([
39 '.tox/{environment}/bin/python'.format(
40 environment=args.environment),
41 '-m',
42 'testtools.run'] + args.tests)
43 else:
44 return testtools.run.main([sys.argv[0]] + args.tests, sys.stdout)
45
46
47if __name__ == '__main__':
48 sys.exit(main())