diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 6370119c6f..58b789d697 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -3500,7 +3500,6 @@ tools/ci/python_packages/tiny_test_fw/TinyFW.py tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py tools/ci/python_packages/tiny_test_fw/Utility/GitlabCIJob.py -tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py tools/ci/python_packages/tiny_test_fw/Utility/TestCase.py tools/ci/python_packages/tiny_test_fw/Utility/__init__.py tools/ci/python_packages/tiny_test_fw/bin/Runner.py diff --git a/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py b/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py index f61de3a7ec..8674bf57b8 100644 --- a/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py +++ b/tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py @@ -1,30 +1,27 @@ -# Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http:#www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 """ search test cases from a given file or path """ import copy import fnmatch import os +import sys import types +from typing import List from . import load_source -class Search(object): +class Search: + """ + This class is used as a class singleton. all the member functions are `classmethod` + """ TEST_CASE_FILE_PATTERN = '*_test.py' SUPPORT_REPLICATE_CASES_KEY = ['target'] + # this attribute would be modified while running + missing_import_warnings: List[str] = [] + @classmethod def _search_cases_from_file(cls, file_name): """ get test cases from test case .py file """ @@ -42,7 +39,8 @@ class Search(object): except AttributeError: continue except ImportError as e: - print('ImportError: \r\n\tFile:' + file_name + '\r\n\tError:' + str(e)) + warning_str = 'ImortError: \r\n\tFile:' + file_name + '\r\n\tError:' + str(e) + cls.missing_import_warnings.append(warning_str) test_functions_out = [] for case in test_functions: @@ -132,8 +130,14 @@ class Search(object): test_case_paths = [test_case_paths] test_case_files = [] for path in test_case_paths: - test_case_files.extend(cls._search_test_case_files(path, test_case_file_pattern or cls.TEST_CASE_FILE_PATTERN)) + test_case_files.extend( + cls._search_test_case_files(path, test_case_file_pattern or cls.TEST_CASE_FILE_PATTERN)) test_cases = [] for test_case_file in test_case_files: test_cases += cls._search_cases_from_file(test_case_file) + + if cls.missing_import_warnings: + print('\n\n'.join(cls.missing_import_warnings)) + sys.exit(1) + return test_cases