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

load "${BATS_TEST_DIRNAME}/setup"


@test 'system required_utility does command lookup' {
    local script_name="system_script"
    local script_path="$BATS_TMPDIR/$script_name"
    local test_message="Can use git"
    TEST_FILE_HELP=""
    TEST_FILE_MODULES=("messages" "system")
    TEST_FILE_BODY="set -e; required_utility git; msg '$test_message'"
    _create_test_script_file "$script_name"
    run $script_path
    [ "$status" -eq 0 ]
    [[ "$output" = "$test_message" ]]

    TEST_FILE_MODULES=()
    _create_test_script_file "$script_name"
    run $script_path
    [ "$status" -eq 127 ]
    [[ "$output" = *"required_utility: command not found"* ]]

}

@test 'system required_utility terminates script if command not found' {
    local script_name="system_script"
    local script_path="$BATS_TMPDIR/$script_name"
    local test_message="Should not see this"
    TEST_FILE_HELP=""
    TEST_FILE_MODULES=("messages" "system")
    TEST_FILE_BODY="required_utility git; required_utility something_else; msg '$test_message'"
    _create_test_script_file "$script_name"
    run $script_path
    [ "$status" -eq 1 ]
    [[ "$output" = *"Was not able to find required 'something_else' utility in the PATH" ]]
    [[ "$output" != *"$test_message"* ]]
    [[ "$output" != *"git"* ]]<commit_msg>Modify system.bats tests as system module should include messages<commit_after>#!/usr/bin/env bats

load "${BATS_TEST_DIRNAME}/setup"


@test 'system required_utility does command lookup' {
    local script_name="system_script"
    local script_path="$BATS_TMPDIR/$script_name"
    local test_message="Can use git"
    TEST_FILE_HELP=""
    TEST_FILE_MODULES=("system") # system should include "messages"
    TEST_FILE_BODY="set -e; required_utility git; msg '$test_message'"
    _create_test_script_file "$script_name"
    run $script_path
    [ "$status" -eq 0 ]
    [[ "$output" = "$test_message" ]]

    TEST_FILE_MODULES=()
    _create_test_script_file "$script_name"
    run $script_path
    [ "$status" -eq 127 ]
    [[ "$output" = *"required_utility: command not found"* ]]

}

@test 'system required_utility terminates script if command not found' {
    local script_name="system_script"
    local script_path="$BATS_TMPDIR/$script_name"
    local test_message="Should not see this"
    TEST_FILE_HELP=""
    TEST_FILE_MODULES=("messages" "system")
    TEST_FILE_BODY="required_utility git; required_utility something_else; msg '$test_message'"
    _create_test_script_file "$script_name"
    run $script_path
    [ "$status" -eq 1 ]
    [[ "$output" = *"Was not able to find required 'something_else' utility in the PATH" ]]
    [[ "$output" != *"$test_message"* ]]
    [[ "$output" != *"git"* ]]
{'fraction_non_alphanumeric': 0.13304093567251463, 'fraction_numerical': 0.003654970760233918, 'mean_word_length': 4.409090909090909, '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': '3052418', 'n_tokens_mistral': 932, 'n_tokens_neox': 911, 'n_words': 209}