Commit.
This commit is contained in:
parent
5bcf10589f
commit
e38135cc75
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "Jenkins",
|
||||
"type": "jenkins",
|
||||
"url": "http://example.org",
|
||||
"buildOrder": 13,
|
||||
"buildName": "allure-report_deploy#13",
|
||||
"buildUrl": "http://example.org/build#13",
|
||||
"reportUrl": "http://example.org/build#13/AllureReport",
|
||||
"reportName": "Demo allure report"
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
from os import system as exec_system_command
|
||||
from os.path import exists as is_file_exists
|
||||
from os import environ
|
||||
from os.path import dirname
|
||||
from sys import argv as term_args
|
||||
from sys import executable
|
||||
import platform
|
||||
import json
|
||||
|
||||
# Must run as the main program.
|
||||
if __name__ != '__main__':
|
||||
raise SystemExit('The current file can only be run as the main program, and it is forbidden to be imported.')
|
||||
|
||||
|
||||
# Main command line.
|
||||
first_command_status = exec_system_command("""
|
||||
pytest --alluredir ./allure-results --clean-alluredir %s
|
||||
""" % "\x20".join(term_args[1:]))
|
||||
|
||||
|
||||
allure_results = '%s/allure-results' % dirname(__file__)
|
||||
|
||||
if is_file_exists(allure_results):
|
||||
allure_results_categories = '%s/categories.json' % allure_results
|
||||
open(allure_results_categories, mode='w', encoding='utf-8').write(json.dumps([
|
||||
{
|
||||
"name": "通过",
|
||||
"matchedStatuses": [
|
||||
"passed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "失败",
|
||||
"matchedStatuses": [
|
||||
"failed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "测试发生错误",
|
||||
"matchedStatuses": [
|
||||
"broken"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "加载超时异常",
|
||||
"matchedStatuses": [
|
||||
"broken"
|
||||
],
|
||||
"messageRegex": ".*TimeoutException.*"
|
||||
}
|
||||
], indent=4, ensure_ascii=False))
|
||||
if is_file_exists(allure_results):
|
||||
allure_results_environment_properties = '%s/environment.properties' % allure_results
|
||||
open(allure_results_environment_properties, mode='w').write("OS = %s\nPython = %s\nExecute = %s" % (
|
||||
('%s (%s %s) %s' % (platform.node(), platform.system(), platform.release(), platform.machine().lower())),
|
||||
('%s' % (platform.python_version())),
|
||||
executable.replace("\\", '/')
|
||||
))
|
||||
if is_file_exists(allure_results):
|
||||
executor_file = '%s/executor.json' % allure_results
|
||||
if True:
|
||||
c = 0
|
||||
if 'PYCHARM_HOSTED' in environ.keys():
|
||||
c = 1
|
||||
if 'CI' in environ.keys() or 'JENKINS_HOME' in environ.keys():
|
||||
c = 2
|
||||
match c:
|
||||
case 0:
|
||||
open(executor_file, mode='w').write(json.dumps(
|
||||
{
|
||||
'name': 'Python',
|
||||
'type': 'python',
|
||||
'buildName': ' '
|
||||
},
|
||||
indent=4, ensure_ascii=False
|
||||
))
|
||||
case 1:
|
||||
open(executor_file, mode='w').write(json.dumps(
|
||||
{
|
||||
'name': 'PyCharm',
|
||||
'type': 'pycharm',
|
||||
'buildName': ' '
|
||||
},
|
||||
indent=4, ensure_ascii=False
|
||||
))
|
||||
|
||||
# Return to the main command line status code.
|
||||
exit(first_command_status)
|
60
runtest.py
60
runtest.py
|
@ -1,60 +0,0 @@
|
|||
from os import system as exec_system_command
|
||||
from os.path import exists as is_file_exists
|
||||
from os.path import dirname
|
||||
from sys import argv as term_args
|
||||
from sys import executable
|
||||
import platform
|
||||
|
||||
|
||||
if __name__ != '__main__':
|
||||
raise SystemExit('The current file can only be run as the main program, and it is forbidden to be imported.')
|
||||
|
||||
first_command_status = exec_system_command("""
|
||||
pytest --alluredir ./allure-results --clean-alluredir %s
|
||||
""" % "\x20".join(term_args[1:]))
|
||||
|
||||
allure_results = '%s/allure-results' % dirname(__file__)
|
||||
allure_results_categories = '%s/categories.json' % allure_results
|
||||
allure_results_categories_content = """
|
||||
[
|
||||
{
|
||||
"name": "通过",
|
||||
"matchedStatuses": [
|
||||
"passed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "失败",
|
||||
"matchedStatuses": [
|
||||
"failed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "测试发生错误",
|
||||
"matchedStatuses": [
|
||||
"broken"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "加载超时异常",
|
||||
"matchedStatuses": [
|
||||
"broken"
|
||||
],
|
||||
"messageRegex": ".*TimeoutException.*"
|
||||
}
|
||||
]
|
||||
"""
|
||||
allure_results_environment_properties = '%s/environment.properties' % allure_results
|
||||
allure_results_environment_properties_content = """
|
||||
OS = %s
|
||||
Python = %s
|
||||
Execute = %s
|
||||
""" % (
|
||||
('%s (%s %s) %s' % (platform.node(), platform.system(), platform.release(), platform.machine().lower())),
|
||||
('%s' % (platform.python_version())),
|
||||
executable.replace("\\", '/')
|
||||
)
|
||||
is_file_exists(allure_results) and open(allure_results_categories, mode='w', encoding='utf-8').write(allure_results_categories_content)
|
||||
is_file_exists(allure_results) and open(allure_results_environment_properties, mode='w', encoding='utf-8').write(allure_results_environment_properties_content)
|
||||
|
||||
exit(first_command_status)
|
Loading…
Reference in New Issue