<commit_before>from os import path
from benchbuild.utils.wrapping import wrap
from benchbuild.projects.benchbuild.group import BenchBuildGroup
from benchbuild.utils.compiler import lt_clang
from benchbuild.utils.downloader import Wget
from benchbuild.utils.run import run
from benchbuild.utils.cmd import cat, make, unzip, mv, mkdir
from plumbum import local


class Crafty(BenchBuildGroup):
    """ crafty benchmark """

    NAME = 'crafty'
    DOMAIN = 'scientific'
    VERSION = '25.2'

    src_dir = "crafty-{0}".format(VERSION)
    src_uri = "http://www.craftychess.com/downloads/source/crafty-{0}.zip".format(VERSION)
    SRC_FILE = src_dir + ".zip"

    def download(self):
        book_file = "book.bin"
        book_bin = "http://www.craftychess.com/downloads/book/" + book_file
        Wget(self.src_uri, self.SRC_FILE)
        Wget(book_bin, book_file)

        mkdir(self.src_dir)

        with local.cwd(self.src_dir):
            unzip(path.join("..", self.SRC_FILE))
        mv(book_file, self.src_dir)

    def configure(self):
        pass

    def build(self):
        clang = lt_clang(self.cflags, self.ldflags, self.compiler_extension)
        with local.cwd(self.src_dir):
            target_opts = ["-DCPUS=1", "-DSYZYGY", "-DTEST"]
            crafty_make = make["target=UNIX", "CC="+str(clang),
                               "opt="+" ".join(target_opts), "crafty-make"]
            run(crafty_make)

    def run_tests(self, experiment, run):
        with local.cwd(self.src_dir):
            exp = wrap("./crafty", experiment)
            run((cat[path.join(self.testdir, "test1.sh")] | exp), retcode=120)
            run((cat[path.join(self.testdir, "test2.sh")] | exp), retcode=120)<commit_msg>crafty: accept both 0 and 120 as retcode<commit_after>from os import path
from benchbuild.utils.wrapping import wrap
from benchbuild.projects.benchbuild.group import BenchBuildGroup
from benchbuild.utils.compiler import lt_clang
from benchbuild.utils.downloader import Wget
from benchbuild.utils.run import run
from benchbuild.utils.cmd import cat, make, unzip, mv, mkdir
from plumbum import local


class Crafty(BenchBuildGroup):
    """ crafty benchmark """

    NAME = 'crafty'
    DOMAIN = 'scientific'
    VERSION = '25.2'

    src_dir = "crafty-{0}".format(VERSION)
    src_uri = "http://www.craftychess.com/downloads/source/crafty-{0}.zip".format(VERSION)
    SRC_FILE = src_dir + ".zip"

    def download(self):
        book_file = "book.bin"
        book_bin = "http://www.craftychess.com/downloads/book/" + book_file
        Wget(self.src_uri, self.SRC_FILE)
        Wget(book_bin, book_file)

        mkdir(self.src_dir)

        with local.cwd(self.src_dir):
            unzip(path.join("..", self.SRC_FILE))
        mv(book_file, self.src_dir)

    def configure(self):
        pass

    def build(self):
        clang = lt_clang(self.cflags, self.ldflags, self.compiler_extension)
        with local.cwd(self.src_dir):
            target_opts = ["-DCPUS=1", "-DSYZYGY", "-DTEST"]
            crafty_make = make["target=UNIX", "CC="+str(clang),
                               "opt="+" ".join(target_opts), "crafty-make"]
            run(crafty_make)

    def run_tests(self, experiment, run):
        with local.cwd(self.src_dir):
            exp = wrap("./crafty", experiment)
            run((cat[path.join(self.testdir, "test1.sh")] | exp),
                retcode=[0, 120])
            run((cat[path.join(self.testdir, "test2.sh")] | exp),
                retcode=[0, 120])
{'fraction_non_alphanumeric': 0.13642836798632868, 'fraction_numerical': 0.00968385075477072, 'mean_word_length': 2.7361702127659573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1997545', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1155, 'n_words': 228}