<commit_before>#! /usr/bin/env python3
"""Test mel from a user's perspective."""

import argparse
import os
import subprocess
import sys


class ExpectationError(Exception):

    def __init__(self, message, completed_process):
        super(ExpectationError, self).__init__(message)
        self.completed_process = completed_process


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.parse_args()

    # cd to the root of the repository, so all the paths are relative to that
    rootdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
    os.chdir(rootdir)

    try:
        run_tests()
    except ExpectationError as e:
        print()
        print(e)
        print("-- stdout:")
        print(e.completed_process.stdout)
        print("-- stderr:")
        print(e.completed_process.stderr)
        print("--")
        return 1

    print("OK")


def run_tests():

    mel_cmd = './bin/mel'

    expect_returncode(2, mel_cmd)
    expect_ok(mel_cmd, '-h')

    subcommands = [
        'add-cluster',
        'add-single',
        'list',
        'micro-add',
        'micro-view',
        'rotomap-edit',
        'rotomap-molepicker',
        'rotomap-relate',
        'rotomap-show',
        'rotomap-uuid',
    ]

    for s in subcommands:
        expect_ok(mel_cmd, s, '-h')


def expect_ok(*args):
    return expect_returncode(0, args)


def expect_returncode(expected_code, command):
    print('.', end='', flush=True)
    # print('Running "{}", expect return code {}'.format(
    #     command, expected_code))

    result = subprocess.run(<commit_msg>meta/system_tests.py: remove dead code<commit_after>#! /usr/bin/env python3
"""Test mel from a user's perspective."""

import argparse
import os
import subprocess
import sys


class ExpectationError(Exception):

    def __init__(self, message, completed_process):
        super(ExpectationError, self).__init__(message)
        self.completed_process = completed_process


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.parse_args()

    # cd to the root of the repository, so all the paths are relative to that
    rootdir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
    os.chdir(rootdir)

    try:
        run_tests()
    except ExpectationError as e:
        print()
        print(e)
        print("-- stdout:")
        print(e.completed_process.stdout)
        print("-- stderr:")
        print(e.completed_process.stderr)
        print("--")
        return 1

    print("OK")


def run_tests():

    mel_cmd = './bin/mel'

    expect_returncode(2, mel_cmd)
    expect_ok(mel_cmd, '-h')

    subcommands = [
        'add-cluster',
        'add-single',
        'list',
        'micro-add',
        'micro-view',
        'rotomap-edit',
        'rotomap-molepicker',
        'rotomap-relate',
        'rotomap-show',
        'rotomap-uuid',
    ]

    for s in subcommands:
        expect_ok(mel_cmd, s, '-h')


def expect_ok(*args):
    return expect_returncode(0, args)


def expect_returncode(expected_code, command):
    print('.', end='', flush=True)

    result = subprocess.run(
{'fraction_non_alphanumeric': 0.1295238095238095, 'fraction_numerical': 0.0025396825396825397, 'mean_word_length': 2.5929304446978336, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1835306', 'n_tokens_mistral': 1031, 'n_tokens_neox': 983, 'n_words': 223}