Skip to content

tests: Unable to share code in tests #5524

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

Closed
geky opened this issue Nov 17, 2017 · 5 comments · Fixed by #5819
Closed

tests: Unable to share code in tests #5524

geky opened this issue Nov 17, 2017 · 5 comments · Fixed by #5819
Assignees

Comments

@geky
Copy link
Contributor

geky commented Nov 17, 2017

I realize this issue probably already exists, but I can't seemt to find it.

Currently, we have no method for sharing code between related tests. Currently the options are:

  1. Copy test code into every test directory
  2. Include the code at the top level and compile always

Option 1 violates the principle of don't repeat yourself. Leads to a lot of code duplication that can fall out of sync as tests are modified.

Option 2 leads to several minor issues:

  • Where do we store the common code? Currently common tests code is being stored inconsistenly. We've started using TEST_COMMON, but this could lead to compatibility concerns if the name becomes used in the mbed tools.
  • Additional compile time, mbed doesn't need help with this
  • Distributed dependencies makes debugging tougher when jumping between files
  • Test code needs additional ifdefs to avoid breaking the codebase if there is a compile issue outside of testing.

We already have the special folder host_tests in the testing folder layout. It would be helpful to have something similar for shared code. (maybe TESTS/filesystem/UTIL?).

cc @studavekar, @theotherjimmy, @c1728p9, @bridadan

@theotherjimmy
Copy link
Contributor

Definitely a problem. I don't presently have a design for a solution. I'm very open to suggestions here.

@bridadan
Copy link
Contributor

Yep, this was a bit of an oversight when this was first implemented!

We already have the special folder host_tests in the testing folder layout. It would be helpful to have something similar for shared code. (maybe TESTS/filesystem/UTIL?).

Seems ok, and should be pretty straight forward to accomplish. The edits would need to be made in tools/test.py and tools/test_api.py. I'd definitely make it a capital directory to fit in with our existing "All caps directories are special". Just needs to be documented in Mbed CLI's readme.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 21, 2017

A set of tests (test unit) might need a common folder, as shown above TESTS/filesystem/UTIL. How these test units can specify the common folder dependency? For filesystem it can be util, for spi drivers another one, tickers another one.

How can this be defined? Set somehow in our tools as @bridadan proposed above? Who should define this dependency? A target defines it's own dependencies via labels. Can one test unit do the same? Not a config option?

@bridadan
Copy link
Contributor

bridadan commented Nov 21, 2017

Can one test unit do the same

Not to my knowledge, no. And there isn't really anything in the tools right now that would allow us to do that.

Not a config option

Same thing here, there isn't really a mechanism for this that I know of.

Since we already treat the folders TESTS/host_tests and TESTS/<test group>host_tests differently, would anyone be opposed to adding a similar folder? I'd propose TESTS/common and TESTS/<test group>/common.

EDIT: we should probably looking at making those special folders CAPITALIZED too, to fit the current convention.

@geky geky self-assigned this Jan 9, 2018
@geky
Copy link
Contributor Author

geky commented Jan 9, 2018

Here's the conception of @bridadan's thoughts: #5819

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 a pull request may close this issue.

4 participants