-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
About tests organization #982
Comments
I'd say that the standard for tests would be to be placed in |
Then does tester/src/test/scala/spinal/lib/bus/amba3/ahblite/AhbLite3InterconnectTester.scala
//^^ ^^^ ^^^^ //here, tester is removed.
//project. test directory. this path better? |
Here following the package/file parallel it has to start with |
Emm, I suppose that is how Scala do. I mean, put the unit test in the same package of DUT. Only keep it away from publishing. Btw, neither the simulation code nor the formal verification code could be run as standalone example just by "copy & paste". |
Ah so here it is just about conventions. AFAIK the only common convention is the one @andreasWallner mentioned. I think ideally the best would be to go with this one but I'm afraid of cyclic dependencies if we want to use a feature from @andreasWallner Usually unit tests are placed in a location relative to the tested thing, and integration test are put on a completely separate project, to integrate from another point a view with clean public-only API. Also it is "go to test" (singular) so I think it is implicitly "the unit test for this", not "tests for this, unit and integration". However Scala has everything public by default so maybe it is different from what I'm used to ^^' |
@numero-744 I had a quick look around a few libraries (https://github.com/scalanlp/breeze, https://github.com/haifengl/smile, https://github.com/scalanlp/nak, https://github.com/intel-analytics/BigDL - chosen at random (via google search for scala libraries). They all use the And I think we could have long discussions on what is a unit test vs. integration test for e.g. spinal.lib ;-) Not sure there needs to be a strict definition/dividing line. In my projects I place all my tests in the test folder of the library, simply because of convenience: if I open that library in an IDE it will show me both code and tests. If the tests are in a separate library I need to make sure that that library is compiled/run as well. (which doesn't mean it has to be the same here - the only thing that matters is that those working on the code find the respective tests...) If there are really features in One additional thing: package private content can only be tested if it is the same library&package. |
The initial situation was that such testing features were in |
I look over the sbt's usage, there is a test-scoped dependency, which can help to prevent the runtime depends on libraries only required in test. So scalatest as a standard test framework of SpinalHDL would not cause a conflict with user's test framework unless they use helper class defined in SpinalHDL, like SpinalFormalFunSuite. |
If we put testing helpers like |
If I describe the functions of each subproject as follows, would there be any problems?
|
One thing: I think Also there are See https://github.com/SpinalHDL/SpinalTemplateSbt/blob/master/build.sbt |
Yes, as I previously state, SpinalFormalFunSuite only add tags for formal suites which run a seperate jobs in CI. Of course, that can be exported through a tester subproject, like SpinalTestBench. And the best is to split the existing tester into their own subproject, if possible. |
Okay, I'm gonna try to PR that next week-end or before, depending on the time I have, unless someone else wants to do that? |
I have updated the description of sim. About the idsl plugin and payload, I think they are more like a support library of core, which could not directly used by user. |
Yes but they are in the |
so the dependency chain can be: like this? In many cases, dependency relation should be unidirectional. |
I think |
yes |
I'm falling on this: https://stackoverflow.com/questions/44764692/cyclic-dependencies-between-main-test-modules-in-sbt Maybe a (really) dirty workaround could be to https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201#59761201 |
I tried symlink recently, it works weird. Maybe it's caused by some mistake I have done. |
On my side I would say:
(Sorry, Lignux addict here 😆) Joke apart, maybe the link I have provided at the end of my previous comment can help? I have never tried it because I stay away from Windows weirdness as much as I can. |
Firstly, this link might help. |
Hmm for #968 I know I know need at least |
Ah, to recall something from memory, the first reason I gave up on Chisel was that it compiled with an error on Windows. |
Btw what we want is exactly https://doc.rust-lang.org/cargo/reference/features.html but it doesn't seem to be a thing in Scala |
However, we can just work around it. Here might worth a try. BTW, there are runIvyDeps, compileIvyDeps separately in Mill :) . |
Thanks for the link! The (really old) suggestion does not work in the current version of |
I would find it more natural to use the sbt/maven layout, but in the end it's not a huge thing if not. |
@andreasWallner I'm working on the conversion to |
While moving stuff I notice that:
|
FYI, so far I've done 50% of tests reorganization to standard |
@numero-744 Just one quick thought because you mentioned #968: If you want to switch to that (which is perfectly reasonable) I'd do that in two steps, it's pretty much unreviewable if you move & change much stuff^^ |
@andreasWallner The PR I'm preparing is just moving code around ^^' |
I am trying to continue this work, to move some test to lib to reduce the CI time. As lib-test and tester-test tasks in CI could be running on parallel. So do you know the requirements for "go to test" function to work? This would be considered in mind. For example, there are two testers in Axi4AdapterTester.scala file, one for upsizer, one for downsizer. However Axi4Upsizer and Axi4Downsizer are located in seperate file, does it matter for "go to test" function? If you want give it a try [Readon/SpinalHDL@move-tests] is the branch. |
Until now I have just had the tests in the same library, same library with the same folder structure. |
Below is the first part of the path:
The standard for unit tests would be:
So let's admit that (most) tests running simulations are integration tests, hence putting them in a separate
tester/
module. It also simplifies dependencies management for the day we want to use features released intester/
to test something fromcore/
orlib/
.IMHO nothing to change here 👍
Then there is the
tester/
folder. As it is about integration tests, it forces to import tested things (else using the same package as the test being run would bring in scope the stuff if the same package), making tests look more like examples, to better test the user's API, which seems to be a good thing.IMHO nothing to change here 👍
Then there are lots of tests with poor organization. Below is a suggestion:
drafts/
for worksheets (old things that could be removed IMHO), so that most contributors can forget thempath/to/item.scala
where the first element of the path is basicallycore
,lib
, etc. without being repeated.issues/IssueXXX.scala
for bug fixesFor instance:
tests:
So it would be moved to:
Tests about different elements (elements being tested, not elements used to test other elements) would be in the deepest common element in the paths.
I think it is okay to have
App
s to test Scala syntax and types among scalatest-run tests.This way it would be easier to find and add more tests.
The text was updated successfully, but these errors were encountered: