Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use parameter_types instead of thread_local for test-setup #12020

Closed
kianenigma opened this issue Aug 12, 2022 · 5 comments · Fixed by #12036
Closed

Use parameter_types instead of thread_local for test-setup #12020

kianenigma opened this issue Aug 12, 2022 · 5 comments · Fixed by #12036
Assignees
Labels
I5-tests Tests need fixing, improving or augmenting. I7-refactor Code needs refactoring. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.

Comments

@kianenigma
Copy link
Contributor

parameter_types! {
    pub static Members: BoundedVec<u64,ConstU32<10_u32>> = bounded_vec![0,10]
}

and then you get Members::get() and Members::set() with the same functionality.

Originally posted by @kianenigma in #11996 (comment)


As per explained in the above PR.

@kianenigma kianenigma added I5-tests Tests need fixing, improving or augmenting. I7-refactor Code needs refactoring. Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder labels Aug 12, 2022
@ggwpez
Copy link
Member

ggwpez commented Aug 12, 2022

That should also fix this #10479, if used everywhere.

@bkchr
Copy link
Member

bkchr commented Aug 12, 2022

You can not use parameter_types! in all tests. The problem is that some tests require that you change the values between different tests.

@kianenigma
Copy link
Contributor Author

I don't see any function difference between the two. It is merely for the nicer syntax. Can you provide an example?

@bkchr
Copy link
Member

bkchr commented Aug 13, 2022

Okay, I mixed stuff up. There is some usage of thread_local in the frame tests, but none of them is used directly as alternative for parameter_types. More like some way to introspect operations.

@tifecool
Copy link
Contributor

Would like to attempt this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I5-tests Tests need fixing, improving or augmenting. I7-refactor Code needs refactoring. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder Z6-mentor An easy task where a mentor is available. Please indicate in the issue who the mentor could be.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants