<commit_before>#!/bin/bash

set -eo pipefail

if ! test -d ../bfs; then
    echo "Could not find ../bfs"
    echo "git clone https://github.com/tavianator/bfs.git"
    exit 1
fi

# build the rust implementation
cargo build --release
FIND=$(readlink -f target/release/find)

cd ..
make -C bfs -j "$(nproc)" tests/mksock WITH_ONIGURUMA=

# Run the GNU find compatibility tests by default
if test "$#" -eq 0; then
    set -- --verbose --gnu
fi

LOG_FILE=bfs/tests.log
./bfs/tests.sh --bfs="$FIND" "$@" | tee "$LOG_FILE" || :

PASS=$(sed -n "s/^tests passed: \(.*\)/\1/p" "$LOG_FILE" | head -n1)
SKIP=$(sed -n "s/^tests skipped: \(.*\)/\1/p" "$LOG_FILE" | head -n1)
FAIL=$(sed -n "s/^tests failed: \(.*\)/\1/p" "$LOG_FILE" | head -n1)
TOTAL=$((PASS + SKIP + FAIL))
if (( TOTAL <= 1 )); then
    echo "Error in the execution, failing early"
    exit 1
fi

output="BFS tests summary = TOTAL: $TOTAL / PASS: $PASS / SKIP: $SKIP / FAIL: $FAIL"
echo "${output}"
if (( FAIL > 0 )); then echo "::warning ::${output}"; fi

jq -n \
   --arg date "$(date --rfc-email)" \
   --arg sha "$GITHUB_SHA" \<commit_msg>ci: Fix BFS tests comparison with zero skipped tests<commit_after>#!/bin/bash

set -eo pipefail

if ! test -d ../bfs; then
    echo "Could not find ../bfs"
    echo "git clone https://github.com/tavianator/bfs.git"
    exit 1
fi

# build the rust implementation
cargo build --release
FIND=$(readlink -f target/release/find)

cd ..
make -C bfs -j "$(nproc)" tests/mksock WITH_ONIGURUMA=

# Run the GNU find compatibility tests by default
if test "$#" -eq 0; then
    set -- --verbose --gnu
fi

LOG_FILE=bfs/tests.log
./bfs/tests.sh --bfs="$FIND" "$@" | tee "$LOG_FILE" || :

PASS=$(sed -n "s/^tests passed: \(.*\)/\1/p" "$LOG_FILE" | head -n1)
SKIP=$(sed -n "s/^tests skipped: \(.*\)/\1/p" "$LOG_FILE" | head -n1)
FAIL=$(sed -n "s/^tests failed: \(.*\)/\1/p" "$LOG_FILE" | head -n1)

# Default any missing numbers to zero (e.g. no tests skipped)
: ${PASS:=0}
: ${SKIP:=0}
: ${FAIL:=0}

TOTAL=$((PASS + SKIP + FAIL))
if (( TOTAL <= 1 )); then
    echo "Error in the execution, failing early"
    exit 1
fi

output="BFS tests summary = TOTAL: $TOTAL / PASS: $PASS / SKIP: $SKIP / FAIL: $FAIL"
echo "${output}"
if (( FAIL > 0 )); then echo "::warning ::${output}"; fi

jq -n \
   --arg date "$(date --rfc-email)" \
   --arg sha "$GITHUB_SHA" \
{'fraction_non_alphanumeric': 0.20804794520547945, 'fraction_numerical': 0.010702054794520547, 'mean_word_length': 2.961016949152542, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1309393', 'n_tokens_mistral': 961, 'n_tokens_neox': 902, 'n_words': 285}