Skip to content

Commit

Permalink
Allow multiple JDKs in smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvodita committed Feb 15, 2024
1 parent c700424 commit 678dd65
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions dev-tools/scripts/smokeTestRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,14 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
java.run_java17('./gradlew --no-daemon jar -Dversion.release=%s' % version, '%s/compile.log' % unpackPath)
testDemo(java.run_java17, isSrc, version, '17')

if java.run_alt_javas:
for run_alt_java in java.run_alt_javas:
print(" run tests w/ Java ?? and testArgs='%s'..." % testArgs)
run_alt_java('./gradlew --no-daemon test %s' % testArgs, '%s/test.log' % unpackPath)
print(" compile jars w/ Java ??")
run_alt_java('./gradlew --no-daemon jar -Dversion.release=%s' % version, '%s/compile.log' % unpackPath)
testDemo(run_alt_java, isSrc, version, '??')

print(' confirm all releases have coverage in TestBackwardsCompatibility')
confirmAllReleasesAreTestedForBackCompat(version, unpackPath)

Expand All @@ -636,6 +644,9 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
testDemo(java.run_java11, isSrc, version, '11')
if java.run_java17:
testDemo(java.run_java17, isSrc, version, '17')
if java.run_alt_javas:
for run_alt_java in java.run_alt_javas:
testDemo(run_alt_java, isSrc, version, '??')

testChangesText('.', version)

Expand Down Expand Up @@ -911,7 +922,7 @@ def crawl(downloadedFiles, urlString, targetDir, exclusions=set()):
sys.stdout.write('.')


def make_java_config(parser, java17_home):
def make_java_config(parser, java17_home, alt_java_homes):
def _make_runner(java_home, version):
print('Java %s JAVA_HOME=%s' % (version, java_home))
if cygwin:
Expand All @@ -920,24 +931,34 @@ def _make_runner(java_home, version):
(java_home, java_home, java_home)
s = subprocess.check_output('%s; java -version' % cmd_prefix,
shell=True, stderr=subprocess.STDOUT).decode('utf-8')
if s.find(' version "%s' % version) == -1:
# TODO: Print actual version when provided version is None
if version is not None and s.find(' version "%s' % version) == -1:
parser.error('got wrong version for java %s:\n%s' % (version, s))

def run_java(cmd, logfile):
run('%s; %s' % (cmd_prefix, cmd), logfile)

return run_java

java11_home = os.environ.get('JAVA_HOME')
if java11_home is None:
parser.error('JAVA_HOME must be set')
run_java11 = _make_runner(java11_home, '11')
run_java17 = None
if java17_home is not None:
run_java17 = _make_runner(java17_home, '17')
run_alt_javas = []
if alt_java_homes:
for alt_java_home in alt_java_homes:
run_alt_java = _make_runner(alt_java_home, None)
run_alt_javas.append(run_alt_java)

jc = namedtuple('JavaConfig', 'run_java11 java11_home run_java17 java17_home')
return jc(run_java11, java11_home, run_java17, java17_home)
jc = namedtuple('JavaConfig', 'run_java11 java11_home run_java17 java17_home run_alt_javas alt_java_homes')
return jc(run_java11, java11_home, run_java17, java17_home, run_alt_javas, alt_java_homes)

version_re = re.compile(r'(\d+\.\d+\.\d+(-ALPHA|-BETA)?)')
revision_re = re.compile(r'rev-([a-f\d]+)')

def parse_config():
epilogue = textwrap.dedent('''
Example usage:
Expand All @@ -958,6 +979,8 @@ def parse_config():
help='Version of the release, defaults to that in URL')
parser.add_argument('--test-java17', metavar='java17_home',
help='Path to Java17 home directory, to run tests with if specified')
parser.add_argument('--test-alternative-java', action='append',
help='Path to alternative Java home directory, to run tests with if specified')
parser.add_argument('--download-only', action='store_true', default=False,
help='Only perform download and sha hash check steps')
parser.add_argument('url', help='Url pointing to release to test')
Expand All @@ -984,7 +1007,7 @@ def parse_config():
if c.local_keys is not None and not os.path.exists(c.local_keys):
parser.error('Local KEYS file "%s" not found' % c.local_keys)

c.java = make_java_config(parser, c.test_java17)
c.java = make_java_config(parser, c.test_java17, c.test_alternative_java)

if c.tmp_dir:
c.tmp_dir = os.path.abspath(c.tmp_dir)
Expand Down

0 comments on commit 678dd65

Please sign in to comment.