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

refactor(macros): cleanup macros, add better error handling, dedup code, DX #472

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

tbraun96
Copy link
Collaborator

Addresses #407 and #381

Copy link
Contributor

@drewstone drewstone left a comment

Choose a reason for hiding this comment

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

Looks good, some comments and would appreciate more reviews on this @Serial-ATA @shekohex

#[test]
fn test_jobs_invalid_cases() {
let t = TestCases::new();
t.compile_fail("tests/invalid_cases/job/*.rs");
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

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

The valid test cases you fixed below aren't running now ya? Can we make them run? Or it's simply enough to define them above and ensure they compile?

Copy link
Collaborator Author

@tbraun96 tbraun96 Nov 13, 2024

Choose a reason for hiding this comment

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

Before, they weren't technically running, only checking for syntactical correctness. Now, it does the same thing but implicitly by being attached to the module tree. We could make them run once to check input/output correctness, though, maybe in another PR since it would be beyond the scope of this task.

pre_processor = pre_process,
post_processor = post_process,
),
)]
// Maps a boolean value obtained from pre-processing to a u8 value
pub async fn web_poller(value: bool, count: Arc<AtomicUsize>) -> Result<u8, Infallible> {
pub async fn web_poller_test(value: bool, count: Arc<AtomicUsize>) -> Result<u8, Infallible> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we test this in the blueprint examples repo? It's getting to be a bit of a nested mess IMO. PeriodicListener with WebPoller and then another PeriodicListener with a WebPollerTest containing a WebPoller.

I would suggest getting CI to test the example blueprint instead? Would that accomplish your goal here? It would also be good to have a PeriodicListener example as a simple cron-job no inner listener too, no complexity, just "here's how you trigger your job every 2 seconds".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We currently don't have a clean way of testing blueprints unless we inject test-related code into them (like I did for the web_poller_test). While we could test the one inside examples, we would have to add more code to it, confusing the user by mixing prod code with test code. At least with web_poller_test, I just need to import the already-existing code inside examples, then add a thin wrapper over it where I am then able to inject the test-related code.

Copy link
Contributor

@shekohex shekohex left a comment

Choose a reason for hiding this comment

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

Overall Looks good!

aside from the removed test cases, we need to expand more and add a test case for each scenario (AI Could be useful here for generating different scenarios); Testing here is very important to make sure changes to the macros or other things does not break the SDK.

Comment on lines +48 to +49
/// Tuple
Tuple(Vec<FieldType>),
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be updated and added to the runtime, please open a PR on tangle or a task so we are aware of it.

CC @Serial-ATA to maybe support this into blueprint-serde.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

macros/blueprint-proc-macro/src/job.rs Show resolved Hide resolved
macros/blueprint-proc-macro/src/job.rs Outdated Show resolved Hide resolved
macros/blueprint-proc-macro/src/report.rs Outdated Show resolved Hide resolved
macros/blueprint-proc-macro/src/report.rs Outdated Show resolved Hide resolved
macros/blueprint-proc-macro/src/report.rs Outdated Show resolved Hide resolved
macros/blueprint-proc-macro/src/report.rs Outdated Show resolved Hide resolved
macros/blueprint-proc-macro/src/report.rs Outdated Show resolved Hide resolved
@tbraun96 tbraun96 merged commit ae45c67 into main Nov 13, 2024
13 checks passed
@webb-spider webb-spider bot mentioned this pull request Nov 13, 2024
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.

3 participants