-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP] 3482 Add detection for circular macro replacement #4029
base: dev
Are you sure you want to change the base?
Conversation
merge master
merge master
merge master
merge master
merge master
Signed-off-by: Nic Ma <nma@nvidia.com>
/black |
/build |
1 similar comment
/build |
Signed-off-by: Nic Ma <nma@nvidia.com>
/build |
|
||
""" | ||
if waiting_list is None: | ||
waiting_list = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If waiting_list
is actually a list we could look at the previous item in the exception to help the user trace what's happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think set is more suitable/efficient for in
checks here...not sure if the previous item is very intuitive when the circular ref is formed by multiple reference a->b->...->c->a
if not path: | ||
# if the target id is in the waiting list, that's circular references | ||
if ids in waiting_list: | ||
raise ValueError(f"detected circular references in macro replacement '{ids}' for id='{id}'.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this would be raise ValueError(f"Detected circular references in macro replacement '{ids}' for id='{id}'. (previous id='{waiting_list[-2]}'")
or something like that.
part of #3482
Description
Thanks for Gigon's suggestion, this PR added support to detect circular macro replacement in a config file.
And it also fixed a bug that missing the
id
arg in recursive operation, and now we don't do recursive logic for the case that macro text is in another config file.Added many unit tests to cover the cases.
Status
Working in progress
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.