Esempio n. 1
0
def cran_pkg_tests(list_file, graalvm_home=None):
    cache_args = []
    cache = os.environ.get('FASTR_PKGS_CACHE_OPT')
    if cache is None:
        mx.warn("If you want to use R packages cache, export environment variable FASTR_PKGS_CACHE_OPT. See option '--cache-pkgs' of 'mx pkgtest' for the syntax.")
    else:
        cache_args += ['--cache-pkgs', cache]
    result = pkgtest(["--verbose"] + cache_args + common_pkg_tests_args(graalvm_home) + ["--pkg-filelist", list_file])
    if result != 0:
        mx.abort("package test failed")
Esempio n. 2
0
def internal_pkg_tests(graalvm_home=None):
    list_file = os.path.join(_fastr_suite.dir, 'com.oracle.truffle.r.test.native/packages/pkg-filelist')
    if os.environ.get('FASTR_RFFI') == 'llvm':
        list_file_llvm = list_file + '.llvm'
        if os.path.exists(list_file_llvm):
            list_file = list_file_llvm
    if 'FASTR_GCTORTURE' in os.environ:
        list_file_gctorture = list_file + '.gctorture'
        if os.path.exists(list_file_gctorture):
            list_file = list_file_gctorture
    result = pkgtest(["--verbose", "--pkg-filelist", list_file] + common_pkg_tests_args(graalvm_home))
    if result != 0:
        mx.abort("internal package test failed")
Esempio n. 3
0
def _fastr_gate_runner(args, tasks):
    with mx_gate.Task('Setup no specials',
                      tasks,
                      tags=[FastRGateTags.no_specials]) as t:
        if t:
            os.environ['FASTR_OPTION_UseSpecials'] = 'false'

    with mx_gate.Task('Setup no dsl cache',
                      tasks,
                      tags=[FastRGateTags.no_dsl_cache]) as t:
        if t:
            os.environ['FASTR_OPTION_DSLCacheSizeFactor'] = '0'

    with mx_gate.Task('SetupLLVM', tasks, tags=[FastRGateTags.llvm]) as t:
        if t:
            os.environ['FASTR_RFFI'] = 'llvm'

    with mx_gate.Task('GCTorture1', tasks,
                      tags=[FastRGateTags.gc_torture1]) as t:
        if t:
            os.environ['FASTR_GCTORTURE'] = '1'

    with mx_gate.Task('GCTorture5', tasks,
                      tags=[FastRGateTags.gc_torture5]) as t:
        if t:
            os.environ['FASTR_GCTORTURE'] = '5'
    '''
    The specific additional gates tasks provided by FastR.
    '''
    with mx_gate.Task('ExtSoftVersions', tasks,
                      tags=[mx_gate.Tags.always]) as t:
        if t:
            new_env = os.environ.copy()
            new_env['R_DEFAULT_PACKAGES'] = 'base'
            run_r(['-q', '-e', 'extSoftVersion()'], 'R', env=new_env)

    # ---------------------------------
    # Style checks:

    # FastR has custom copyright check
    with mx_gate.Task('Copyright check', tasks,
                      tags=[mx_gate.Tags.style]) as t:
        if t:
            if mx.checkcopyrights(['--primary']) != 0:
                t.abort('copyright errors')

    # check that the expected test output file is up to date
    with mx_gate.Task('UnitTests: ExpectedTestOutput file check',
                      tasks,
                      tags=[mx_gate.Tags.style]) as t:
        if t:
            mx_unittest.unittest([
                '-Dfastr.test.gen.expected=' +
                _test_srcdir(), '-Dfastr.test.check.expected=true'
            ] + _gate_unit_tests())

    # ----------------------------------
    # Basic tests:

    with mx_gate.Task(
            'UnitTests',
            tasks,
            tags=[FastRGateTags.basic_tests, FastRGateTags.unit_tests]) as t:
        if t:
            mx_unittest.unittest(_gate_noapps_unit_tests())

    with mx_gate.Task('Rembedded', tasks,
                      tags=[FastRGateTags.basic_tests]) as t:
        if t:
            if rembedtest([]) != 0:
                t.abort("Rembedded tests failed")

    # ----------------------------------
    # Package tests:

    with mx_gate.Task('Recommended load test',
                      tasks,
                      tags=[FastRGateTags.recommended_load]) as t:
        if t:
            # Note: this is a convenience mx gate job for testing the loading of recommended packages
            # We also test the loading of recommended pkgs in the "graalvm-tests"
            if not os.path.exists(
                    os.path.join(_fastr_suite.dir, 'library', 'spatial')):
                mx.abort(
                    'Recommended packages seem to be not installed in FastR. Did you forget to build with FASTR_RELEASE=true?'
                )
            pkgs = [
                'codetools', 'MASS', 'boot', 'class', 'cluster', 'lattice',
                'nnet', 'spatial', 'Matrix', 'KernSmooth', 'foreign', 'nlme',
                'rpart', 'survival'
            ]
            # TODO: removed failing "KernSmooth" and "cluster" on LLVM, GR-20406
            if os.environ.get('FASTR_RFFI') == 'llvm':
                pkgs.remove('KernSmooth')
                pkgs.remove('cluster')
            # Creates code that looks like: require(codetools) && require(MASS) && ...
            require_stmts = ' && '.join(
                ['require(' + pkg + ')' for pkg in pkgs])
            test_load = 'if (!(' + require_stmts + ')) q(status=1) else q(status=42)'
            if run_r(['--vanilla', '-e', test_load], 'R',
                     nonZeroIsFatal=False) != 42:
                mx.abort("Loading of recommended packages failed")

    with mx_gate.Task('Internal pkg test',
                      tasks,
                      tags=[FastRGateTags.internal_pkgs_test]) as t:
        if t:
            list_file = os.path.join(
                _fastr_suite.dir,
                'com.oracle.truffle.r.test.native/packages/pkg-filelist')
            if os.environ.get('FASTR_RFFI') == 'llvm':
                list_file_llvm = list_file + '.llvm'
                if os.path.exists(list_file_llvm):
                    list_file = list_file_llvm
            if os.environ.get('FASTR_GCTORTURE') != '':
                list_file_gctorture = list_file + '.gctorture'
                if os.path.exists(list_file_gctorture):
                    list_file = list_file_gctorture
            result = pkgtest(
                ["--verbose", "--repos", "FASTR", "--pkg-filelist", list_file])
            if result != 0:
                mx.abort("internal package test failed")

    # CRAN packages are listed in files com.oracle.truffle.r.test.packages/gated0, gated1, ...
    # We loop over all such files and crete gate task for each of them
    # See also documentation in FastRGateTags.cran_pkgs_tests
    for i in range(1, 1000):
        list_file = os.path.join(
            _fastr_suite.dir,
            'com.oracle.truffle.r.test.packages/gated' + str(i))
        if not os.path.exists(list_file):
            break
        with mx_gate.Task('CRAN pkg test: ' + str(i),
                          tasks,
                          tags=[FastRGateTags.cran_pkgs_test + str(i)]) as t:
            if t:
                check_last = False if mx_gate.Task.tags is None else FastRGateTags.cran_pkgs_test_check_last in mx_gate.Task.tags  # pylint: disable=unsupported-membership-test
                if check_last:
                    next_file = os.path.join(
                        _fastr_suite.dir,
                        'com.oracle.truffle.r.test.packages/gated' +
                        str(i + 1))
                    if os.path.exists(next_file):
                        mx.abort(
                            "File %s exists, but the gate thinks that %s is the last file. Did you forget to update the gate configuration?"
                            % (next_file, list_file))
                cache_arg = os.environ.get('FASTR_PKGS_CACHE_OPT')
                if cache_arg is None:
                    cache_arg = []
                    mx.warn(
                        "If you want to use R packages cache, export environment variable FASTR_PKGS_CACHE_OPT. See option '--cache-pkgs' of 'mx pkgtest' for the syntax."
                    )
                else:
                    cache_arg = ['--cache-pkgs', cache_arg]
                result = pkgtest(
                    ["--verbose"] + cache_arg +
                    ["--repos", "SNAPSHOT", "--pkg-filelist", list_file])
                if result != 0:
                    mx.abort("package test failed")