Matthew Treinish | 519cb3e | 2013-10-28 20:27:38 +0000 | [diff] [blame] | 1 | # Copyright 2013 IBM Corp. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
Matthew Treinish | a0f820f | 2014-09-16 11:25:34 -0400 | [diff] [blame] | 15 | import os |
Matthew Treinish | 519cb3e | 2013-10-28 20:27:38 +0000 | [diff] [blame] | 16 | import re |
| 17 | import subprocess |
| 18 | |
Masayuki Igawa | 134d9f7 | 2017-02-10 18:05:26 +0900 | [diff] [blame] | 19 | import six |
| 20 | |
Matthew Treinish | ffad78a | 2016-04-16 14:39:52 -0400 | [diff] [blame] | 21 | from tempest.tests import base |
Matthew Treinish | 519cb3e | 2013-10-28 20:27:38 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | class TestTestList(base.TestCase): |
| 25 | |
Masayuki Igawa | d0b8ebd | 2017-09-14 14:51:25 -0600 | [diff] [blame] | 26 | def test_stestr_list_no_errors(self): |
Matthew Treinish | a0f820f | 2014-09-16 11:25:34 -0400 | [diff] [blame] | 27 | test_env = os.environ.copy() |
Matthew Treinish | 519cb3e | 2013-10-28 20:27:38 +0000 | [diff] [blame] | 28 | import_failures = [] |
Masayuki Igawa | d0b8ebd | 2017-09-14 14:51:25 -0600 | [diff] [blame] | 29 | p = subprocess.Popen(['stestr', 'list'], stdout=subprocess.PIPE, |
Matthew Treinish | a0f820f | 2014-09-16 11:25:34 -0400 | [diff] [blame] | 30 | env=test_env) |
| 31 | ids, err = p.communicate() |
| 32 | self.assertEqual(0, p.returncode, |
| 33 | "test discovery failed, one or more files cause an " |
Sean Dague | 6a9764d | 2015-01-06 17:12:16 -0500 | [diff] [blame] | 34 | "error on import %s" % ids) |
Matthew Treinish | 0948724 | 2015-05-10 12:43:58 -0400 | [diff] [blame] | 35 | ids = six.text_type(ids).split('\n') |
Matthew Treinish | 519cb3e | 2013-10-28 20:27:38 +0000 | [diff] [blame] | 36 | for test_id in ids: |
| 37 | if re.match('(\w+\.){3}\w+', test_id): |
| 38 | if not test_id.startswith('tempest.'): |
Matthew Treinish | a0f820f | 2014-09-16 11:25:34 -0400 | [diff] [blame] | 39 | parts = test_id.partition('tempest') |
| 40 | fail_id = parts[1] + parts[2] |
Matthew Treinish | 519cb3e | 2013-10-28 20:27:38 +0000 | [diff] [blame] | 41 | import_failures.append(fail_id) |
| 42 | error_message = ("The following tests have import failures and aren't" |
| 43 | " being run with test filters %s" % import_failures) |
| 44 | self.assertFalse(import_failures, error_message) |