diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2018-01-22 11:11:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-22 11:11:30 -0800 |
commit | 256d12a38d9846ffb3ab859a5de360d94f276ba1 (patch) | |
tree | ca65cc562c12729ef1d0648fad3099559ec32f61 | |
parent | ecfe848cf1edb218f9b635e41693eae43fd076b6 (diff) | |
parent | 13b6b8f628a6be3c5890d739549c31f67db4580d (diff) | |
download | coreclr-256d12a38d9846ffb3ab859a5de360d94f276ba1.tar.gz coreclr-256d12a38d9846ffb3ab859a5de360d94f276ba1.tar.bz2 coreclr-256d12a38d9846ffb3ab859a5de360d94f276ba1.zip |
Merge pull request #15944 from BruceForstall/CorefxTestUseCorrectVersion
For corefx testing, use a matching corefx repo version git hash
-rwxr-xr-x | netci.groovy | 15 | ||||
-rw-r--r-- | tests/scripts/run-corefx-tests.py | 53 |
2 files changed, 61 insertions, 7 deletions
diff --git a/netci.groovy b/netci.groovy index 9979bcf0ab..ce8f9c0075 100755 --- a/netci.groovy +++ b/netci.groovy @@ -1645,7 +1645,12 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR } if (enableCorefxTesting) { - buildOpts += ' skiptests'; + // We shouldn't need to build the tests. However, run-corefx-tests.py currently depends on having the restored corefx + // package available, to determine the correct corefx version git commit hash, and we need to build the tests before + // running "tests\\runtest.cmd GenerateLayoutOnly". So build the pri-0 tests to make this happen. + // + // buildOpts += ' skiptests'; + buildOpts += " -priority=0" } else { buildOpts += " -priority=${priority}" } @@ -1743,6 +1748,10 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR runtestArguments = "${lowerConfiguration} ${arch} ${testOpts}" if (enableCorefxTesting) { + // Generate the test layout because it restores the corefx package which allows run-corefx-tests.py + // to determine the correct matching corefx version git commit hash. + buildCommands += "tests\\runtest.cmd ${runtestArguments} GenerateLayoutOnly" + def workspaceRelativeFxRoot = "_/fx" def absoluteFxRoot = "%WORKSPACE%\\_\\fx" @@ -1911,6 +1920,10 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR // Build coreclr buildCommands += "./build.sh verbose ${lowerConfiguration} ${architecture}" + // Generate the test layout, which restores the corefx package, and allows run-corefx-tests.py to determine the + // matching corefx version git commit hash. + buildCommands += "./build-test.sh ${architecture} ${lowerConfiguration} generatelayoutonly" + def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh" def envScriptCmds = envScriptCreate(os, scriptFileName) diff --git a/tests/scripts/run-corefx-tests.py b/tests/scripts/run-corefx-tests.py index ba49631e1c..99daf940b5 100644 --- a/tests/scripts/run-corefx-tests.py +++ b/tests/scripts/run-corefx-tests.py @@ -120,9 +120,6 @@ def validate_args(args): validate_arg(build_type, lambda item: item in valid_build_types) validate_arg(fx_branch, lambda item: True) - if fx_commit is None: - fx_commit = 'HEAD' - if clr_root is None: clr_root = nth_dirname(os.path.abspath(sys.argv[0]), 3) else: @@ -198,6 +195,53 @@ def main(args): 'Product', '%s.%s.%s' % (clr_os, arch, build_type)) + # 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.: + # 197a0699b08087ea85581679afdd9fd7b5c465c3 + # 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 https://github.com/dotnet/buildtools/issues/1141. + + if fx_commit is None: + # Default to 'HEAD'; overwrite if we find an actual commit hash. + fx_commit = 'HEAD' + try: + dependencies_filename = os.path.join(clr_root, 'dependencies.props') + if os.path.isfile(dependencies_filename): + with open(dependencies_filename, 'r') as dependencies_file_handle: + dependencies_file = dependencies_file_handle.read() + matchObj = re.search(r'.*<MicrosoftPrivateCoreFxNETCoreAppPackageVersion>(.+)</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>.*', dependencies_file) + if matchObj: + package_version_string = matchObj.group(1) + version_filename = os.path.join(clr_root, 'packages', 'microsoft.private.corefx.netcoreapp', package_version_string, 'version.txt') + if os.path.isfile(version_filename): + with open(version_filename, 'r') as f: + version_file = f.readlines() + fx_commit = version_file[0].strip() + log("Using matching corefx commit hash: %s" % fx_commit) + except: + log("Failed to find matching corefx commit hash") + + if fx_commit == 'HEAD': + log("Using default corefx commit hash: HEAD") + # corefx creates both files that are read-only and files that include non-ascii # characters. Using onerror=del_rw allows us to delete all of the read-only files. # To delete the files with non-ascii characters, when rmtree fails due to those @@ -250,9 +294,6 @@ def main(args): os.putenv('HOME', fx_home) log('HOME=' + fx_home) - # Determine the RID to specify the to corefix build scripts. This seems to - # be way harder than it ought to be. - # Gather up some arguments to pass to both build and build-tests. config_args = '-Release -os:%s -buildArch:%s' % (clr_os, arch) |