<commit_before>from benchbuild.projects.benchbuild.group import BenchBuildGroup
from benchbuild.project import wrap
from benchbuild.settings import CFG
from benchbuild.utils.compiler import lt_clang, lt_clang_cxx
from benchbuild.utils.downloader import Git
from benchbuild.utils.run import run
from benchbuild.utils.versions import get_git_hash

from plumbum import local
from benchbuild.utils.cmd import make, mkdir

from os import path


class SpiderMonkey(BenchBuildGroup):
    NAME = 'js'
    DOMAIN = 'compilation'

    SRC_FILE = "https://github.com/mozilla/gecko-dev.git"
    src_dir = "gecko-dev.git"
    version = get_git_hash(SRC_FILE)
    if version == None:
        VERSION = None
    elif len(version) <= 7:
        VERSION = str(version)
    else:
        VERSION = str(version)[:7]

    def download(self):
        Git(self.SRC_FILE, self.src_dir)

    def configure(self):
        js_dir = path.join(self.src_dir, "js", "src")
        clang = lt_clang(self.cflags, self.ldflags, self.compiler_extension)
        clang_cxx = lt_clang_cxx(self.cflags, self.ldflags,
                                 self.compiler_extension)
        with local.cwd(js_dir):
            autoconf = local["autoconf"]
            autoconf()
            mkdir("build_OPT.OBJ")
            with local.cwd("build_OPT.OBJ"):
                with local.env(CC=str(clang), CXX=str(clang_cxx)):
                    configure = local["../configure"]
                    run(configure)

    def build(self):
        js_dir = path.join(self.src_dir, "js", "src", "build_OPT.OBJ")
        with local.cwd(js_dir):
            run(make["-j", CFG["available_cpu_count"].value()])

    def run_tests(self, experiment):
        js_dir = path.join(self.src_dir, "js", "src")
        js_build_dir = path.join(js_dir, "build_OPT.OBJ")
        wrap(path.join(js_build_dir, "bin", "js"), experiment)

        with local.cwd(js_build_dir):
            run(make["check"])<commit_msg>js: update to newest gecko<commit_after>from benchbuild.projects.benchbuild.group import BenchBuildGroup
from benchbuild.project import wrap
from benchbuild.settings import CFG
from benchbuild.utils.compiler import lt_clang, lt_clang_cxx
from benchbuild.utils.downloader import Git
from benchbuild.utils.run import run
from benchbuild.utils.versions import get_git_hash

from plumbum import local
from benchbuild.utils.cmd import make, mkdir, tar

from os import path


class SpiderMonkey(BenchBuildGroup):
    """
    SpiderMonkey requires a legacy version of autoconf: autoconf-2.13
    """

    NAME = 'js'
    DOMAIN = 'compilation'

    SRC_FILE = "https://github.com/mozilla/gecko-dev.git"
    src_dir = "gecko-dev.git"
    version = get_git_hash(SRC_FILE)
    if version == None:
        VERSION = None
    elif len(version) <= 7:
        VERSION = str(version)
    else:
        VERSION = str(version)[:7]

    def download(self):
        Git(self.SRC_FILE, self.src_dir)

    def configure(self):
        js_dir = path.join(self.src_dir, "js", "src")
        clang = lt_clang(self.cflags, self.ldflags, self.compiler_extension)
        clang_cxx = lt_clang_cxx(self.cflags, self.ldflags,
                                 self.compiler_extension)
        with local.cwd(js_dir):
            make_src_pkg = local["./make-source-package.sh"]
            with local.env(DIST=self.builddir,
                           MOZJS_MAJOR_VERSION=0,
                           MOZJS_MINOR_VERSION=0,
                           MOZJS_PATCH_VERSION=0):
                make_src_pkg()

        mozjs_dir = "mozjs-0.0.0"
        tar("xfj", mozjs_dir + ".tar.bz2")
        with local.cwd(path.join(mozjs_dir, "js", "src")):
            mkdir("obj")
            autoconf = local["autoconf-2.13"]
            autoconf()
            with local.cwd("obj"):
                with local.env(CC=str(clang),
                               CXX=str(clang_cxx)):
                    configure = local["../configure"]
                    run(configure)

    def build(self):
        mozjs_dir = path.join("mozjs-0.0.0", "js", "src", "obj")
        with local.cwd(mozjs_dir):
            run(make["-j", CFG["jobs"].value()])

    def run_tests(self, experiment):
        mozjs_dir = path.join("mozjs-0.0.0", "js", "src", "obj")
        wrap(path.join(mozjs_dir, "bin", "js"), experiment)

        with local.cwd(mozjs_dir):
            run(make["check"])
{'fraction_non_alphanumeric': 0.12046543463381246, 'fraction_numerical': 0.005247547342003194, 'mean_word_length': 2.398449612403101, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '804023', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1402, 'n_words': 281}