<commit_before>#!/bin/sh
#!/bin/bash

typeset -i tests=0

function it {
    let tests+=1;
    description="$1";
}

function assert {
    if [[ "$1" == "$2" ]]; then
        printf "\033[32m.\033[0m";
    else
        printf "\033[31m\nFAIL: $description\033[0m: '$1' != '$2'\n";
        exit 1
    fi
}

it "Should accept a file"
    code=0
    ./cli.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept stdin"
    code=0
    cat History.md | ./cli.js > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should fail without input"
    code=0
    ./cli.js > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on an invalid file"
    code=0
    ./cli.js some-other-file.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on multiple files"
    code=0
    ./cli.js History.md Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on stdin and files"
    code=0
    cat History.md | ./cli.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should accept \`--ast\`"
    code=0
    ./cli.js --ast Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-a\`"
    code=0
    ./cli.js -a Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`--options\`"
    code=0
    ./cli.js --options > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`--help\`"
    code=0
    ./cli.js --help > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-h\`"
    code=0
    ./cli.js -h > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`--version\`"
    code=0
    ./cli.js --version > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-v\`"
    code=0
    ./cli.js -v > /dev/null 2>&1 || code=$?
    assert $code 0

printf "\033[32m\n(✓) Passed $tests assertions without errors\033[0m\n";<commit_msg>Add assertions for plugins to `test/cli.sh`<commit_after>#!/bin/sh
#!/bin/bash

typeset -i tests=0

function it {
    let tests+=1;
    description="$1";
}

function assert {
    if [[ "$1" == "$2" ]]; then
        printf "\033[32m.\033[0m";
    else
        printf "\033[31m\nFAIL: $description\033[0m: '$1' != '$2'\n";
        exit 1
    fi
}

it "Should accept a file"
    code=0
    ./cli.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept stdin"
    code=0
    cat History.md | ./cli.js > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should fail without input"
    code=0
    ./cli.js > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on an invalid file"
    code=0
    ./cli.js some-other-file.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on multiple files"
    code=0
    ./cli.js History.md Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on stdin and files"
    code=0
    cat History.md | ./cli.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should accept \`--ast\`"
    code=0
    ./cli.js --ast Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-a\`"
    code=0
    ./cli.js -a Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-u <plugin>\`"
    code=0
    ./cli.js -u ./test/plugin.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`--use <plugin>\`"
    code=0
    ./cli.js --use ./test/plugin.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should fail on \`-u <invalid-plugin>\`"
    code=0
    ./cli.js -u ./invalid-plugin.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on \`--use <invalid-plugin>\`"
    code=0
    ./cli.js --use ./invalid-plugin.js Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on missing value for \`-u\`"
    code=0
    ./cli.js -u Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should fail on missing value for \`--use\`"
    code=0
    ./cli.js --use Readme.md > /dev/null 2>&1 || code=$?
    assert $code 1

it "Should accept \`--options\`"
    code=0
    ./cli.js --options > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`--help\`"
    code=0
    ./cli.js --help > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-h\`"
    code=0
    ./cli.js -h > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`--version\`"
    code=0
    ./cli.js --version > /dev/null 2>&1 || code=$?
    assert $code 0

it "Should accept \`-v\`"
    code=0
    ./cli.js -v > /dev/null 2>&1 || code=$?
    assert $code 0

printf "\033[32m\n(✓) Passed $tests assertions without errors\033[0m\n";
{'fraction_non_alphanumeric': 0.19593425605536333, 'fraction_numerical': 0.042820069204152246, 'mean_word_length': 2.125, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 71, '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': '6455846', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1811, 'n_words': 542}