Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check return code of bootstrap script in format.py. #32581

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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