def testdownstream(args):
    """test downstream users of the Truffle API"""
    jruby_dir = 'jruby'
    jruby_repo = 'https://github.com/jruby/jruby.git'
    jruby_branch = 'truffle-head'
    git = mx.GitConfig()
    if os.path.exists('jruby'):
        git.run(['git', 'reset', 'HEAD', '--hard'],
                nonZeroIsFatal=True,
                cwd=jruby_dir)
        git.pull('jruby')
    else:
        git.clone(jruby_repo, jruby_dir)
        git.run(['git', 'checkout', jruby_branch],
                nonZeroIsFatal=True,
                cwd=jruby_dir)
    dev_version = _suite.release_version(snapshotSuffix='SNAPSHOT')
    subprocess.check_call(['tool/truffle/set_truffle_version.sh', dev_version],
                          cwd=jruby_dir)
    mx.build([])
    mx.maven_install([])
    subprocess.check_call(['./mvnw', '-X', 'clean'], cwd=jruby_dir)
    subprocess.check_call([
        './mvnw',
        '-X',
    ], cwd=jruby_dir)
    subprocess.check_call(['bin/jruby', 'tool/jt.rb', 'test', 'fast'],
                          cwd=jruby_dir)
Exemple #2
0
def graal_wasm_gate_runner(args, tasks):
    with Task("BuildAll", tasks, tags=[GraalWasmDefaultTags.buildall]) as t:
        if t:
            mx.build(["--all"])
    with Task("UnitTests", tasks, tags=[GraalWasmDefaultTags.wasmtest]) as t:
        if t:
            unittest([
                "-Dwasmtest.watToWasmExecutable=" +
                os.path.join(wabt_dir, "wat2wasm"), "WasmTestSuite"
            ])
    with Task("ExtraUnitTests",
              tasks,
              tags=[GraalWasmDefaultTags.wasmextratest]) as t:
        if t:
            unittest(["CSuite"])
            unittest(["WatSuite"])
    with Task("BenchTest", tasks,
              tags=[GraalWasmDefaultTags.wasmbenchtest]) as t:
        if t:
            for b in microbenchmarks:
                exitcode = mx_benchmark.benchmark([
                    "wasm:WASM_BENCHMARKCASES", "--", "--jvm", "server",
                    "--jvm-config", "graal-core",
                    "-Dwasmbench.benchmarkName=" + b,
                    "-Dwasmtest.keepTempFiles=true", "--",
                    "CMicroBenchmarkSuite", "-wi", "1", "-i", "1"
                ])
                if exitcode != 0:
                    mx.abort("Errors during benchmark tests, aborting.")
Exemple #3
0
def wikidoc(args):
    """generate Confluence Wiki format for package-info.java files"""

    # Ensure the wiki doclet is up to date
    mx.build(['--projects', 'com.oracle.max.tools'])

    # the WikiDoclet cannot see the -classpath argument passed to javadoc so we pass the
    # full list of projects as an explicit argument, thereby enabling it to map classes
    # to projects, which is needed to generate Wiki links to the source code.
    # There is no virtue in running the doclet on dependent projects as there are
    # no generated links between Wiki pages
    toolsDir = mx.project('com.oracle.max.tools').output_dir()
    baseDir = mx.project('com.oracle.max.base').output_dir()
    dp = os.pathsep.join([toolsDir, baseDir])
    project_list = ','.join(p.name for p in mx.sorted_deps())
    for a in [
            '-docletpath', dp, '-doclet',
            'com.oracle.max.tools.javadoc.wiki.WikiDoclet', '-projects',
            project_list
    ]:
        args.append('--arg')
        args.append('@' + a)

    mx.javadoc(args,
               parser=ArgumentParser('mx wikidoc'),
               docDir='wikidoc',
               includeDeps=False,
               stdDoclet=False)
Exemple #4
0
def _find_classes_by_annotated_methods(annotations, suite):
    """
    Scan distributions from binary suite dependencies for classes contain at least one method
    with an annotation from 'annotations' and return a dictionary from fully qualified class
    names to the distribution containing the class.
    """
    binarySuiteDists = [d for d in mx.dependencies(opt_limit_to_suite=True) if d.isJARDistribution() and
                        isinstance(d.suite, mx.BinarySuite) and (not suite or suite == d.suite)]
    if len(binarySuiteDists) != 0:
        # Ensure Java support class is built
        mx.build(['--dependencies', 'com.oracle.mxtool.junit'])

        # Create map from jar file to the binary suite distribution defining it
        jars = {d.classpath_repr() : d for d in binarySuiteDists}

        cp = mx.classpath(['com.oracle.mxtool.junit'] + [d.name for d in binarySuiteDists])
        out = mx.OutputCapture()
        mx.run_java(['-cp', cp] + ['com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] + annotations + jars.keys(), out=out)
        candidates = {}
        for line in out.data.strip().split('\n'):
            name, jar = line.split(' ')
            # Record class name to the binary suite distribution containing it
            candidates[name] = jars[jar]
        return candidates
    return {}
Exemple #5
0
def graal_wasm_gate_runner(args, tasks):
    with Task("BuildAll", tasks, tags=[GraalWasmDefaultTags.buildall]) as t:
        if t:
            mx.build(["--all"])
    with Task("UnitTests", tasks, tags=[GraalWasmDefaultTags.wasmtest]) as t:
        if t:
            unittest(["-Dwasmtest.watToWasmExecutable=" + os.path.join(wabt_dir, wat2wasm_binary()), "WasmTestSuite"])
    with Task("ConstantsPolicyUnitTests", tasks, tags=[GraalWasmDefaultTags.wasmconstantspolicytest]) as t:
        if t:
            unittest(["-Dwasmtest.watToWasmExecutable=" + os.path.join(wabt_dir, wat2wasm_binary()),
                      "-Dwasmtest.storeConstantsPolicy=LARGE_ONLY", "WasmTestSuite"])
    with Task("ExtraUnitTests", tasks, tags=[GraalWasmDefaultTags.wasmextratest]) as t:
        if t:
            unittest(["CSuite"])
            unittest(["WatSuite"])
    with Task("ConstantsPolicyExtraUnitTests", tasks, tags=[GraalWasmDefaultTags.wasmconstantspolicyextratest]) as t:
        if t:
            unittest(["-Dwasmtest.storeConstantsPolicy=LARGE_ONLY", "CSuite"])
            unittest(["-Dwasmtest.storeConstantsPolicy=LARGE_ONLY", "WatSuite"])
    # This is a gate used to test that all the benchmarks return the correct results. It does not upload anything,
    # and does not run on a dedicated machine.
    with Task("BenchTest", tasks, tags=[GraalWasmDefaultTags.wasmbenchtest]) as t:
        if t:
            for b in microbenchmarks:
                exitcode = mx_benchmark.benchmark([
                        "wasm:WASM_BENCHMARKCASES", "--",
                        "--jvm", "server", "--jvm-config", "graal-core",
                        "-Dwasmbench.benchmarkName=" + b, "-Dwasmtest.keepTempFiles=true", "--",
                        "CMicroBenchmarkSuite", "-wi", "1", "-i", "1"])
                if exitcode != 0:
                    mx.abort("Errors during benchmark tests, aborting.")
Exemple #6
0
def _find_classes_by_annotated_methods(annotations, suite):
    """
    Scan distributions from binary suite dependencies for classes contain at least one method
    with an annotation from 'annotations' and return a dictionary from fully qualified class
    names to the distribution containing the class.
    """
    binarySuiteDists = [
        d for d in mx.dependencies(opt_limit_to_suite=True)
        if d.isJARDistribution() and isinstance(d.suite, mx.BinarySuite) and (
            not suite or suite == d.suite)
    ]
    if len(binarySuiteDists) != 0:
        # Ensure Java support class is built
        mx.build(['--dependencies', 'com.oracle.mxtool.junit'])

        # Create map from jar file to the binary suite distribution defining it
        jars = {d.classpath_repr(): d for d in binarySuiteDists}

        cp = mx.classpath(['com.oracle.mxtool.junit'] +
                          [d.name for d in binarySuiteDists])
        out = mx.OutputCapture()
        mx.run_java(['-cp', cp] +
                    ['com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] +
                    annotations + jars.keys(),
                    out=out)
        candidates = {}
        for line in out.data.strip().split('\n'):
            name, jar = line.split(' ')
            # Record class name to the binary suite distribution containing it
            candidates[name] = jars[jar]
        return candidates
    return {}
Exemple #7
0
def testgen(args):
    '''generate the expected output for unit tests, and All/Failing test classes'''
    parser = ArgumentParser(prog='r testgen')
    parser.add_argument('--tests', action='store', default=_all_unit_tests(), help='pattern to match test classes')
    args = parser.parse_args(args)
    # check we are in the home directory
    if os.getcwd() != _fastr_suite.dir:
        mx.abort('must run rtestgen from FastR home directory')
    # check the version of GnuR against FastR
    try:
        fastr_version = subprocess.check_output([mx.get_jdk().java, '-cp', mx.classpath('com.oracle.truffle.r.runtime'), 'com.oracle.truffle.r.runtime.RVersionNumber'])
        gnur_version = subprocess.check_output(['R', '--version'])
        if not gnur_version.startswith(fastr_version):
            mx.abort('R version is incompatible with FastR, please update to ' + fastr_version)
    except subprocess.CalledProcessError:
        mx.abort('RVersionNumber.main failed')
    # clean the test project to invoke the test analyzer AP
    testOnly = ['--projects', 'com.oracle.truffle.r.test']
    mx.clean(['--no-dist', ] + testOnly)
    mx.build(testOnly)
    # now just invoke junit with the appropriate options
    mx.log("generating expected output for packages: ")
    for pkg in args.tests.split(','):
        mx.log("    " + str(pkg))
    junit(['--tests', args.tests, '--gen-expected-output', '--gen-expected-quiet'])
Exemple #8
0
def _unittest(args, annotations, prefixCp="", blacklist=None, whitelist=None, verbose=False, fail_fast=False, enable_timing=False, regex=None, color=False, eager_stacktrace=False, gc_after_test=False, suite=None):
    testfile = os.environ.get('MX_TESTFILE', None)
    if testfile is None:
        (_, testfile) = tempfile.mkstemp(".testclasses", "mxtool")
        os.close(_)

    mainClass = 'com.oracle.mxtool.junit.MxJUnitWrapper'
    if not exists(join(mx.project('com.oracle.mxtool.junit').output_dir(), mainClass.replace('.', os.sep) + '.class')):
        mx.build(['--only', 'com.oracle.mxtool.junit'])
    coreCp = mx.classpath(['com.oracle.mxtool.junit'])

    coreArgs = []
    if verbose:
        coreArgs.append('-JUnitVerbose')
    if fail_fast:
        coreArgs.append('-JUnitFailFast')
    if enable_timing:
        coreArgs.append('-JUnitEnableTiming')
    if color:
        coreArgs.append('-JUnitColor')
    if eager_stacktrace:
        coreArgs.append('-JUnitEagerStackTrace')
    if gc_after_test:
        coreArgs.append('-JUnitGCAfterTest')


    def harness(unittestCp, vmLauncher, vmArgs):
        prefixArgs = ['-esa', '-ea']
        if gc_after_test:
            prefixArgs.append('-XX:-DisableExplicitGC')
        with open(testfile) as fp:
            testclasses = [l.rstrip() for l in fp.readlines()]

        cp = prefixCp + coreCp + os.pathsep + unittestCp

        # suppress menubar and dock when running on Mac
        vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs + ['-cp', mx._separatedCygpathU2W(cp)]
        # Execute Junit directly when one test is being run. This simplifies
        # replaying the VM execution in a native debugger (e.g., gdb).
        mainClassArgs = coreArgs + (testclasses if len(testclasses) == 1 else ['@' + mx._cygpathU2W(testfile)])

        config = (vmArgs, mainClass, mainClassArgs)
        for p in _config_participants:
            config = p(config)

        vmLauncher.launcher(*config)

    vmLauncher = _vm_launcher
    if vmLauncher is None:
        jdk = mx.get_jdk()
        def _run_vm(vmArgs, mainClass, mainClassArgs):
            mx.run_java(vmArgs + [mainClass] + mainClassArgs, jdk=jdk)
        vmLauncher = _VMLauncher('default VM launcher', _run_vm, jdk)

    try:
        _run_tests(args, harness, vmLauncher, annotations, testfile, blacklist, whitelist, regex, mx.suite(suite) if suite else None)
    finally:
        if os.environ.get('MX_TESTFILE') is None:
            os.remove(testfile)
Exemple #9
0
def copycheck(args):
    """run copyright check on the Maxine sources (defined as being under hg control)"""
    mx.build(['--projects', 'com.oracle.max.base'])
    mx.run_java([
        '-cp',
        mx.classpath('com.oracle.max.base', resolve=False),
        'com.sun.max.tools.CheckCopyright'
    ] + args)
Exemple #10
0
 def build(args):
     # add custom build arguments
     parser = ArgumentParser(prog='mx build')
     parser.add_argument('--debug', action='store_true', dest='debug', help='build in debug mode')
     parser.add_argument('--shared-library', action='store_true', dest='sharedlibrary', help='build as shared library')
     parser.add_argument('--threading', action='store_true', dest='threading', help='build with threading support')
     mx.build(args, parser)
     return 0
Exemple #11
0
def findBugs(args=None):
    tasks = []
    with Task('Clean', tasks) as t:
        if t: mx.clean([]) # we need a clean build before running findbugs
    with Task('Build', tasks) as t:
        if t: mx.build([])
    with Task('Findbugs', tasks) as t:
        if t and mx_findbugs.findbugs([]) != 0:
            t.abort('FindBugs warnings were found')
Exemple #12
0
def findBugs(args=None):
    tasks = []
    with Task('Clean', tasks) as t:
        if t: mx.clean([])  # we need a clean build before running findbugs
    with Task('Build', tasks) as t:
        if t: mx.build(['--force-javac'])
    with Task('Findbugs', tasks) as t:
        if t and mx_findbugs.findbugs([]) != 0:
            t.abort('FindBugs warnings were found')
Exemple #13
0
 def build(args):
     # add custom build arguments
     parser = ArgumentParser(prog='mx build')
     parser.add_argument('--debug',
                         action='store_true',
                         dest='debug',
                         help='build in debug mode')
     mx.build(args, parser)
     return 0
Exemple #14
0
def graal_wasm_gate_runner(args, tasks):
    with Task("BuildAll", tasks, tags=[GraalWasmDefaultTags.buildall]) as t:
        if t:
            mx.build(["--all"])
    with Task("UnitTests", tasks, tags=[GraalWasmDefaultTags.wasmtest]) as t:
        if t:
            unittest(["-Dwasmtest.watToWasmExecutable=" + os.path.join(wabt_dir, "wat2wasm"), "WasmTestSuite"])
    with Task("ExtraUnitTests", tasks, tags=[GraalWasmDefaultTags.wasmextratest]) as t:
        if t:
            unittest(["CSuite"])
            unittest(["WatSuite"])
Exemple #15
0
def _find_classes_by_annotated_methods(annotations, dists, jdk=None):
    if len(dists) == 0:
        return {}

    candidates = {}

    # Create map from jar file to the binary suite distribution defining it
    jarsToDists = {d.classpath_repr(): d for d in dists}

    primarySuite = mx.primary_suite()
    cachesDir = None
    jarsToParse = []
    if primarySuite and primarySuite != mx._mx_suite:
        cachesDir = mx.ensure_dir_exists(
            join(primarySuite.get_output_root(), 'unittest'))
        for d in dists:
            jar = d.classpath_repr()
            testclasses = _read_cached_testclasses(
                cachesDir, jar, jdk if jdk else mx.get_jdk())
            if testclasses is not None:
                for classname in testclasses:
                    candidates[classname] = jarsToDists[jar]
            else:
                jarsToParse.append(jar)

    if jarsToParse:
        # Ensure Java support class is built
        mx.build(['--no-daemon', '--dependencies', 'com.oracle.mxtool.junit'])

        cp = mx.classpath(['com.oracle.mxtool.junit'] +
                          list(jarsToDists.values()),
                          jdk=jdk)
        out = mx.LinesOutputCapture()
        mx.run_java([
            '-cp', cp, 'com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'
        ] + annotations + jarsToParse,
                    out=out,
                    addDefaultArgs=False)

        for line in out.lines:
            parts = line.split(' ')
            jar = parts[0]
            reportedclasses = parts[1:] if len(parts) > 1 else []
            testclasses = [c for c in reportedclasses if not c.startswith("!")]
            excludedclasses = [c for c in reportedclasses if c.startswith("!")]
            if cachesDir:
                _write_cached_testclasses(cachesDir, jar,
                                          jdk if jdk else mx.get_jdk(),
                                          testclasses, excludedclasses)
            for classname in testclasses:
                candidates[classname] = jarsToDists[jar]
    return candidates
Exemple #16
0
def _unittest(args, annotations, junit_args, prefixCp="", blacklist=None, whitelist=None, regex=None, suite=None, **extra_args):
    testfile = os.environ.get('MX_TESTFILE', None)
    if testfile is None:
        (_, testfile) = tempfile.mkstemp(".testclasses", "mxtool")
        os.close(_)

    mainClass = 'com.oracle.mxtool.junit.MxJUnitWrapper'
    mx.build(['--no-daemon', '--dependencies', 'JUNIT_TOOL'])
    coreCp = mx.classpath(['JUNIT_TOOL'])

    def harness(unittestDeps, vmLauncher, vmArgs):
        prefixArgs = ['-esa', '-ea']
        if '-JUnitGCAfterTest' in junit_args:
            prefixArgs.append('-XX:-DisableExplicitGC')
        with open(testfile) as fp:
            testclasses = [l.rstrip() for l in fp.readlines()]

        jdk = vmLauncher.jdk()
        vmArgs += mx.get_runtime_jvm_args(unittestDeps, cp_prefix=prefixCp+coreCp, jdk=jdk)

        # suppress menubar and dock when running on Mac
        vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs

        if jdk.javaCompliance > '1.8':
            # This is required to access jdk.internal.module.Modules for supporting
            # the @AddExports annotation.
            vmArgs = vmArgs + ['--add-exports=java.base/jdk.internal.module=ALL-UNNAMED']

        # Execute Junit directly when one test is being run. This simplifies
        # replaying the VM execution in a native debugger (e.g., gdb).
        mainClassArgs = junit_args + (testclasses if len(testclasses) == 1 else ['@' + mx._cygpathU2W(testfile)])

        config = (vmArgs, mainClass, mainClassArgs)
        for p in _config_participants:
            config = p(config)
        vmLauncher.launcher(*config)

    vmLauncher = _vm_launcher
    if vmLauncher is None:
        jdk = mx.get_jdk()
        def _run_vm(vmArgs, mainClass, mainClassArgs):
            mx.run_java(vmArgs + [mainClass] + mainClassArgs, jdk=jdk)
        vmLauncher = _VMLauncher('default VM launcher', _run_vm, jdk)

    try:
        _run_tests(args, harness, vmLauncher, annotations, testfile, blacklist, whitelist, regex, mx.suite(suite) if suite else None)
    finally:
        if os.environ.get('MX_TESTFILE') is None:
            os.remove(testfile)
Exemple #17
0
def _truffle_gate_state_bitwidth_tests():
    runs = [1, 2, 4, 8, 16, 32, 64]
    for run_bits in runs:
        build_args = ['-f', '-p', '--dependencies', 'TRUFFLE_TEST', '--force-javac',
                      '-A-Atruffle.dsl.StateBitWidth={0}'.format(run_bits)]

        unittest_args = ['--suite', 'truffle', '--enable-timing', '--fail-fast', '-Dtruffle.dsl.StateBitWidth={0}'.format(run_bits),
                         'com.oracle.truffle.api.dsl.test', 'com.oracle.truffle.api.library.test', 'com.oracle.truffle.sl.test']
        try:
            mx.build(build_args)
            unittest(unittest_args)
        finally:
            mx.log('Completed Truffle DSL state bitwidth test. Reproduce with:')
            mx.log('  mx build {0}'.format(" ".join(build_args)))
            mx.log('  mx unittest {0}'.format(" ".join(unittest_args)))
Exemple #18
0
def testdownstream(args):
    """test downstream users of the Truffle API"""
    jruby_dir = 'jruby'
    jruby_repo = 'https://github.com/jruby/jruby.git'
    jruby_branch = 'truffle-head'
    git = mx.GitConfig()
    if os.path.exists('jruby'):
        git.run(['git', 'reset', 'HEAD', '--hard'], nonZeroIsFatal=True, cwd=jruby_dir)
        git.pull('jruby')
    else:
        git.clone(jruby_repo, jruby_dir)
        git.run(['git', 'checkout', jruby_branch], nonZeroIsFatal=True, cwd=jruby_dir)
    dev_version = _suite.release_version(snapshotSuffix='SNAPSHOT')
    mx.build([])
    mx.maven_install([])
    subprocess.check_call(['./mvnw', '-q', '-Dtruffle.version=' + dev_version], cwd=jruby_dir)
    subprocess.check_call(['bin/jruby', 'tool/jt.rb', 'test', 'fast'], cwd=jruby_dir)
Exemple #19
0
def webserver(args):
    """start or bundle a simple webserver with a web site"""

    parser = ArgumentParser(
        prog='mx webserver',
        description='Start a webserver to serve the site at root or '
        'bundle the site along with the server into an executable jar.')

    parser.add_argument(
        '-a',
        '--archive',
        help=
        'instead of starting the server, create an executable jar in <path> '
        'containing the server and the site at root such that `java -jar <path>` will start a server '
        'for the site and open a browser at its root.',
        metavar='<path>')
    parser.add_argument('-p',
                        '--port',
                        help='local port on which the server should listen',
                        metavar='<num>')
    parser.add_argument(
        '--no-browse',
        help='do not open default web browser on the served site',
        action='store_true')
    parser.add_argument('root', metavar='root')

    args = parser.parse_args(args)

    project = 'com.oracle.mxtool.webserver'
    mainClass = project + '.WebServer'
    mx.build(['--no-daemon', '--dependencies', project])
    coreCp = mx.classpath([project])

    jdk = mx.get_jdk(tag='default')

    java_args = mx.get_runtime_jvm_args(project, coreCp, jdk=jdk)
    java_args += [mainClass]
    if args.archive:
        java_args.append('--archive=' + args.archive)
    if args.port:
        java_args.append('--port=' + args.port)
    if args.no_browse:
        java_args.append('--no-browse')
    java_args.append(args.root)
    mx.run_java(java_args, jdk=jdk)
Exemple #20
0
def testdownstream(args):
    """test downstream users of the Truffle API"""
    jruby_dir = "jruby"
    jruby_repo = "https://github.com/jruby/jruby.git"
    jruby_branch = "truffle-head"
    git = mx.GitConfig()
    if os.path.exists("jruby"):
        git.run(["git", "reset", "HEAD", "--hard"], nonZeroIsFatal=True, cwd=jruby_dir)
        git.pull("jruby")
    else:
        git.clone(jruby_repo, jruby_dir)
        git.run(["git", "checkout", jruby_branch], nonZeroIsFatal=True, cwd=jruby_dir)
    dev_version = _suite.release_version(snapshotSuffix="SNAPSHOT")
    subprocess.check_call(["tool/truffle/set_truffle_version.sh", dev_version], cwd=jruby_dir)
    mx.build([])
    mx.maven_install([])
    subprocess.check_call(["./mvnw", "clean"], cwd=jruby_dir)
    subprocess.check_call(["./mvnw"], cwd=jruby_dir)
    subprocess.check_call(["bin/jruby", "tool/jt.rb", "test", "fast"], cwd=jruby_dir)
Exemple #21
0
def wikidoc(args):
    """generate Confluence Wiki format for package-info.java files"""

    # Ensure the wiki doclet is up to date
    mx.build(['--projects', 'com.oracle.max.tools'])

    # the WikiDoclet cannot see the -classpath argument passed to javadoc so we pass the
    # full list of projects as an explicit argument, thereby enabling it to map classes
    # to projects, which is needed to generate Wiki links to the source code.
    # There is no virtue in running the doclet on dependent projects as there are
    # no generated links between Wiki pages
    toolsDir = mx.project('com.oracle.max.tools').output_dir()
    baseDir = mx.project('com.oracle.max.base').output_dir()
    dp = os.pathsep.join([toolsDir, baseDir])
    project_list = ','.join(p.name for p in mx.sorted_deps())
    for a in ['-docletpath', dp, '-doclet', 'com.oracle.max.tools.javadoc.wiki.WikiDoclet', '-projects', project_list]:
        args.append('--arg')
        args.append('@' + a)

    mx.javadoc(args, parser=ArgumentParser('mx wikidoc'), docDir='wikidoc', includeDeps=False, stdDoclet=False)
Exemple #22
0
def _find_classes_by_annotated_methods(annotations, dists, jdk=None):
    if len(dists) == 0:
        return {}

    candidates = {}

    # Create map from jar file to the binary suite distribution defining it
    jarsToDists = {d.classpath_repr(): d for d in dists}

    primarySuite = mx.primary_suite()
    cachesDir = None
    jarsToParse = []
    if primarySuite and primarySuite != mx._mx_suite:
        cachesDir = mx.ensure_dir_exists(join(primarySuite.get_output_root(), 'unittest'))
        for d in dists:
            jar = d.classpath_repr()
            testclasses = _read_cached_testclasses(cachesDir, jar)
            if testclasses is not None:
                for classname in testclasses:
                    candidates[classname] = jarsToDists[jar]
            else:
                jarsToParse.append(jar)

    if jarsToParse:
        # Ensure Java support class is built
        mx.build(['--no-daemon', '--dependencies', 'com.oracle.mxtool.junit'])

        cp = mx.classpath(['com.oracle.mxtool.junit'] + jarsToDists.values(), jdk=jdk)
        out = mx.LinesOutputCapture()
        mx.run_java(['-cp', cp, 'com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] + annotations + jarsToParse, out=out, addDefaultArgs=False)

        for line in out.lines:
            parts = line.split(' ')
            jar = parts[0]
            testclasses = parts[1:] if len(parts) > 1 else []
            if cachesDir:
                _write_cached_testclasses(cachesDir, jar, testclasses)
            for classname in testclasses:
                candidates[classname] = jarsToDists[jar]
    return candidates
Exemple #23
0
def _find_classes_by_annotated_methods(annotations, dists, jdk=None):
    if len(dists) == 0:
        return {}

    candidates = {}
    # Ensure Java support class is built
    mx.build(['--dependencies', 'com.oracle.mxtool.junit'])
    # Create map from jar file to the binary suite distribution defining it
    jars = {d.classpath_repr(): d for d in dists}
    cp = mx.classpath(['com.oracle.mxtool.junit'] + [d.name for d in dists],
                      jdk=jdk)
    out = mx.OutputCapture()
    mx.run_java(
        ['-cp', cp, 'com.oracle.mxtool.junit.FindClassesByAnnotatedMethods'] +
        annotations + jars.keys(),
        out=out,
        addDefaultArgs=False)
    for line in out.data.strip().split('\n'):
        name, jar = line.split(' ')
        # Record class name to the binary suite distribution containing it
        candidates[name] = jars[jar]
    return candidates
Exemple #24
0
def nativebuild(args):
    '''
    force the build of part or all of the native project
    '''
    parser = ArgumentParser(prog='nativebuild')
    parser.add_argument('--all', action='store_true', help='clean and build everything, else just ffi')
    args = parser.parse_args(args)
    nativedir = mx.project('com.oracle.truffle.r.native').dir
    if args.all:
        return subprocess.call(['make clean && make'], shell=True, cwd=nativedir)
    else:
        ffidir = join(nativedir, 'fficall')
        jni_done = join(ffidir, 'jni.done')
        jniboot_done = join(ffidir, 'jniboot.done')
        if os.path.exists(jni_done):
            os.remove(jni_done)
        if os.path.exists(jniboot_done):
            os.remove(jniboot_done)
        return mx.build(['--no-java'])
Exemple #25
0
def nativebuild(args):
    '''
    force the build of part or all of the native project
    '''
    parser = ArgumentParser(prog='nativebuild')
    parser.add_argument('--all', action='store_true', help='clean and build everything, else just ffi')
    args = parser.parse_args(args)
    nativedir = mx.project('com.oracle.truffle.r.native').dir
    if args.all:
        return subprocess.call(['make clean && make'], shell=True, cwd=nativedir)
    else:
        ffidir = join(nativedir, 'fficall')
        jni_done = join(ffidir, 'jni.done')
        jniboot_done = join(ffidir, 'jniboot.done')
        if os.path.exists(jni_done):
            os.remove(jni_done)
        if os.path.exists(jniboot_done):
            os.remove(jniboot_done)
        return mx.build(['--no-java'])
Exemple #26
0
def _unittest(args,
              annotations,
              prefixCp="",
              blacklist=None,
              whitelist=None,
              verbose=False,
              very_verbose=False,
              fail_fast=False,
              enable_timing=False,
              regex=None,
              color=False,
              eager_stacktrace=False,
              gc_after_test=False,
              suite=None):
    testfile = os.environ.get('MX_TESTFILE', None)
    if testfile is None:
        (_, testfile) = tempfile.mkstemp(".testclasses", "mxtool")
        os.close(_)

    mainClass = 'com.oracle.mxtool.junit.MxJUnitWrapper'
    if not exists(
            join(
                mx.project('com.oracle.mxtool.junit').output_dir(),
                mainClass.replace('.', os.sep) + '.class')):
        mx.build(['--only', 'com.oracle.mxtool.junit'])
    coreCp = mx.classpath(['com.oracle.mxtool.junit'])

    coreArgs = []
    if very_verbose:
        coreArgs.append('-JUnitVeryVerbose')
    elif verbose:
        coreArgs.append('-JUnitVerbose')
    if fail_fast:
        coreArgs.append('-JUnitFailFast')
    if enable_timing:
        coreArgs.append('-JUnitEnableTiming')
    if color:
        coreArgs.append('-JUnitColor')
    if eager_stacktrace:
        coreArgs.append('-JUnitEagerStackTrace')
    if gc_after_test:
        coreArgs.append('-JUnitGCAfterTest')

    def harness(unittestCp, vmLauncher, vmArgs):
        prefixArgs = ['-esa', '-ea']
        if gc_after_test:
            prefixArgs.append('-XX:-DisableExplicitGC')
        with open(testfile) as fp:
            testclasses = [l.rstrip() for l in fp.readlines()]

        cp = prefixCp + coreCp + os.pathsep + unittestCp

        # suppress menubar and dock when running on Mac
        vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs + [
            '-cp', mx._separatedCygpathU2W(cp)
        ]
        # Execute Junit directly when one test is being run. This simplifies
        # replaying the VM execution in a native debugger (e.g., gdb).
        mainClassArgs = coreArgs + (testclasses if len(testclasses) == 1 else
                                    ['@' + mx._cygpathU2W(testfile)])

        config = (vmArgs, mainClass, mainClassArgs)
        for p in _config_participants:
            config = p(config)

        vmLauncher.launcher(*config)

    vmLauncher = _vm_launcher
    if vmLauncher is None:
        jdk = mx.get_jdk()

        def _run_vm(vmArgs, mainClass, mainClassArgs):
            mx.run_java(vmArgs + [mainClass] + mainClassArgs, jdk=jdk)

        vmLauncher = _VMLauncher('default VM launcher', _run_vm, jdk)

    try:
        _run_tests(args, harness, vmLauncher, annotations, testfile, blacklist,
                   whitelist, regex,
                   mx.suite(suite) if suite else None)
    finally:
        if os.environ.get('MX_TESTFILE') is None:
            os.remove(testfile)
Exemple #27
0
def _unittest(
    args,
    annotations,
    prefixCp="",
    blacklist=None,
    whitelist=None,
    verbose=False,
    fail_fast=False,
    enable_timing=False,
    regex=None,
    color=False,
    eager_stacktrace=False,
    gc_after_test=False,
    suite=None,
):
    testfile = os.environ.get("MX_TESTFILE", None)
    if testfile is None:
        (_, testfile) = tempfile.mkstemp(".testclasses", "mxtool")
        os.close(_)

    mainClass = "com.oracle.mxtool.junit.MxJUnitWrapper"
    if not exists(join(mx.project("com.oracle.mxtool.junit").output_dir(), mainClass.replace(".", os.sep) + ".class")):
        mx.build(["--only", "com.oracle.mxtool.junit"])
    coreCp = mx.classpath(["com.oracle.mxtool.junit"])

    coreArgs = []
    if verbose:
        coreArgs.append("-JUnitVerbose")
    if fail_fast:
        coreArgs.append("-JUnitFailFast")
    if enable_timing:
        coreArgs.append("-JUnitEnableTiming")
    if color:
        coreArgs.append("-JUnitColor")
    if eager_stacktrace:
        coreArgs.append("-JUnitEagerStackTrace")
    if gc_after_test:
        coreArgs.append("-JUnitGCAfterTest")

    def harness(projectsCp, vmLauncher, vmArgs):
        prefixArgs = ["-esa", "-ea"]
        if gc_after_test:
            prefixArgs.append("-XX:-DisableExplicitGC")
        with open(testfile) as fp:
            testclasses = [l.rstrip() for l in fp.readlines()]

        cp = prefixCp + coreCp + os.pathsep + projectsCp

        # suppress menubar and dock when running on Mac
        vmArgs = prefixArgs + ["-Djava.awt.headless=true"] + vmArgs + ["-cp", mx._separatedCygpathU2W(cp)]
        # Execute Junit directly when one test is being run. This simplifies
        # replaying the VM execution in a native debugger (e.g., gdb).
        mainClassArgs = coreArgs + (testclasses if len(testclasses) == 1 else ["@" + mx._cygpathU2W(testfile)])

        config = (vmArgs, mainClass, mainClassArgs)
        for p in _config_participants:
            config = p(config)

        _, launcher = vmLauncher
        launcher(*config)

    vmLauncher = _vm_launcher
    if vmLauncher is None:
        vmLauncher = (
            "default VM launcher",
            lambda vmArgs, mainClass, mainClassArgs: mx.run_java(vmArgs + [mainClass] + mainClassArgs),
        )

    try:
        _run_tests(
            args,
            harness,
            vmLauncher,
            annotations,
            testfile,
            blacklist,
            whitelist,
            regex,
            mx.suite(suite) if suite else None,
        )
    finally:
        if os.environ.get("MX_TESTFILE") is None:
            os.remove(testfile)
Exemple #28
0
def build(args):
    for i in args:
        if i == '-h' or i == '-help' or i == '--help':
            print '"for help run mx :build -h"'
            return
    mx.build(['--warning-as-error'] + args)
Exemple #29
0
def build(args, vm=None):
    """build the Java sources"""
    opts2 = mx.build(['--source', '1.7'] + args)
    assert len(opts2.remainder) == 0
Exemple #30
0
def copycheck(args):
    """run copyright check on the Maxine sources (defined as being under hg control)"""
    mx.build(['--projects', 'com.oracle.max.base'])
    mx.run_java(['-cp', mx.classpath('com.oracle.max.base', resolve=False), 'com.sun.max.tools.CheckCopyright'] + args)
Exemple #31
0
def nativebuild(args):
    mx.build([
        "--only",
        "com.oracle.graal.python.cext,GRAALPYTHON,GRAALPYTHON_GRAALVM_SUPPORT"
    ])
def nativebuild(args):
    "Build the non-Java Python projects and archives"
    mx.build(["--only", ",".join(PYTHON_NATIVE_PROJECTS + PYTHON_ARCHIVES)])
    mx.archive(["@" + a for a in PYTHON_ARCHIVES])
Exemple #33
0
 def build(self, args):
     return mx.build(args)
Exemple #34
0
def build(args, vm=None):
    """build the Java sources"""
    opts2 = mx.build(['--source', '1.7'] + args)
    assert len(opts2.remainder) == 0
Exemple #35
0
def build(args, vm=None):
    """build the Java sources"""
    opts2 = mx.build(["--source", "1.7"] + args)
    assert len(opts2.remainder) == 0
Exemple #36
0
def nativebuild(args):
    mx.build(["--only", "com.oracle.graal.python.cext"])