<commit_before>---
- name: set facts for test suite
  set_fact:
      test_output_file: "tempest-results-{{ test_suite.key }}.xml"
      blacklistfile: ''
      whitelistfile: ''
      regex: ''

- name: remove old test list for "{{ test_suite.key }}"
  file:
      state: absent
      name: "{{ tester.dir }}/{{ item }}"
  with_items:
      - white_list
      - black_list
      - "{{ test_output_file }}"

- block:
    - name: create Test List - Whitelist for "{{ test_suite.key }}"
      lineinfile:
          create: yes
          dest: "{{ tester.dir }}/white_list"
          line: "{{ item }}"
          regexp: "^{{ item }}$"
      with_items: "{{ test_suite.value.whitelist | default([]) }}"

    - name: add whitelist invocation
      set_fact:
          whitelistfile: "--whitelist_file white_list"

  when: test_suite.value.whitelist is defined and test_suite.value.whitelist

- block:
    - name: create Test List - Blacklist for "{{ test_suite.key }}"
      lineinfile:
          create: yes
          dest: "{{ tester.dir }}/black_list"
          line: "{{ item }}"
          regexp: "^{{ item }}$"
      with_items: "{{ test_suite.value.blacklist | default([]) }}"

    - name: add blacklist invocation
      set_fact:
          blacklistfile: "--blacklist_file black_list"
  when: test_suite.value.blacklist is defined and test_suite.value.blacklist

- name: add regex invoke for "{{ test_suite.key }}"
  set_fact:
      regex: "--regex {{ test_suite.value.test_regex }}"
  when: test_suite.value.test_regex is defined and test_suite.value.test_regex

- block:
      - name: run tempest "{{ test_suite.key }}" suite
        shell: >
            [ -e .venv/bin/activate ] && source .venv/bin/activate;
            ostestr -s --no-pretty '{{ regex | default('') }}' {{ whitelistfile }} {{ blacklistfile }}
            | subunit2junitxml --output-to={{ test_output_file }} | subunit2pyunit
        args:
            executable: /bin/bash
            chdir: "{{ tester.dir }}"<commit_msg>Separate regex argument from the regexp<commit_after>---
- name: set facts for test suite
  set_fact:
      test_output_file: "tempest-results-{{ test_suite.key }}.xml"
      blacklistfile: ''
      whitelistfile: ''
      regex: ''

- name: remove old test list for "{{ test_suite.key }}"
  file:
      state: absent
      name: "{{ tester.dir }}/{{ item }}"
  with_items:
      - white_list
      - black_list
      - "{{ test_output_file }}"

- block:
    - name: create Test List - Whitelist for "{{ test_suite.key }}"
      lineinfile:
          create: yes
          dest: "{{ tester.dir }}/white_list"
          line: "{{ item }}"
          regexp: "^{{ item }}$"
      with_items: "{{ test_suite.value.whitelist | default([]) }}"

    - name: add whitelist invocation
      set_fact:
          whitelistfile: "--whitelist_file white_list"

  when: test_suite.value.whitelist is defined and test_suite.value.whitelist

- block:
    - name: create Test List - Blacklist for "{{ test_suite.key }}"
      lineinfile:
          create: yes
          dest: "{{ tester.dir }}/black_list"
          line: "{{ item }}"
          regexp: "^{{ item }}$"
      with_items: "{{ test_suite.value.blacklist | default([]) }}"

    - name: add blacklist invocation
      set_fact:
          blacklistfile: "--blacklist_file black_list"
  when: test_suite.value.blacklist is defined and test_suite.value.blacklist

- name: add regex invoke for "{{ test_suite.key }}"
  set_fact:
      regex: "{{ test_suite.value.test_regex }}"
  when: test_suite.value.test_regex is defined and test_suite.value.test_regex

- block:
      - name: run tempest "{{ test_suite.key }}" suite
        shell: >
            [ -e .venv/bin/activate ] && source .venv/bin/activate;
            ostestr -s --no-pretty --regex '{{ regex | default('') }}' {{ whitelistfile }} {{ blacklistfile }}
            | subunit2junitxml --output-to={{ test_output_file }} | subunit2pyunit
        args:
            executable: /bin/bash
            chdir: "{{ tester.dir }}"
{'fraction_non_alphanumeric': 0.14456035767511177, 'fraction_numerical': 0.0009935419771485345, 'mean_word_length': 2.322607260726073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5614084', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1286, 'n_words': 295}