Skip to content

Commit

Permalink
[GR-47917] Add --force-classpath option to mx unittest to test usage …
Browse files Browse the repository at this point in the history
…from classpath.

PullRequest: mx/1661
  • Loading branch information
chumer committed Aug 16, 2023
2 parents 7cf3088 + 7c47286 commit 137fb07
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
12 changes: 6 additions & 6 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },

"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+34-jvmci-23.1-b12", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+34-jvmci-23.1-b12-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+34-jvmci-23.1-b12-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21+34-jvmci-23.1-b12", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+34-jvmci-23.1-b12-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+34-jvmci-23.1-b12-sulong", "platformspecific": true },
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b13", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b13-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b13-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b13", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b13-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b13-sulong", "platformspecific": true },

"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
},
Expand Down
27 changes: 14 additions & 13 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -12659,7 +12659,7 @@ def classpath(names=None, resolve=True, includeSelf=True, includeBootClasspath=F
return _entries_to_classpath(cpEntries=cpEntries, resolve=resolve, includeBootClasspath=includeBootClasspath, jdk=jdk, unique=unique, ignoreStripped=ignoreStripped)


def get_runtime_jvm_args(names=None, cp_prefix=None, cp_suffix=None, jdk=None, exclude_names=None):
def get_runtime_jvm_args(names=None, cp_prefix=None, cp_suffix=None, jdk=None, exclude_names=None, force_cp=False):
"""
Get the VM arguments (e.g. classpath and system properties) for a list of named projects and
distributions. If 'names' is None, then all registered dependencies are used. 'exclude_names'
Expand All @@ -12673,17 +12673,18 @@ def get_runtime_jvm_args(names=None, cp_prefix=None, cp_suffix=None, jdk=None, e

mp_entries_set = set()
mp_entries = []
for entry in entries:
if entry.isClasspathDependency() and entry.use_module_path():
if entry.get_declaring_module_name() and entry not in mp_entries_set:
mp_entries.append(entry)
mp_entries_set.add(entry)
# if a distribution is a module put all dependencies
# on the module path as well.
for mp_entry in classpath_entries(names=[entry]):
if mp_entry in entries and mp_entry not in mp_entries_set:
mp_entries.append(mp_entry)
mp_entries_set.add(mp_entry)
if not force_cp:
for entry in entries:
if entry.isClasspathDependency() and entry.use_module_path():
if entry.get_declaring_module_name() and entry not in mp_entries_set:
mp_entries.append(entry)
mp_entries_set.add(entry)
# if a distribution is a module put all dependencies
# on the module path as well.
for mp_entry in classpath_entries(names=[entry]):
if mp_entry in entries and mp_entry not in mp_entries_set:
mp_entries.append(mp_entry)
mp_entries_set.add(mp_entry)
if mp_entries:
cp_entries = [e for e in entries if e not in mp_entries_set]
else:
Expand Down Expand Up @@ -18614,7 +18615,7 @@ def alarm_handler(signum, frame):
abort(1, killsig=signal.SIGINT)

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("6.41.0") # Added noMavenSources, forbidding uploading source code to the maven repository.
version = VersionSpec("6.42.0") # Added support for mx unittest --force-classpath

_mx_start_datetime = datetime.utcnow()
_last_timestamp = _mx_start_datetime
Expand Down
4 changes: 3 additions & 1 deletion mx_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def harness(unittestDeps, vmLauncher, vmArgs):
prefixArgs.append('-XX:-DisableExplicitGC')

jdk = vmLauncher.jdk()
vmArgs += mx.get_runtime_jvm_args(unittestDeps, cp_prefix=prefixCp+coreCp, jdk=jdk)
force_cp = '-JUnitForceClassPath' in junit_args
vmArgs += mx.get_runtime_jvm_args(unittestDeps, cp_prefix=prefixCp+coreCp, jdk=jdk, force_cp=force_cp)

# suppress menubar and dock when running on Mac
vmArgs = prefixArgs + ['-Djava.awt.headless=true'] + vmArgs
Expand Down Expand Up @@ -531,6 +532,7 @@ def __call__(self, parser, namespace, values, option_string=None):
parser.add_argument('--blacklist', help='run all testcases not specified in <file>', metavar='<file>')
parser.add_argument('--whitelist', help='run testcases specified in <file> only', metavar='<file>')
parser.add_argument('--verbose', help='enable verbose JUnit output', dest='JUnitVerbose', action=MxJUnitWrapperBoolArg)
parser.add_argument('--force-classpath', help='forces all jars on the classpath', dest='JUnitForceClassPath', action=MxJUnitWrapperBoolArg)
parser.add_argument('--very-verbose', help='enable very verbose JUnit output', dest='JUnitVeryVerbose', action=MxJUnitWrapperBoolArg)
parser.add_argument('--max-class-failures', help='stop after N test classes that have a failure (default is no limit)', type=is_strictly_positive, metavar='<N>', dest='JUnitMaxClassFailures', action=MxJUnitWrapperArg)
parser.add_argument('--fail-fast', help='alias for --max-class-failures=1', dest='JUnitFailFast', action=MxJUnitWrapperBoolArg)
Expand Down

0 comments on commit 137fb07

Please sign in to comment.