Skip to content

Commit

Permalink
Check return code of bootstrap script in format.py. (#32581)
Browse files Browse the repository at this point in the history
Formatting jobs run format.py script, which calls bootstrap.{cmd/sh}
from jitutils. This change adds a check for return code of the call and
returns an error code from format.py if bootstrap.{cmd/sh} failed.
  • Loading branch information
erozenfeld authored Feb 20, 2020
1 parent b709d30 commit cf43585
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/coreclr/tests/scripts/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def del_rw(action, name, exc):
os.chmod(name, 0o651)
os.remove(name)

def cleanup(jitUtilsPath, bootstrapPath):
if os.path.isdir(jitUtilsPath):
print("Deleting " + jitUtilsPath)
shutil.rmtree(jitUtilsPath, onerror=del_rw)

if os.path.isfile(bootstrapPath):
print("Deleting " + bootstrapPath)
os.remove(bootstrapPath)

def main(argv):
parser = argparse.ArgumentParser()
required = parser.add_argument_group('required arguments')
Expand Down Expand Up @@ -103,9 +112,7 @@ def main(argv):

jitUtilsPath = os.path.join(coreclr, "jitutils")

if os.path.isdir(jitUtilsPath):
print("Deleting " + jitUtilsPath)
shutil.rmtree(jitUtilsPath, onerror=del_rw)
cleanup(jitUtilsPath, '')

if platform == 'Linux' or platform == 'OSX':
bootstrapFilename = "bootstrap.sh"
Expand Down Expand Up @@ -156,6 +163,11 @@ def main(argv):
proc = subprocess.Popen([bootstrapPath], env=my_env)
output,error = proc.communicate()

if proc.returncode != 0:
cleanup('', bootstrapPath)
print("Bootstrap failed")
return -1

# Run jit-format

returncode = 0
Expand Down Expand Up @@ -212,13 +224,7 @@ def main(argv):
proc = subprocess.Popen(["git", "diff", "--patch", "-U20", "--", jitSrcPath], env=my_env, stdout=patchFile)
output,error = proc.communicate()

if os.path.isdir(jitUtilsPath):
print("Deleting " + jitUtilsPath)
shutil.rmtree(jitUtilsPath, onerror=del_rw)

if os.path.isfile(bootstrapPath):
print("Deleting " + bootstrapPath)
os.remove(bootstrapPath)
cleanup(jitUtilsPath, bootstrapPath)

if returncode != 0:
print("There were errors in formatting. Please run jit-format locally with: \n")
Expand Down

0 comments on commit cf43585

Please sign in to comment.