<commit_before>"""Main entrypoint for clowder test runner"""

from __future__ import print_function

import argparse
import os
import sys
import argcomplete

from clowder_test.execute import execute_command


# Disable errors shown by pylint for too many public methods
# pylint: disable=R0904
# Disable errors shown by pylint for no specified exception types
# pylint: disable=W0702


def main():
    """Main entrypoint for clowder test runner"""
    Command()


if __name__ == '__main__':
    raise SystemExit(main())


class Command(object):
    """Command class for parsing commandline options"""

    def __init__(self):
        # clowder argparse setup
        command_description = 'Clowder test runner'
        parser = argparse.ArgumentParser(description=command_description,
                                         formatter_class=argparse.RawDescriptionHelpFormatter)
        parser.add_argument('--write', '-w', action='store_true',
                            help='run tests requiring test repo write access')
        self._subparsers = parser.add_subparsers(dest='test_command', metavar='SUBCOMMAND')
        self._configure_all_subparser()
        self._configure_cats_subparser()
        self._configure_cocos2d_subparser()
        self._configure_llvm_subparser()
        self._configure_offline_subparser()
        self._configure_parallel_subparser()
        self._configure_swift_subparser()
        self._configure_unittest_subparser()
        # Argcomplete and arguments parsing
        argcomplete.autocomplete(parser)
        self.args = parser.parse_args()
        if self.args.test_command is None or not hasattr(self, self.args.test_command):
            exit_unrecognized_command(parser)
        # use dispatch pattern to invoke method with same name
        scripts_dir = os.path.join(os.getcwd(), 'test', 'scripts')
        getattr(self, self.args.test_command)(scripts_dir)
        print()

    def all(self, path):
        """clowder branch command"""
        self.cats(path)
        self.cocos2d(path)
        self.llvm(path)
        self.offline(path)
        self.parallel(path)
        self.swift(path)
        self.unittests(path)

    def cats(self, path):
        """clowder cats tests entrypoint"""
        cats_command = 'cats_' + self.args.cats_command
        path = os.path.join(path, 'cats')
        getattr(self, cats_command)(path)

    def cats_all(self, path):
        """clowder cats tests"""
        test_env = {}
        if self.args.write:
            test_env["ACCESS_LEVEL"] = 'write'
        else:
            test_env["ACCESS_LEVEL"] = 'read'
        return_code = execute_command('./test_example_cats.sh', path, shell=True, env=test_env)
        sys.exit(return_code)

    @classmethod
    def cats_branch(cls, path):
        """clowder cats branch tests"""
        return_code = execute_command('./branch.sh', path, shell=True)
        sys.exit(return_code)

    @classmethod
    def cats_clean(cls, path):
        """clowder cats clean tests"""
        return_code = execute_command('./clean.sh', path, shell=True)
        sys.exit(return_code)

    @classmethod<commit_msg>Fix cats all test command<commit_after>"""Main entrypoint for clowder test runner"""

from __future__ import print_function

import argparse
import os
import sys
import argcomplete

from clowder_test.execute import execute_command


# Disable errors shown by pylint for too many public methods
# pylint: disable=R0904
# Disable errors shown by pylint for no specified exception types
# pylint: disable=W0702


def main():
    """Main entrypoint for clowder test runner"""
    Command()


if __name__ == '__main__':
    raise SystemExit(main())


class Command(object):
    """Command class for parsing commandline options"""

    def __init__(self):
        # clowder argparse setup
        command_description = 'Clowder test runner'
        parser = argparse.ArgumentParser(description=command_description,
                                         formatter_class=argparse.RawDescriptionHelpFormatter)
        parser.add_argument('--write', '-w', action='store_true',
                            help='run tests requiring test repo write access')
        self._subparsers = parser.add_subparsers(dest='test_command', metavar='SUBCOMMAND')
        self._configure_all_subparser()
        self._configure_cats_subparser()
        self._configure_cocos2d_subparser()
        self._configure_llvm_subparser()
        self._configure_offline_subparser()
        self._configure_parallel_subparser()
        self._configure_swift_subparser()
        self._configure_unittest_subparser()
        # Argcomplete and arguments parsing
        argcomplete.autocomplete(parser)
        self.args = parser.parse_args()
        if self.args.test_command is None or not hasattr(self, self.args.test_command):
            exit_unrecognized_command(parser)
        # use dispatch pattern to invoke method with same name
        scripts_dir = os.path.join(os.getcwd(), 'test', 'scripts')
        getattr(self, self.args.test_command)(scripts_dir)
        print()

    def all(self, path):
        """clowder branch command"""
        self.cats(path)
        self.cocos2d(path)
        self.llvm(path)
        self.offline(path)
        self.parallel(path)
        self.swift(path)
        self.unittests(path)

    def cats(self, path):
        """clowder cats tests entrypoint"""
        cats_command = 'cats_' + self.args.cats_command
        if self.args.cats_command != 'all':
            path = os.path.join(path, 'cats')
        getattr(self, cats_command)(path)

    def cats_all(self, path):
        """clowder cats tests"""
        test_env = {}
        if self.args.write:
            test_env["ACCESS_LEVEL"] = 'write'
        else:
            test_env["ACCESS_LEVEL"] = 'read'
        return_code = execute_command('./test_example_cats.sh', path, shell=True, env=test_env)
        sys.exit(return_code)

    @classmethod
    def cats_branch(cls, path):
        """clowder cats branch tests"""
        return_code = execute_command('./branch.sh', path, shell=True)
        sys.exit(return_code)

    @classmethod
    def cats_clean(cls, path):
        """clowder cats clean tests"""
        return_code = execute_command('./clean.sh', path, shell=True)
        sys.exit(return_code)

    @classmethod
{'fraction_non_alphanumeric': 0.10154769425142135, 'fraction_numerical': 0.003158559696778269, 'mean_word_length': 2.8127633955448523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '949681', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1784, 'n_words': 422}