Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 256d12a

Browse files
Merge pull request #15944 from BruceForstall/CorefxTestUseCorrectVersion
For corefx testing, use a matching corefx repo version git hash
2 parents ecfe848 + 13b6b8f commit 256d12a

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

netci.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,12 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
16451645
}
16461646

16471647
if (enableCorefxTesting) {
1648-
buildOpts += ' skiptests';
1648+
// We shouldn't need to build the tests. However, run-corefx-tests.py currently depends on having the restored corefx
1649+
// package available, to determine the correct corefx version git commit hash, and we need to build the tests before
1650+
// running "tests\\runtest.cmd GenerateLayoutOnly". So build the pri-0 tests to make this happen.
1651+
//
1652+
// buildOpts += ' skiptests';
1653+
buildOpts += " -priority=0"
16491654
} else {
16501655
buildOpts += " -priority=${priority}"
16511656
}
@@ -1743,6 +1748,10 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
17431748
runtestArguments = "${lowerConfiguration} ${arch} ${testOpts}"
17441749

17451750
if (enableCorefxTesting) {
1751+
// Generate the test layout because it restores the corefx package which allows run-corefx-tests.py
1752+
// to determine the correct matching corefx version git commit hash.
1753+
buildCommands += "tests\\runtest.cmd ${runtestArguments} GenerateLayoutOnly"
1754+
17461755
def workspaceRelativeFxRoot = "_/fx"
17471756
def absoluteFxRoot = "%WORKSPACE%\\_\\fx"
17481757

@@ -1911,6 +1920,10 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR
19111920
// Build coreclr
19121921
buildCommands += "./build.sh verbose ${lowerConfiguration} ${architecture}"
19131922

1923+
// Generate the test layout, which restores the corefx package, and allows run-corefx-tests.py to determine the
1924+
// matching corefx version git commit hash.
1925+
buildCommands += "./build-test.sh ${architecture} ${lowerConfiguration} generatelayoutonly"
1926+
19141927
def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh"
19151928

19161929
def envScriptCmds = envScriptCreate(os, scriptFileName)

tests/scripts/run-corefx-tests.py

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ def validate_arg(arg, check):
120120
validate_arg(build_type, lambda item: item in valid_build_types)
121121
validate_arg(fx_branch, lambda item: True)
122122

123-
if fx_commit is None:
124-
fx_commit = 'HEAD'
125-
126123
if clr_root is None:
127124
clr_root = nth_dirname(os.path.abspath(sys.argv[0]), 3)
128125
else:
@@ -198,6 +195,53 @@ def main(args):
198195
'Product',
199196
'%s.%s.%s' % (clr_os, arch, build_type))
200197

198+
# If the user doesn't specify a specific corefx commit hash to use, try to find the matching
199+
# commit hash in the coreclr repro. If the matching hash can't be found, use 'HEAD'.
200+
#
201+
# We find the matching corefx commit hash by first parsing file 'dependencies.props' at the root
202+
# of the coreclr repro, looking for this:
203+
# <MicrosoftPrivateCoreFxNETCoreAppPackageVersion>4.5.0-preview1-26112-01</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>
204+
# This determines the corefx package version that matches. Next, we look for the version.txt
205+
# file in the package cache, e.g.,
206+
# <coreclr_root>\packages\microsoft.private.corefx.netcoreapp\4.5.0-preview1-26112-01\version.txt
207+
# The contents of this file is exactly the git commit hash we need to use, e.g.:
208+
# 197a0699b08087ea85581679afdd9fd7b5c465c3
209+
# The version.txt file is created when the corefx package is restored, which happens when doing one of:
210+
# Windows: tests\runtests.cmd GenerateLayoutOnly
211+
# non-Windows: build-test.sh generatelayoutonly
212+
#
213+
# It would also be possible to not depend on the package already being downloaded, but instead
214+
# download the correct package here, using the determined "MicrosoftPrivateCoreFxNETCoreAppPackageVersion"
215+
# package version, e.g.:
216+
# https://dotnet.myget.org/F/dotnet-core/api/v2/package/Microsoft.Private.CoreFx.NETCoreApp/4.5.0-preview1-26112-01
217+
# and then extracting the ZIP archive to find the version.txt file.
218+
#
219+
# This might get easier if the corefx commit hash is added directly to dependencies.props, as
220+
# discussed in https://github.com/dotnet/buildtools/issues/1141.
221+
222+
if fx_commit is None:
223+
# Default to 'HEAD'; overwrite if we find an actual commit hash.
224+
fx_commit = 'HEAD'
225+
try:
226+
dependencies_filename = os.path.join(clr_root, 'dependencies.props')
227+
if os.path.isfile(dependencies_filename):
228+
with open(dependencies_filename, 'r') as dependencies_file_handle:
229+
dependencies_file = dependencies_file_handle.read()
230+
matchObj = re.search(r'.*<MicrosoftPrivateCoreFxNETCoreAppPackageVersion>(.+)</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>.*', dependencies_file)
231+
if matchObj:
232+
package_version_string = matchObj.group(1)
233+
version_filename = os.path.join(clr_root, 'packages', 'microsoft.private.corefx.netcoreapp', package_version_string, 'version.txt')
234+
if os.path.isfile(version_filename):
235+
with open(version_filename, 'r') as f:
236+
version_file = f.readlines()
237+
fx_commit = version_file[0].strip()
238+
log("Using matching corefx commit hash: %s" % fx_commit)
239+
except:
240+
log("Failed to find matching corefx commit hash")
241+
242+
if fx_commit == 'HEAD':
243+
log("Using default corefx commit hash: HEAD")
244+
201245
# corefx creates both files that are read-only and files that include non-ascii
202246
# characters. Using onerror=del_rw allows us to delete all of the read-only files.
203247
# To delete the files with non-ascii characters, when rmtree fails due to those
@@ -250,9 +294,6 @@ def main(args):
250294
os.putenv('HOME', fx_home)
251295
log('HOME=' + fx_home)
252296

253-
# Determine the RID to specify the to corefix build scripts. This seems to
254-
# be way harder than it ought to be.
255-
256297
# Gather up some arguments to pass to both build and build-tests.
257298

258299
config_args = '-Release -os:%s -buildArch:%s' % (clr_os, arch)

0 commit comments

Comments
 (0)