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

Commit 9612440

Browse files
committed
For corefx testing, use a matching corefx repo version git hash
If the user doesn't specify a specific corefx commit hash to use, try to find the matching commit hash in the coreclr repro. If the matching hash can't be found, use 'HEAD'. We find the matching corefx commit hash by first parsing file 'dependencies.props' at the root of the coreclr repro, looking for this: <MicrosoftPrivateCoreFxNETCoreAppPackageVersion>4.5.0-preview1-26112-01</MicrosoftPrivateCoreFxNETCoreAppPackageVersion> This determines the corefx package version that matches. Next, we look for the version.txt file in the package cache, e.g., <coreclr_root>\packages\microsoft.private.corefx.netcoreapp\4.5.0-preview1-26112-01\version.txt The contents of this file is exactly the git commit hash we need to use, e.g.: 197a069 The version.txt file is created when the corefx package is restored, which happens when doing one of: Windows: tests\runtests.cmd GenerateLayoutOnly non-Windows: build-test.sh generatelayoutonly It would also be possible to not depend on the package already being downloaded, but instead download the correct package here, using the determined "MicrosoftPrivateCoreFxNETCoreAppPackageVersion" package version, e.g.: https://dotnet.myget.org/F/dotnet-core/api/v2/package/Microsoft.Private.CoreFx.NETCoreApp/4.5.0-preview1-26112-01 and then extracting the ZIP archive to find the version.txt file. This might get easier if the corefx commit hash is added directly to dependencies.props, as discussed in dotnet/buildtools#1141.
1 parent 19cdca1 commit 9612440

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

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)