SpinalTemplateSbt icon indicating copy to clipboard operation
SpinalTemplateSbt copied to clipboard

Add tests in the structure

Open numero-744 opened this issue 2 years ago • 7 comments
trafficstars

FYI https://github.com/numero-744/Aes has been updated; part of its contents could be put in the template:

  • add tb/ folder for Test (not released contents) with sub-directories like for hw/
  • add HTML report generation with scalatest
  • works with both App and SpinalTestBench (in its current state, changes will occur)
  • tested with mill

See the end of the readme with an IDE screenshot and the resulting directory structure with important things highlighted in blue on the left.

numero-744 avatar Nov 30 '22 18:11 numero-744

That is exactly what I want to say. Btw, Scala use "main" and "test" directory name to distinct the source code and test code.

Readon avatar Dec 06 '22 09:12 Readon

FYI https://github.com/numero-744/Aes has been updated; part of its contents could be put in the template:

  • add tb/ folder for Test (not released contents) with sub-directories like for hw/
  • add HTML report generation with scalatest
  • works with both App and SpinalTestBench (in its current state, changes will occur)
  • tested with mill

See the end of the readme with an IDE screenshot and the resulting directory structure with important things highlighted in blue on the left.

I tried to get test dir working. However, the "hw/spinal" directory is really different from the other project in Scala, which makes it hard to work with sbt. Although I have make the mill works, not perfect still.

Readon avatar Dec 07 '22 13:12 Readon

@Readon I just tested sbt with :

Test / scalaSource := baseDirectory.value / "miaou" / "spinal",

It worked well for me.

What issue did you had ?

Dolu1990 avatar Dec 07 '22 16:12 Dolu1990

@Readon I just tested sbt with :

Test / scalaSource := baseDirectory.value / "miaou" / "spinal",

It worked well for me.

What issue did you had ?

I add test directory in this PR, which need to seperately depends on spinal.tester. Then use Test / scalaSource to specify the test sources would need to point to the test directory manually, or it will compile those source file several times.

On other hand, if the multiple-times-compilation is acceptable, a common dependency of scalatest is involved, to the compilation process.

I think as a template, efficiency and cleanliness are of utmost importance, especially for users just starting out.

Readon avatar Dec 07 '22 17:12 Readon

Hmm bad news, the App in tests requires to be run with Test/runMain instead of just runMain in sbt

  • do I document that in the Getting started section of RTD? (https://github.com/SpinalHDL/SpinalDoc-RTD/pull/162 is not enough)
  • or do we just let things currently in main where they are, and add example files in test with only test suites
  • or other ideas?

In the latter case no modification to the Getting started section of RTD would be needed, and I suggest to add this new structure in the next release, after:

  • having released https://github.com/SpinalHDL/SpinalHDL/pull/968 so that we can add an example using it, and
  • having stabilized the tester repository structure so that we are sure things do not get moved later on (I'm moving things for https://github.com/SpinalHDL/SpinalHDL/issues/982 so I'll PR and we'll be able to discuss a structure and move things again after that I think)

PS: I think having simulation tests in the tb folder is consistent and other hardware engineers will like it so I vote for moving things and documenting it in RTD.

numero-744 avatar Dec 07 '22 19:12 numero-744

I think as a template, efficiency and cleanliness are of utmost importance, especially for users just starting out.

So, one thing i noticed, is that very often, people have already premade project structure. And trying to impose the SBT structure on them is a paine. With that change, which explicitly specify where are the scala sources in the build.sbt, it show people a easy way to adapt / customise the template to their workflow.

do I document that in the Getting started section of RTD?

Yes i would say.

PS: I think having simulation tests in the tb folder is consistent and other hardware engineers will like it so I vote for moving things and documenting it in RTD.

Yes

Dolu1990 avatar Dec 08 '22 15:12 Dolu1990

@Dolu1990 I changed my mind during discussion with Readon https://github.com/SpinalHDL/SpinalTemplateSbt/pull/30#issuecomment-1343322740 I suggest to continue discussion there

numero-744 avatar Dec 08 '22 20:12 numero-744