change: add logs

This commit is contained in:
debugtalk
2020-06-21 12:29:21 +08:00
parent d58d45a196
commit 3841406dd9
2 changed files with 22 additions and 9 deletions
-2
View File
@@ -78,7 +78,6 @@ def load_testcase(testcase: Dict) -> TestCase:
testcase_obj = TestCase.parse_obj(testcase) testcase_obj = TestCase.parse_obj(testcase)
except ValidationError as ex: except ValidationError as ex:
err_msg = f"TestCase ValidationError:\nerror: {ex}\ncontent: {testcase}" err_msg = f"TestCase ValidationError:\nerror: {ex}\ncontent: {testcase}"
logger.error(err_msg)
raise exceptions.TestCaseFormatError(err_msg) raise exceptions.TestCaseFormatError(err_msg)
return testcase_obj return testcase_obj
@@ -99,7 +98,6 @@ def load_testsuite(testsuite: Dict) -> TestSuite:
testsuite_obj = TestSuite.parse_obj(testsuite) testsuite_obj = TestSuite.parse_obj(testsuite)
except ValidationError as ex: except ValidationError as ex:
err_msg = f"TestSuite ValidationError:\nfile: {path}\nerror: {ex}" err_msg = f"TestSuite ValidationError:\nfile: {path}\nerror: {ex}"
logger.error(err_msg)
raise exceptions.TestSuiteFormatError(err_msg) raise exceptions.TestSuiteFormatError(err_msg)
return testsuite_obj return testsuite_obj
+22 -7
View File
@@ -478,6 +478,7 @@ def __make(tests_path: Text) -> NoReturn:
tests_path: should be in absolute path tests_path: should be in absolute path
""" """
logger.info(f"make path: {tests_path}")
test_files = [] test_files = []
if os.path.isdir(tests_path): if os.path.isdir(tests_path):
files_list = load_folder_files(tests_path) files_list = load_folder_files(tests_path)
@@ -495,11 +496,14 @@ def __make(tests_path: Text) -> NoReturn:
try: try:
test_content = load_test_file(test_file) test_content = load_test_file(test_file)
except (exceptions.FileNotFound, exceptions.FileFormatError) as ex: except (exceptions.FileNotFound, exceptions.FileFormatError) as ex:
logger.warning(ex) logger.warning(f"Invalid test file: {test_file}\n{type(ex).__name__}: {ex}")
continue continue
if not isinstance(test_content, Dict): if not isinstance(test_content, Dict):
logger.warning(f"test content not in dict format. \npath: {test_file}") logger.warning(
f"Invalid test file: {test_file}\n"
f"reason: test content not in dict format."
)
continue continue
# api in v2 format, convert to v3 testcase # api in v2 format, convert to v3 testcase
@@ -508,12 +512,14 @@ def __make(tests_path: Text) -> NoReturn:
if "config" not in test_content: if "config" not in test_content:
logger.warning( logger.warning(
f"Invalid testcase/testsuite: missing config part in testcase/testsuite.\npath: {test_file}" f"Invalid testcase/testsuite file: {test_file}\n"
f"reason: missing config part."
) )
continue continue
elif not isinstance(test_content["config"], Dict): elif not isinstance(test_content["config"], Dict):
logger.warning( logger.warning(
f"Invalid testcase/testsuite: config should be dict type, got {test_content['config']}" f"Invalid testcase/testsuite file: {test_file}\n"
f"reason: config should be dict type, got {test_content['config']}"
) )
continue continue
@@ -525,19 +531,28 @@ def __make(tests_path: Text) -> NoReturn:
try: try:
testcase_pytest_path = make_testcase(test_content) testcase_pytest_path = make_testcase(test_content)
pytest_files_run_set.add(testcase_pytest_path) pytest_files_run_set.add(testcase_pytest_path)
except exceptions.TestCaseFormatError: except exceptions.TestCaseFormatError as ex:
logger.warning(
f"Invalid testcase file: {test_file}\n{type(ex).__name__}: {ex}"
)
continue continue
# testsuite # testsuite
elif "testcases" in test_content: elif "testcases" in test_content:
try: try:
make_testsuite(test_content) make_testsuite(test_content)
except exceptions.TestSuiteFormatError: except exceptions.TestSuiteFormatError as ex:
logger.warning(
f"Invalid testsuite file: {test_file}\n{type(ex).__name__}: {ex}"
)
continue continue
# invalid format # invalid format
else: else:
logger.warning(f"skip invalid testcase/testsuite file: {test_file}") logger.warning(
f"Invalid test file: {test_file}\n"
f"reason: file content is neither testcase nor testsuite"
)
def main_make(tests_paths: List[Text]) -> List[Text]: def main_make(tests_paths: List[Text]) -> List[Text]: