blob: 4af74630d5771f46d663ac6c9e2a0768d9027ea6 [file] [log] [blame]
Matthew Treinish519cb3e2013-10-28 20:27:38 +00001# 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 Treinisha0f820f2014-09-16 11:25:34 -040015import os
Matthew Treinish519cb3e2013-10-28 20:27:38 +000016import re
17import subprocess
18
Masayuki Igawa134d9f72017-02-10 18:05:26 +090019import six
20
Matthew Treinishffad78a2016-04-16 14:39:52 -040021from tempest.tests import base
Matthew Treinish519cb3e2013-10-28 20:27:38 +000022
23
24class TestTestList(base.TestCase):
25
Masayuki Igawad0b8ebd2017-09-14 14:51:25 -060026 def test_stestr_list_no_errors(self):
Matthew Treinisha0f820f2014-09-16 11:25:34 -040027 test_env = os.environ.copy()
Matthew Treinish519cb3e2013-10-28 20:27:38 +000028 import_failures = []
Masayuki Igawad0b8ebd2017-09-14 14:51:25 -060029 p = subprocess.Popen(['stestr', 'list'], stdout=subprocess.PIPE,
Matthew Treinisha0f820f2014-09-16 11:25:34 -040030 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 Dague6a9764d2015-01-06 17:12:16 -050034 "error on import %s" % ids)
Matthew Treinish09487242015-05-10 12:43:58 -040035 ids = six.text_type(ids).split('\n')
Matthew Treinish519cb3e2013-10-28 20:27:38 +000036 for test_id in ids:
37 if re.match('(\w+\.){3}\w+', test_id):
38 if not test_id.startswith('tempest.'):
Matthew Treinisha0f820f2014-09-16 11:25:34 -040039 parts = test_id.partition('tempest')
40 fail_id = parts[1] + parts[2]
Matthew Treinish519cb3e2013-10-28 20:27:38 +000041 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)