From: Michelle McDaniel Date: Tue, 8 Nov 2016 21:37:20 +0000 (-0800) Subject: Create patches in formatting job X-Git-Tag: submit/tizen/20210909.063632~11030^2~8919^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fc62184f696c7f84d34dc859bc8f7bd27dd1184;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Create patches in formatting job In the formatting job, if there are formatting errors, we will run the formatter in --fix mode and generate a patch which will be uploaded to azure storage. Commit migrated from https://github.com/dotnet/coreclr/commit/503de5e8dde3d996b06db41c0b46617cebbdee11 --- diff --git a/src/coreclr/netci.groovy b/src/coreclr/netci.groovy index 3bba51d..81d3ee7 100755 --- a/src/coreclr/netci.groovy +++ b/src/coreclr/netci.groovy @@ -1761,6 +1761,7 @@ combinedScenarios.each { scenario -> } else if (scenario == 'formatting') { buildCommands += "python -u tests\\scripts\\format.py -c %WORKSPACE% -o Windows_NT -a ${arch}" + Utilities.addArchival(newJob, "format.patch", "", true, false) break } else { @@ -1972,6 +1973,7 @@ combinedScenarios.each { scenario -> if (scenario == 'formatting') { buildCommands += "python tests/scripts/format.py -c \${WORKSPACE} -o Linux -a ${arch}" + Utilities.addArchival(newJob, "format.patch", "", true, false) break } diff --git a/src/coreclr/tests/scripts/format.py b/src/coreclr/tests/scripts/format.py index ae8348a..1cda283 100644 --- a/src/coreclr/tests/scripts/format.py +++ b/src/coreclr/tests/scripts/format.py @@ -202,8 +202,26 @@ def main(argv): errorMessage += " -c --verbose --fix --projects " + project +"\n" returncode = errorcode + # Fix mode doesn't return an error, so we have to run the build, then run with + # --fix to generate the patch. This means that it is likely only the first run + # of jit-format will return a formatting failure. + if errorcode == -2: + # If errorcode was -2, no need to run clang-tidy again + proc = subprocess.Popen([jitformat, "--fix", "--untidy", "-a", arch, "-b", build, "-o", platform, "-c", coreclr, "--verbose", "--projects", project], env=my_env) + output,error = proc.communicate() + else: + # Otherwise, must run both + proc = subprocess.Popen([jitformat, "--fix", "-a", arch, "-b", build, "-o", platform, "-c", coreclr, "--verbose", "--projects", project], env=my_env) + output,error = proc.communicate() + os.chdir(current_dir) + if returncode != 0: + # Create a patch file + patchFile = open("format.patch", "w") + proc = subprocess.Popen(["git", "diff", "--patch", "-U20"], env=my_env, stdout=patchFile) + output,error = proc.communicate() + if os.path.isdir(jitUtilsPath): print("Deleting " + jitUtilsPath) shutil.rmtree(jitUtilsPath, onerror=del_rw) @@ -217,8 +235,12 @@ def main(argv): os.remove(bootstrapPath) if returncode != 0: + buildUrl = my_env["BUILD_URL"] print("There were errors in formatting. Please run jit-format locally with: \n") print(errorMessage) + print("\nOr download and apply generated patch:") + print("wget " + buildUrl + "artifacts/format.patch") + print("git apply format.patch") return returncode