관리-도구
편집 파일: junit.cpython-39.pyc
a �)g�5 � @ s� d dl mZmZmZ eZdZd dlZd dlZd dl Z d dl mZ d dl mZmZ d dlmZ d dlmZmZmZmZmZ G dd � d e�ZG d d� d�ZG dd � d �ZdS )� )�absolute_import�division�print_functiona name: junit type: aggregate short_description: write playbook output to a JUnit file. version_added: historical description: - This callback writes playbook output to a JUnit formatted XML file. - "Tasks show up in the report as follows: 'ok': pass 'failed' with 'EXPECTED FAILURE' in the task name: pass 'failed' with 'TOGGLE RESULT' in the task name: pass 'ok' with 'TOGGLE RESULT' in the task name: failure 'failed' due to an exception: error 'failed' for other reasons: failure 'skipped': skipped" options: output_dir: name: JUnit output dir default: ~/.ansible.log description: Directory to write XML files to. env: - name: JUNIT_OUTPUT_DIR task_class: name: JUnit Task class default: False description: Configure the output to be one class per yaml file env: - name: JUNIT_TASK_CLASS task_relative_path: name: JUnit Task relative path default: none description: Configure the output to use relative paths to given directory version_added: "2.8" env: - name: JUNIT_TASK_RELATIVE_PATH replace_out_of_tree_path: name: Replace out of tree path default: none description: Replace the directory portion of an out-of-tree relative task path with the given placeholder version_added: "2.12.3" env: - name: JUNIT_REPLACE_OUT_OF_TREE_PATH fail_on_change: name: JUnit fail on change default: False description: Consider any tasks reporting "changed" as a junit test failure env: - name: JUNIT_FAIL_ON_CHANGE fail_on_ignore: name: JUnit fail on ignore default: False description: Consider failed tasks as a junit test failure even if ignore_on_error is set env: - name: JUNIT_FAIL_ON_IGNORE include_setup_tasks_in_report: name: JUnit include setup tasks in report default: True description: Should the setup tasks be included in the final report env: - name: JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT hide_task_arguments: name: Hide the arguments for a task default: False description: Hide the arguments for a task version_added: "2.8" env: - name: JUNIT_HIDE_TASK_ARGUMENTS test_case_prefix: name: Prefix to find actual test cases default: <empty> description: Consider a task only as test case if it has this value as prefix. Additionally failing tasks are recorded as failed test cases. version_added: "2.8" env: - name: JUNIT_TEST_CASE_PREFIX requirements: - enable in configuration N)� constants)�to_bytes�to_text)�CallbackBase)�TestCase� TestError�TestFailure� TestSuite� TestSuitesc s� e Zd ZdZdZdZdZdZ� fdd�Zdd � Z d d� Z dd � Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd)dd �Zd!d"� Zd#d$� Zd%d&� Zd'd(� Z� ZS )*�CallbackModulea This callback writes playbook output to a JUnit formatted XML file. Tasks show up in the report as follows: 'ok': pass 'failed' with 'EXPECTED FAILURE' in the task name: pass 'failed' with 'TOGGLE RESULT' in the task name: pass 'ok' with 'TOGGLE RESULT' in the task name: failure 'failed' due to an exception: error 'failed' for other reasons: failure 'skipped': skipped This plugin makes use of the following environment variables: JUNIT_OUTPUT_DIR (optional): Directory to write XML files to. Default: ~/.ansible.log JUNIT_TASK_CLASS (optional): Configure the output to be one class per yaml file Default: False JUNIT_TASK_RELATIVE_PATH (optional): Configure the output to use relative paths to given directory Default: none JUNIT_FAIL_ON_CHANGE (optional): Consider any tasks reporting "changed" as a junit test failure Default: False JUNIT_FAIL_ON_IGNORE (optional): Consider failed tasks as a junit test failure even if ignore_on_error is set Default: False JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT (optional): Should the setup tasks be included in the final report Default: True JUNIT_HIDE_TASK_ARGUMENTS (optional): Hide the arguments for a task Default: False JUNIT_TEST_CASE_PREFIX (optional): Consider a task only as test case if it has this value as prefix. Additionally failing tasks are recorded as failed test cases. Default: <empty> g @Z aggregateZjunitTc s t t| ��� t�dtj�d��| _t�dd��� | _ t�dd�| _ t�dd��� | _t�dd��� | _t�d d ��� | _ t�dd��� | _t�dd�| _t�d d �| _d | _d | _d | _d | _d| _i | _| jd ur�t| j�| _tj�| j�s�t�| j� d S )NZJUNIT_OUTPUT_DIRz~/.ansible.logZJUNIT_TASK_CLASS�FalseZJUNIT_TASK_RELATIVE_PATH� ZJUNIT_FAIL_ON_CHANGEZJUNIT_FAIL_ON_IGNOREZ#JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT�TrueZJUNIT_HIDE_TASK_ARGUMENTSZJUNIT_TEST_CASE_PREFIXZJUNIT_REPLACE_OUT_OF_TREE_PATHF)�superr �__init__�os�getenv�path� expanduser�_output_dir�lower�_task_class�_task_relative_path�_fail_on_change�_fail_on_ignore�_include_setup_tasks_in_report�_hide_task_arguments�_test_case_prefix�_replace_out_of_tree_path�_playbook_path�_playbook_name� _play_name� _task_dataZdisabledr �exists�makedirs)�self�� __class__� �B/usr/lib/python3.9/site-packages/ansible/plugins/callback/junit.pyr � s( zCallbackModule.__init__c C s� |j }|| jv rdS | j}|�� �� }|�� }|j}|jsn| jdkrnd� dd� |j �� D ��}|rn|d| 7 }t|||||�| j|<