<commit_before>#!/usr/bin/env python3

# Copyright (c) 2014, <NAME>
# All rights reserved.

import os
import subprocess
import sys

def run():
  toolchain = os.getenv('TOOLCHAIN')
  if not toolchain:
    sys.exit('Environment variable TOOLCHAIN is empty')

  config = os.getenv('CONFIG')
  if not config:
    sys.exit('Environment variable CONFIG is empty')

  example = os.getenv('EXAMPLE')
  if not example:
    sys.exit('Environment variable EXAMPLE is empty')

  path = os.path.dirname(os.path.realpath(__file__))
  if not os.path.isabs(path):
    path = os.path.abspath(path)

  build = os.path.join(path, '..', 'bin', 'build.py')

  project_home = os.path.join(path, example)
  if not os.path.exists(project_home):
    sys.exit('Path `{}` not exists'.format(project_home))
  os.chdir(project_home)

  print('Run script: {}'.format(build))
  print('Toolchain: {}'.format(toolchain))
  print('Config: {}'.format(config))
  print('Example: {}'.format(example))

  args = [
      sys.executable,
      build,
      '--toolchain',
      toolchain,
      '--config',
      config,
      '--verbose',
      '--clear',
      '--install',
      '--test'
  ]

  try:
    subprocess.check_call(args)
  except subprocess.CalledProcessError as error:
    print(error)
    print(error.output)
    sys.exit(1)

if __name__ == '__main__':
  run()
<commit_msg>jenkins.py: fix windows path too long error on testing<commit_after>#!/usr/bin/env python3

# Copyright (c) 2014, <NAME>
# All rights reserved.

import os
import shutil
import subprocess
import sys
import tempfile

def run():
  toolchain = os.getenv('TOOLCHAIN')
  if not toolchain:
    sys.exit('Environment variable TOOLCHAIN is empty')

  config = os.getenv('CONFIG')
  if not config:
    sys.exit('Environment variable CONFIG is empty')

  example = os.getenv('EXAMPLE')
  if not example:
    sys.exit('Environment variable EXAMPLE is empty')

  path = os.path.dirname(os.path.realpath(__file__))
  if not os.path.isabs(path):
    path = os.path.abspath(path)

  build = os.path.join(path, '..', 'bin', 'build.py')

  project_home = os.path.join(path, example)
  if not os.path.exists(project_home):
    sys.exit('Path `{}` not exists'.format(project_home))
  os.chdir(project_home)

  build_dir = os.path.join(os.getcwd(), '_builds')
  if os.name == 'nt':
    hunter_junctions = os.getenv('HUNTER_JUNCTIONS')
    if hunter_junctions:
      build_dir = tempfile.mkdtemp(dir=hunter_junctions)

  print('Run script: {}'.format(build))
  print('Toolchain: {}'.format(toolchain))
  print('Config: {}'.format(config))
  print('Example: {}'.format(example))

  os.makedirs(build_dir, exist_ok=True)
  os.chdir(build_dir)

  args = [
      sys.executable,
      build,
      '--toolchain',
      toolchain,
      '--config',
      config,
      '--home',
      project_home,
      '--verbose',
      '--clear',
      '--install',
      '--test'
  ]

  try:
    subprocess.check_call(args)
    shutil.rmtree(build_dir, ignore_errors=True)
  except subprocess.CalledProcessError as error:
    print(error)
    print(error.output)
    sys.exit(1)

if __name__ == '__main__':
  run()

{'fraction_non_alphanumeric': 0.15355086372360843, 'fraction_numerical': 0.003838771593090211, 'mean_word_length': 3.3310249307479225, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5282313', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1081, 'n_words': 233}