<commit_before>a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BINDIR=$(cd $a; pwd)
tmp=$(mktemp /tmp/spf-test-unit-XXXXXXXXX)
trap "rm $tmp*" EXIT
. $BINDIR/../include/despf.inc.sh
export LC_ALL=C
export LANG=C

testexpect() {
  IN=0
  test $1 = "-n" && shift || cat > $tmp-out
  EXPRET=$1
  shift

  echo .. Testing $* ...
  set +e
  eval "$@" > $tmp-real 2>&1
  RETURN=$?
  set -e
  test -s $tmp-out && { diff $tmp-out $tmp-real; rm $tmp-out; }
  test $EXPRET -eq $RETURN
  echo .... OK
}

testexpect 0 mydig -t TXT spf-tools.ml <<EOF
"v=spf1 include:spf1.spf-tools.ml ~all"
EOF

testexpect 0 "mydig -t NS spf-tools.ml | sort" <<EOF
chris.ns.cloudflare.com.
dawn.ns.cloudflare.com.
EOF

testexpect 0 "findns orig.spf-tools.ml | sort" <<EOF
chris.ns.cloudflare.com.
dawn.ns.cloudflare.com.
EOF

testexpect -n 1 findns orig.non-existent.nonnon

cat > $tmp <<EOF<commit_msg>Add test for mydig_notshort<commit_after>a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BINDIR=$(cd $a; pwd)
tmp=$(mktemp /tmp/spf-test-unit-XXXXXXXXX)
trap "rm $tmp*" EXIT
. $BINDIR/../include/despf.inc.sh
export LC_ALL=C
export LANG=C

testexpect() {
  IN=0
  test $1 = "-n" && shift || cat > $tmp-out
  EXPRET=$1
  shift

  echo .. Testing $* ...
  set +e
  eval "$@" > $tmp-real 2>&1
  RETURN=$?
  set -e
  test -s $tmp-out && { diff $tmp-out $tmp-real; rm $tmp-out; }
  test $EXPRET -eq $RETURN
  echo .... OK
}

testexpect 0 mydig -t TXT spf-tools.ml <<EOF
"v=spf1 include:spf1.spf-tools.ml ~all"
EOF

testexpect 0 "mydig -t NS spf-tools.ml | sort" <<EOF
chris.ns.cloudflare.com.
dawn.ns.cloudflare.com.
EOF

testexpect 0 "mydig_notshort -t A cname.spf-tools.ml @dawn.ns.cloudflare.com." <<EOF
cname.spf-tools.ml.	300	IN	CNAME	both.spf-tools.ml.
both.spf-tools.ml.	300	IN	A	1.2.3.4
EOF

testexpect 0 "findns orig.spf-tools.ml | sort" <<EOF
chris.ns.cloudflare.com.
dawn.ns.cloudflare.com.
EOF

testexpect -n 1 findns orig.non-existent.nonnon

cat > $tmp <<EOF
{'fraction_non_alphanumeric': 0.19833852544132918, 'fraction_numerical': 0.018172377985462097, 'mean_word_length': 3.1440860215053763, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 2, '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': '5352072', 'n_tokens_mistral': 896, 'n_tokens_neox': 857, 'n_words': 203}