Skip to content

Commit 6648b77

Browse files
Handling switch back
1 parent 2939a3e commit 6648b77

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bolt/utils/nfc-check-setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,7 @@ def main():
138138
shlex.split("cmake --build . --target llvm-bolt"), cwd=args.build_dir
139139
)
140140

141-
# rename llvm-bolt
142-
if not os.path.exists(bolt_path):
143-
sys.exit(f"Failed to build the previous revision: '{bolt_path}'")
144-
os.replace(bolt_path, f"{bolt_path}.old")
145-
141+
# A build error may have occurred, so switch back before renaming.
146142
if args.switch_back:
147143
if stash:
148144
subprocess.run(shlex.split("git stash pop"), cwd=source_dir)
@@ -153,6 +149,12 @@ def main():
153149
f"to {new_ref}. Local changes were stashed. Switch back using\n\t"
154150
f"git checkout {old_ref}\n"
155151
)
152+
153+
# rename llvm-bolt
154+
if not os.path.exists(bolt_path):
155+
sys.exit(f"Failed to build the previous revision: '{bolt_path}'")
156+
os.replace(bolt_path, f"{bolt_path}.old")
157+
156158
print(
157159
f"Build directory {args.build_dir} is ready to run BOLT tests, e.g.\n"
158160
"\tbin/llvm-lit -sv tools/bolt/test\nor\n"

0 commit comments

Comments
 (0)