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

set -euo pipefail

if (( $# < 1 )); then
    echo "Usage: $0 <testcase_directory>..." >&2
    exit 1
fi

while (( $# > 0 )); do
    dir_testcase="${1}"
    shift

    file_cmd="${dir_testcase}/cmds.vim"
    file_in="${dir_testcase}/input.txt"
    file_out="${dir_testcase}/output.txt"
    file_exp="${dir_testcase}/expected.txt"

    rm "${file_out}" &>/dev/null || true

    cat >"${file_cmd}" <<EOF
:set foldmethod=marker
:%call SortFolds#SortFolds()
:write ${file_out}
:q!
EOF

    ${EDITOR} -s "${file_cmd}" "${file_in}"

    rm "${file_cmd}"

    if diff "${file_out}" "${file_exp}"; then
        exit 0
    else
        echo "TEST FAILED" >&2
        exit 1
    fi
done<commit_msg>test: Copy input to output and modify in-place<commit_after>#!/bin/bash
#!/usr/bin/env sh

set -euo pipefail

if (( $# < 1 )); then
    echo "Usage: $0 <testcase_directory>..." >&2
    exit 1
fi

while (( $# > 0 )); do
    dir_testcase="${1}"
    shift

    file_cmd="${dir_testcase}/cmds.vim"
    file_in="${dir_testcase}/input.txt"
    file_out="${dir_testcase}/output.txt"
    file_exp="${dir_testcase}/expected.txt"

    cp -v "${file_in}" "${file_out}"

    cat >"${file_cmd}" <<EOF
:set foldmethod=marker
:%call SortFolds#SortFolds()
:write
:q!
EOF

    ${EDITOR} -s "${file_cmd}" "${file_out}"

    rm "${file_cmd}"

    if diff "${file_out}" "${file_exp}"; then
        exit 0
    else
        echo "TEST FAILED" >&2
        exit 1
    fi
done
{'fraction_non_alphanumeric': 0.19339622641509435, 'fraction_numerical': 0.012129380053908356, 'mean_word_length': 2.9705882352941178, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, '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': '4347536', 'n_tokens_mistral': 590, 'n_tokens_neox': 559, 'n_words': 131}