<commit_before>import argparse
import os
import sys

script_dir = os.path.realpath(os.path.dirname(__file__))

parser = argparse.ArgumentParser()
parser.add_argument('-r', '--renderdoc',
                    help="The location of the renderdoc library to use", type=str)
parser.add_argument('-p', '--pyrenderdoc',
                    help="The location of the renderdoc python module to use", type=str)
parser.add_argument('-l', '--list',
                    help="Lists the tests available to run", action="store_true")
parser.add_argument('-t', '--test_include', default=".*",
                    help="The tests to include, as a regexp filter", type=str)
parser.add_argument('-x', '--test_exclude', default="",
                    help="The tests to exclude, as a regexp filter", type=str)
parser.add_argument('--in-process',
                    help="Lists the tests available to run", action="store_true")
parser.add_argument('--slow-tests',
                    help="Run potentially slow tests", action="store_true")
parser.add_argument('--data', default=os.path.join(script_dir, "data"),
                    help="The folder that reference data is in. Will not be modified.", type=str)
parser.add_argument('--demos-binary', default="",
                    help="The path to the built demos binary.", type=str)
parser.add_argument('--demos-timeout', default=None,
                    help="The timeout to use when expecting the demos to run.", type=int)
parser.add_argument('--data-extra', default=os.path.join(script_dir, "data_extra"),
                    help="The folder that extra reference data is in (typically very large captures that aren't part "
                         "of the normal repo). Will not be modified.", type=str)
parser.add_argument('--artifacts', default=os.path.join(script_dir, "artifacts"),
                    help="The folder to put output artifacts in. Will be completely cleared.", type=str)
parser.add_argument('--temp', default=os.path.join(script_dir, "tmp"),
                    help="The folder to put temporary run data in. Will be completely cleared.", type=str)
parser.add_argument('--debugger',
                    help="Enable debugger mode, exceptions are not caught by the framework.", action="store_true")
# Internal command, when we fork out to run a test in a separate process
parser.add_argument('--internal_run_test', help=argparse.SUPPRESS, type=str, required=False)
# Internal command, when we re-run as admin to register vulkan layer
parser.add_argument('--internal_vulkan_register', help=argparse.SUPPRESS, action="store_true", required=False)
# Internal command, when we re-run as a remote server
parser.add_argument('--internal_remote_server', help=argparse.SUPPRESS, action="store_true", required=False)
args = parser.parse_args()

if args.renderdoc is not None:
    if os.path.isfile(args.renderdoc):
        renderdoc_dirpath = os.path.abspath(os.path.dirname(args.renderdoc))
    elif os.path.isdir(args.renderdoc):
        renderdoc_dirpath = os.path.abspath(args.renderdoc)
    else:
        raise RuntimeError("'{}' is not a valid path to the renderdoc library".format(args.renderdoc))
    os.environ["PATH"] += os.pathsep + renderdoc_dirpath
    # Python 3.8 doesn't search PATH so add it to the DLL search path
    if sys.platform == 'win32' and sys.version_info[1] >= 8:
        os.add_dll_directory(renderdoc_dirpath)

custom_pyrenderdoc = None

if args.pyrenderdoc is not None:
    if os.path.isfile(args.pyrenderdoc):
        custom_pyrenderdoc = os.path.abspath(os.path.dirname(args.pyrenderdoc))
    elif os.path.isdir(args.pyrenderdoc):
        custom_pyrenderdoc = os.path.abspath(args.pyrenderdoc)
    else:
        raise RuntimeError("'{}' is not a valid path to the pyrenderdoc module".format(args.pyrenderdoc))

    sys.path.insert(0, custom_pyrenderdoc)

sys.path.insert(0, os.path.realpath(os.path.dirname(__file__)))

data_path = os.path.realpath(args.data)
data_extra_path = os.path.realpath(args.data_extra)
temp_path = os.path.realpath(args.temp)
demos_binary = args.demos_binary
if demos_binary != "":
    demos_binary = os.path.realpath(demos_binary)
demos_timeout = args.demos_timeout<commit_msg>When running tests if --pyrenderdoc is omitted, try default location<commit_after>import argparse
import os
import sys

script_dir = os.path.realpath(os.path.dirname(__file__))

parser = argparse.ArgumentParser()
parser.add_argument('-r', '--renderdoc',
                    help="The location of the renderdoc library to use", type=str)
parser.add_argument('-p', '--pyrenderdoc',
                    help="The location of the renderdoc python module to use", type=str)
parser.add_argument('-l', '--list',
                    help="Lists the tests available to run", action="store_true")
parser.add_argument('-t', '--test_include', default=".*",
                    help="The tests to include, as a regexp filter", type=str)
parser.add_argument('-x', '--test_exclude', default="",
                    help="The tests to exclude, as a regexp filter", type=str)
parser.add_argument('--in-process',
                    help="Lists the tests available to run", action="store_true")
parser.add_argument('--slow-tests',
                    help="Run potentially slow tests", action="store_true")
parser.add_argument('--data', default=os.path.join(script_dir, "data"),
                    help="The folder that reference data is in. Will not be modified.", type=str)
parser.add_argument('--demos-binary', default="",
                    help="The path to the built demos binary.", type=str)
parser.add_argument('--demos-timeout', default=None,
                    help="The timeout to use when expecting the demos to run.", type=int)
parser.add_argument('--data-extra', default=os.path.join(script_dir, "data_extra"),
                    help="The folder that extra reference data is in (typically very large captures that aren't part "
                         "of the normal repo). Will not be modified.", type=str)
parser.add_argument('--artifacts', default=os.path.join(script_dir, "artifacts"),
                    help="The folder to put output artifacts in. Will be completely cleared.", type=str)
parser.add_argument('--temp', default=os.path.join(script_dir, "tmp"),
                    help="The folder to put temporary run data in. Will be completely cleared.", type=str)
parser.add_argument('--debugger',
                    help="Enable debugger mode, exceptions are not caught by the framework.", action="store_true")
# Internal command, when we fork out to run a test in a separate process
parser.add_argument('--internal_run_test', help=argparse.SUPPRESS, type=str, required=False)
# Internal command, when we re-run as admin to register vulkan layer
parser.add_argument('--internal_vulkan_register', help=argparse.SUPPRESS, action="store_true", required=False)
# Internal command, when we re-run as a remote server
parser.add_argument('--internal_remote_server', help=argparse.SUPPRESS, action="store_true", required=False)
args = parser.parse_args()

custom_pyrenderdoc = None

if args.pyrenderdoc is not None:
    if os.path.isfile(args.pyrenderdoc):
        custom_pyrenderdoc = os.path.abspath(os.path.dirname(args.pyrenderdoc))
    elif os.path.isdir(args.pyrenderdoc):
        custom_pyrenderdoc = os.path.abspath(args.pyrenderdoc)
    else:
        raise RuntimeError("'{}' is not a valid path to the pyrenderdoc module".format(args.pyrenderdoc))

if args.renderdoc is not None:
    if os.path.isfile(args.renderdoc):
        renderdoc_dirpath = os.path.abspath(os.path.dirname(args.renderdoc))
    elif os.path.isdir(args.renderdoc):
        renderdoc_dirpath = os.path.abspath(args.renderdoc)
    else:
        raise RuntimeError("'{}' is not a valid path to the renderdoc library".format(args.renderdoc))
    os.environ["PATH"] += os.pathsep + renderdoc_dirpath
    # Python 3.8 doesn't search PATH so add it to the DLL search path
    if sys.platform == 'win32' and sys.version_info[1] >= 8:
        os.add_dll_directory(renderdoc_dirpath)

    # if the user didn't specify a pyrenderdoc but we do have a renderdoc, try the default location as a backup
    if custom_pyrenderdoc is None:
        if sys.platform == 'win32':
            custom_pyrenderdoc = os.path.abspath(args.renderdoc) + os.path.sep + "pymodules"
        else:
            custom_pyrenderdoc = os.path.abspath(args.renderdoc)

if custom_pyrenderdoc is not None:
    # explicit paths go at the start, implicit paths go at the end
    if args.pyrenderdoc is not None:
        sys.path.insert(0, custom_pyrenderdoc)
    else:
        sys.path.append(custom_pyrenderdoc)

sys.path.insert(0, os.path.realpath(os.path.dirname(__file__)))

data_path = os.path.realpath(args.data)
data_extra_path = os.path.realpath(args.data_extra)
temp_path = os.path.realpath(args.temp)
demos_binary = args.demos_binary
if demos_binary != "":
    demos_binary = os.path.realpath(demos_binary)
demos_timeout = args.demos_timeout
{'fraction_non_alphanumeric': 0.12113115119127144, 'fraction_numerical': 0.002004008016032064, 'mean_word_length': 3.4915, 'pattern_counts': {'":': 2, '<': 3, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5157948', 'n_tokens_mistral': 2700, 'n_tokens_neox': 2642, 'n_words': 724}