def _fastr_gate_runner(args, tasks): ''' The specific additional gates tasks provided by FastR: 1. Copyright check 2. Check that ExpectedTestOutput file is in sync with unit tests 3. Unit tests ''' # FastR has custom copyright check with mx_gate.Task('Copyright check', tasks) 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) as t: if t: mx_unittest.unittest(['-Dfastr.test.gen.expected=' + _test_srcdir(), '-Dfastr.test.check.expected'] + _gate_unit_tests()) with mx_gate.Task('UnitTests: no specials', tasks) as t: if t: mx_unittest.unittest(['-DR:-UseSpecials'] + _gate_noapps_unit_tests()) with mx_gate.Task('UnitTests: with specials', tasks) as t: if t: mx_unittest.unittest(_gate_noapps_unit_tests()) with mx_gate.Task('UnitTests: apps', tasks) as t: if t: mx_unittest.unittest(_apps_unit_tests())
def _fastr_gate_runner(args, tasks): ''' The specific additional gates tasks provided by FastR: 1. Copyright check 2. Check that ExpectedTestOutput file is in sync with unit tests 3. Unit tests ''' # FastR has custom copyright check with mx_gate.Task('Copyright check', tasks) 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) as t: if t: if junit([ '--tests', _gate_noapps_unit_tests(), '--check-expected-output' ]) != 0: t.abort('unit tests expected output check failed') with mx_gate.Task('UnitTests', tasks) as t: if t: if junit(['--tests', _gate_noapps_unit_tests()]) != 0: t.abort('unit tests failed')
def _add_copyright_checks(tasks): with mx_gate.Task('Check Copyrights', tasks, tags=[mx_gate.Tags.style]) as t: if t: if mx.checkcopyrights(['--primary']) != 0: t.abort('Copyright errors found. Please run "mx ' 'checkcopyrights --primary -- --fix" to fix them.')
def runSuite(args=None): """executes all the test suites or selected ones (see -h or --help)""" vmArgs, otherArgs = mx_sulong.truffle_extract_VM_args(args) parser = argparse.ArgumentParser(description="Compiles all or selected test suites.") parser.add_argument('suite', nargs='*', help=' '.join(testSuites.keys()), default=testSuites.keys()) parsedArgs = parser.parse_args(otherArgs) tasks = [] with mx_gate.Task('BuildJavaWithJavac', tasks) as t: if t: mx.command_function('build')(['-p', '--warning-as-error', '--force-javac']) for testSuiteName in parsedArgs.suite: with mx_gate.Task('Test%s' % testSuiteName.capitalize(), tasks) as t: if t: _, runCommand = testSuites[testSuiteName] runCommand(vmArgs)
def _add_unit_tests(tasks, supports_coverage): with mx_gate.Task('TruffleSqueak JUnit and SUnit tests', tasks, tags=['test']) as t: if t: unittest_args = VM_ARGS_TESTING[:] if supports_coverage: unittest_args.extend(_get_jacoco_agent_args()) unittest_args.extend([ '--suite', 'trufflesqueak', '--very-verbose', '--color', '--enable-timing' ]) if _COMPILER: unittest_args.extend([ '-Dgraal.CompilationFailureAction=ExitVM', '-Dpolyglot.engine.CompilationFailureAction=ExitVM', '-Dpolyglot.engine.TreatPerformanceWarningsAsErrors=all', '-Dpolyglot.engine.CompilationStatistics=true' ]) # Ensure Truffle TCK disabled (workaround needed since GraalVM 19.2.0) # import mx_truffle # mx_unittest._config_participants.remove( # mx_truffle._unittest_config_participant_tck) mx_unittest.unittest(unittest_args)
def _trufflesqueak_gate_runner(args, tasks): os.environ['MX_GATE'] = 'true' supports_coverage = '--jacocout' in sys.argv _add_copyright_checks(tasks) # _add_tck_tests(tasks, supports_coverage) _add_unit_tests(tasks, supports_coverage) if supports_coverage: with mx_gate.Task('Report Code Coverage', tasks, tags=['test']) as t: if t: mx.command_function('jacocoreport')(['--format', 'xml', '.'])
def _add_tck_tests(tasks, supports_coverage): with mx_gate.Task('GraalSqueak TCK tests', tasks, tags=['test']) as t: if t: unittest_args = BASE_VM_ARGS_TESTING[:] if supports_coverage: unittest_args.extend(_get_jacoco_agent_args()) test_image = _get_path_to_test_image() unittest_args.extend([ '--color', '--fail-fast', '-Dtck.language=%s' % LANGUAGE_ID, '-Dpolyglot.%s.headless=true' % LANGUAGE_ID, '-Dpolyglot.%s.image-path=%s' % (LANGUAGE_ID, test_image), 'com.oracle.truffle.tck.tests']) mx_unittest.unittest(unittest_args)
def _add_unit_tests(tasks, supports_coverage): with mx_gate.Task('GraalSqueak JUnit and SUnit tests', tasks, tags=['test']) as t: if t: unittest_args = BASE_VM_ARGS_TESTING[:] if supports_coverage: unittest_args.extend(_get_jacoco_agent_args()) unittest_args.extend(['--suite', 'graalsqueak', '--very-verbose', '--color', '--enable-timing']) # Ensure Truffle TCK disabled (workaround needed since GraalVM 19.2.0) # import mx_truffle # mx_unittest._config_participants.remove( # mx_truffle._unittest_config_participant_tck) mx_unittest.unittest(unittest_args)
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('GCTorture3', tasks, tags=[FastRGateTags.gc_torture3]) as t: if t: os.environ['FASTR_GCTORTURE'] = '3' with mx_gate.Task('VerySlowAsserts', tasks, tags=[FastRGateTags.very_slow_asserts]) as t: if t: os.environ['FASTR_TEST_VERY_SLOW_ASSERTS'] = 'true' ''' 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) with mx_gate.Task('LibsInfo', tasks, tags=[mx_gate.Tags.always]) as t: if t: mx.log("Libraries captured in FASTR_HOME/lib:") lib_dir = os.path.join(_fastr_suite.dir, 'lib') ldd = ['otool', '-L'] if platform.system() == 'Darwin' else ['ldd'] for f in os.listdir(lib_dir): full_path = os.path.join(lib_dir, f) mx.run(['file', full_path], nonZeroIsFatal=False) mx.log('---\nobjdump:') mx.run(['objdump', '-s', '--section', '.comment', full_path], nonZeroIsFatal=False) mx.log('---\nlinking info:') mx.run(ldd + [full_path], nonZeroIsFatal=False) mx.log('---------') # --------------------------------- # 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' ] # 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: internal_pkg_tests() # 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)) cran_pkg_tests(list_file)
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")