<commit_before>#! /usr/bin/env python
# -*- coding: utf-8 -*-

usage="""
This script prepares the test environment and runs a test script:
 - clean and create test directory
 - create a SALOME application
 - launch salome
 - launch the test script within SALOME environment
 - kill salome

 This script uses the following environment variables:
   - ROOT_SALOME : directory which contains salome_context.cfg.
                  This variable is usually defined in salome_prerequisites.sh
   - KERNEL_ROOT_DIR and YACS_ROOT_DIR : directories of modules installation
                  Those variables are usually defined in salome_modules.sh
 Environment variables can be passed to the script using the -d option.
"""

import os
import sys

class TestEnvironment:
  def setUp(self):
    import shutil
    shutil.rmtree("appli", ignore_errors=True)
    
    # create config_appli.xml in current directory
    salome_path = os.getenv("ROOT_SALOME", "")
    salome_context_file = os.path.join(salome_path, "salome_context.cfg")
    if not os.path.isfile(salome_context_file):
      print "File salome_context.cfg not found."
      print "Search path:" + salome_path
      print "This test needs ROOT_SALOME environment variable in order to run"
      exit(1)
    
    config_appli_text = '''<application>
<context path="''' + salome_context_file + '''"/>
<modules>
   <module name="KERNEL" path="'''
    kernel_path = os.getenv("KERNEL_ROOT_DIR", "")
    if not os.path.isdir(kernel_path) :
      print "KERNEL_ROOT_DIR not defined"
      exit(1)
      pass
    
    config_appli_text += kernel_path + '"/>'
        
    # some tests need YACS module.
    yacs_path = os.getenv("YACS_ROOT_DIR", "")
    if os.path.isdir(yacs_path):
      config_appli_text += '''
   <module name="YACS" path="'''
      config_appli_text += yacs_path + '"/>'
      pass
    config_appli_text += '''
</modules>
</application>'''

    f = open("config_appli.xml", 'w')
    f.write(config_appli_text)
    f.close()
    
    # create a SALOME application
    appli_gen_file = os.path.join(kernel_path,<commit_msg>KERNEL tests will no longer fail if ROOT_SALOME is not defined.<commit_after>#! /usr/bin/env python
# -*- coding: utf-8 -*-

usage="""
This script prepares the test environment and runs a test script:
 - clean and create test directory
 - create a SALOME application
 - launch salome
 - launch the test script within SALOME environment
 - kill salome

 This script uses the following environment variables:
   - ROOT_SALOME : directory which contains salome_context.cfg.
                  This variable is usually defined in salome_prerequisites.sh
   - KERNEL_ROOT_DIR and YACS_ROOT_DIR : directories of modules installation
                  Those variables are usually defined in salome_modules.sh
 Environment variables can be passed to the script using the -d option.
"""

import os
import sys

class TestEnvironment:
  def setUp(self):
    import shutil
    shutil.rmtree("appli", ignore_errors=True)
    
    # create config_appli.xml in current directory
    salome_path = os.getenv("ROOT_SALOME", "")
    salome_context_file = os.path.join(salome_path, "salome_context.cfg")
    if not os.path.isfile(salome_context_file):
      print "File salome_context.cfg not found."
      print "Search path:" + salome_path
      print "This test needs ROOT_SALOME environment variable in order to run"
      exit(0)
    
    config_appli_text = '''<application>
<context path="''' + salome_context_file + '''"/>
<modules>
   <module name="KERNEL" path="'''
    kernel_path = os.getenv("KERNEL_ROOT_DIR", "")
    if not os.path.isdir(kernel_path) :
      print "KERNEL_ROOT_DIR not defined"
      exit(0)
      pass
    
    config_appli_text += kernel_path + '"/>'
        
    # some tests need YACS module.
    yacs_path = os.getenv("YACS_ROOT_DIR", "")
    if os.path.isdir(yacs_path):
      config_appli_text += '''
   <module name="YACS" path="'''
      config_appli_text += yacs_path + '"/>'
      pass
    config_appli_text += '''
</modules>
</application>'''

    f = open("config_appli.xml", 'w')
    f.write(config_appli_text)
    f.close()
    
    # create a SALOME application
    appli_gen_file = os.path.join(kernel_path,
{'fraction_non_alphanumeric': 0.10402843601895735, 'fraction_numerical': 0.0014218009478672985, 'mean_word_length': 3.212574850299401, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '2859981', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1299, 'n_words': 369}