Skip to content

Conversation

@0xteddybear
Copy link

see git history for details

this mitigates the case where inconsistencies between the logic in
`collect_helpers` and `collect_tests` caused setup hooks to be invoked
but not defined, as was the trigger for this PR. This also mean we will
generate more helpers, as we'll now generate them when there's no real
need for reuse of their logic, as exemplified in the previous commit
Copy link

@zkfrov zkfrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is working like a charm now. Tested with the full Token tree and all functions are generated and included in their corresponding mods!

Left a small suggestion.

Comment on lines +72 to +76
if generate_setup_hooks {
for import in &self.imported_hooks {
output.push_str(format!(" use super::{};\n", import.name).as_str());
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to have: pack super imports in the mods, this

use super::{
    when_shares_are_held,
    when_called_on_behalf_of_other_with_authwit
};

instead of the current behaviour

use super::when_shares_are_held;
use super::when_called_on_behalf_of_other_with_authwit;

That was generated with this change

Suggested change
if generate_setup_hooks {
for import in &self.imported_hooks {
output.push_str(format!(" use super::{};\n", import.name).as_str());
}
}
if generate_setup_hooks && !self.imported_hooks.is_empty() {
if self.imported_hooks.len() == 1 {
output.push_str(format!(" use super::{};\n", self.imported_hooks[0].name).as_str());
} else {
output.push_str(" use super::{\n");
for (i, import) in self.imported_hooks.iter().enumerate() {
output.push_str(&format!(" {}", import.name));
if i < self.imported_hooks.len() - 1 {
output.push_str(",\n");
} else {
output.push('\n');
}
}
output.push_str(" };\n");
}
output.push('\n');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants