<commit_before>#!/bin/bash

# Sorts .rpl tests into several categories.
# Takes a diretory with the tests as an argument and moves the test to its subdirectories.

source=$1


# Test with the same name is already imported in deckard/sets/resolver
echo Already imported:
mkdir -p $source/imported
for test in `comm -12 <(ls -F ../sets/resolver/*.rpl | xargs -n 1 basename) <(ls -F $source/*.rpl | xargs -n 1 basename)`
do
    echo -e '\t' $test
    mv $source/$test $source/imported
done

# Parse failed
echo Parse failed:
mkdir -p $source/parsefail
for test in $source/*.rpl
do
    if ! python3 parse.py $test >/dev/null 2>/dev/null
    then
        echo -e '\t' $test
        mv $test $source/parsefail
    fi
done


# Invalid DSA signatures (common in old testbound tests)
echo Invalid DSA signatures:
mkdir -p $source/invaliddsa
for test in $source/*.rpl
do
    if ! python3 invalid_dsa.py $test >/dev/null 2>/dev/null
    then 
        echo -e '\t' $test
        mv $test $source/invaliddsa
    fi
done


# Working on kresd in deckard
echo Working:
mkdir -p $source/working

for test in $source/*.rpl
do
    path=$(readlink -m $test)
    if TESTS=$path ./../kresd_run.sh >/dev/null 2>/dev/null
    then 
        echo -e '\t' $test
        mv $test $source/working
    fi
done


# Others
echo Others:
mkdir -p $source/others
for test in $source/*.rpl
do
    echo -e '\t' $test
    mv $test $source/others
done<commit_msg>tools: scripts for sorting tests recomendations to divide_tests.sh from comments of 11b5b7fe<commit_after>#!/bin/bash

# Sorts .rpl tests into several categories.
# Takes a diretory with the tests as an argument and moves the test to its subdirectories.

set -o nounset
set -o errexit

SOURCE="$1"


# Test with the same name is already imported in deckard/sets/resolver
echo Already imported:
mkdir -p "$SOURCE/imported"
for TEST in `comm -12 <(ls -F ../sets/resolver/*.rpl | xargs -n 1 basename) <(ls -F "$SOURCE"/*.rpl | xargs -n 1 basename)`
do
    echo -e '\t' "$TEST"
    mv "$SOURCE/$TEST" "$SOURCE/imported"
done

# Parse failed
echo Parse failed:
mkdir -p "$SOURCE/parsefail"
for TEST in "$SOURCE/"*.rpl
do
    if ! python3 parse.py "$TEST" >/dev/null 2>/dev/null
    then
        echo -e '\t' "$TEST"
        mv "$TEST" "$SOURCE/parsefail"
    fi
done


# Invalid DSA signatures (common in old testbound tests)
echo Invalid DSA signatures:
mkdir -p "$SOURCE/invaliddsa"
for TEST in "$SOURCE"/*.rpl
do
    if ! python3 invalid_dsa.py "$TEST" >/dev/null 2>/dev/null
    then 
        echo -e '\t' "$TEST"
        mv "$TEST" "$SOURCE/invaliddsa"
    fi
done


# Working on kresd in deckard
echo Working:
mkdir -p "$SOURCE/working"

for TEST in "$SOURCE/"*.rpl
do
    PATH=$(readlink -m "$TEST")
    if $TESTS="$PATH" ./../kresd_run.sh >/dev/null 2>/dev/null
    then 
        echo -e '\t' "$TEST"
        mv "$TEST" "$SOURCE/working"
    fi
done


# Others
echo Others:
mkdir -p "$SOURCE/others"
for test in "$SOURCE/*.rpl"
do
    echo -e '\t' "$TEST"
    mv "$TEST" "$SOURCE/others"
done


{'fraction_non_alphanumeric': 0.13075140681893413, 'fraction_numerical': 0.007944389275074478, 'mean_word_length': 2.7775, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '621907', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1050, 'n_words': 386}