change: add logs

This commit is contained in:
debugtalk
2020-06-21 12:25:39 +08:00
parent d58d45a196
commit 3841406dd9
2 changed files with 22 additions and 9 deletions

View File

@@ -78,7 +78,6 @@ def load_testcase(testcase: Dict) -> TestCase:
testcase_obj = TestCase.parse_obj(testcase)
except ValidationError as ex:
err_msg = f"TestCase ValidationError:\nerror: {ex}\ncontent: {testcase}"
logger.error(err_msg)
raise exceptions.TestCaseFormatError(err_msg)
return testcase_obj
@@ -99,7 +98,6 @@ def load_testsuite(testsuite: Dict) -> TestSuite:
testsuite_obj = TestSuite.parse_obj(testsuite)
except ValidationError as ex:
err_msg = f"TestSuite ValidationError:\nfile: {path}\nerror: {ex}"
logger.error(err_msg)
raise exceptions.TestSuiteFormatError(err_msg)
return testsuite_obj

View File

@@ -478,6 +478,7 @@ def __make(tests_path: Text) -> NoReturn:
tests_path: should be in absolute path
"""
logger.info(f"make path: {tests_path}")
test_files = []
if os.path.isdir(tests_path):
files_list = load_folder_files(tests_path)
@@ -495,11 +496,14 @@ def __make(tests_path: Text) -> NoReturn:
try:
test_content = load_test_file(test_file)
except (exceptions.FileNotFound, exceptions.FileFormatError) as ex:
logger.warning(ex)
logger.warning(f"Invalid test file: {test_file}\n{type(ex).__name__}: {ex}")
continue
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
# api in v2 format, convert to v3 testcase
@@ -508,12 +512,14 @@ def __make(tests_path: Text) -> NoReturn:
if "config" not in test_content:
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
elif not isinstance(test_content["config"], Dict):
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
@@ -525,19 +531,28 @@ def __make(tests_path: Text) -> NoReturn:
try:
testcase_pytest_path = make_testcase(test_content)
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
# testsuite
elif "testcases" in test_content:
try:
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
# invalid format
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]: