<commit_before>#!/usr/bin/python3

import os, sh, sys, time, uuid
from tests_common import *

def main():
    sh.mkdir("-p","log")

    printc("COMPILING", color="blue")
    start = time.time()
    try:
        compile(logfile=open("log/compile.txt","wb"))
    except:
        printc("ERROR COMPILING", color="red")
        with open("log/compile.txt") as fd:
            print( fd.read() )
            sys.exit(1)
    end = time.time()

    token = uuid.uuid4()
    fail = False
    dbname = random_dbname()
    dburl = "postgresql://serverboards:serverboards@localhost/%s"%dbname

    with tmpdb(dbname), \
         envset(MIX_ENV="test", SERVERBOARDS_DATABASE_URL=dburl, SERVERBOARDS_TCP_PORT="4040", SERVERBOARDS_INI="test/plugins.ini"), \
         running("mix", "run", "--no-halt", _out="log/serverboards.txt", _err_to_out=True, _cwd="backend"):
        printc("WAIT FOR PORT", color="blue")
        wait_for_port(4040, timeout=20)
        printc("CREATE USER", color="blue")
        create_user(dburl, token)
        printc("TESTS", color="blue")
        with chdir("cli"):
            try:
                sh.make()
                sh.Command("./s10s-plugin-test.py")("--auth-token", token, _out=sys.stdout.buffer, _err_to_out=True)
            except sh.ErrorReturnCode_1:
                fail=True
            except:
                import traceback
                traceback.print_exc()
                fail=True
    if fail:
        print()<commit_msg>Plugin test must be in prod to perform corretly the logging<commit_after>#!/usr/bin/python3

import os, sh, sys, time, uuid
from tests_common import *

def main():
    sh.mkdir("-p","log")

    printc("COMPILING", color="blue")
    start = time.time()
    try:
        compile(logfile=open("log/compile.txt","wb"))
    except:
        printc("ERROR COMPILING", color="red")
        with open("log/compile.txt") as fd:
            print( fd.read() )
            sys.exit(1)
    end = time.time()

    token = <KEY>()
    fail = False
    dbname = random_dbname()
    dburl = "postgresql://serverboards:serverboards@localhost/%s"%dbname

    with tmpdb(dbname), \
         envset(MIX_ENV="prod", SERVERBOARDS_DATABASE_URL=dburl, SERVERBOARDS_TCP_PORT="4040", SERVERBOARDS_INI="test/plugins.ini"), \
         running("mix", "run", "--no-halt", _out="log/serverboards.txt", _err_to_out=True, _cwd="backend"):
        printc("WAIT FOR PORT", color="blue")
        wait_for_port(4040, timeout=20)
        printc("CREATE USER", color="blue")
        create_user(dburl, token)
        printc("TESTS", color="blue")
        with chdir("cli"):
            try:
                sh.make()
                sh.Command("./s10s-plugin-test.py")("--auth-token", token, _out=sys.stdout.buffer, _err_to_out=True)
            except sh.ErrorReturnCode_1:
                fail=True
            except:
                import traceback
                traceback.print_exc()
                fail=True
    if fail:
        print()
{'fraction_non_alphanumeric': 0.14910804442948503, 'fraction_numerical': 0.010434197239986537, 'mean_word_length': 2.339325842696629, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '476929', 'n_tokens_mistral': 991, 'n_tokens_neox': 965, 'n_words': 177}