Skip to content

Commit 128e6ce

Browse files
authored
NFC: ExtractIRForPassTest.py error reporting when pass not found (microsoft#6325)
This just adds convenient error reporting to `ExtractIRForPassTest.py` when the specified pass is not found. No functional change.
1 parent cdc5603 commit 128e6ce

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

utils/hct/ExtractIRForPassTest.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,18 @@ def SplitAtPass(passes, pass_name, invocation=1):
8686
after = [line]
8787
continue
8888
before.append(line)
89-
if after is None:
90-
raise Exception(f"no such pass: {pass_name}")
89+
if count == 0:
90+
raise ValueError(
91+
"Pass '{}' not found in pass list. Check spelling and that it is a module pass. Pass list: {}".format(
92+
pass_name, passes
93+
)
94+
)
95+
elif count < invocation:
96+
raise ValueError(
97+
"Pass '{}' found {} times, but {} invocations requested. Pass list: {}".format(
98+
pass_name, count, invocation, passes
99+
)
100+
)
91101

92102
return before, after
93103

0 commit comments

Comments
 (0)