简体   繁体   English

凿子如何测试只有一个package

[英]Chisel how to test only one package

I am working with chisel-template我正在使用凿子模板

In my src/main/scala I have two folders, let say A and B.在我的src/main/scala中,我有两个文件夹,假设是 A 和 B。

In src/test/scala , I have a folder for A and a folder for B.src/test/scala中,我有一个 A 文件夹和一个 B 文件夹。

I want to test only A but when I do我只想测试 A 但当我这样做时

$ sbt "test:runMain A.TestMain" 

I have the errors of B which make the compilation fail.我有 B 的错误,导致编译失败。 I know there are problems in B but I just want to check A first.我知道 B 有问题,但我只想先检查 A。

How can I test or compile only one folder?如何只测试或编译一个文件夹?

Thanks !谢谢 !

I'm a beginner of scala, so there may be better ways. 我是scala的初学者,所以可能有更好的方法。

sbt ReferenceManual tells us to add statement like below in build.sbt sbt ReferenceManual告诉我们在build.sbt中添加如下所示的语句

excludeFilter in unmanagedSources := "excludedFileName"

If you want to exclude files only when running test, you can specify it like below. 如果只想在运行测试时排除文件,可以像下面一样指定。

excludeFilter in (Test, unmanagedSources) := "excludedFileName"

Probably, your question is about sbt, not chisel. 也许,你的问题是关于sbt,而不是凿子。 That's why you may get better and more detailed answer if you add scala tag. 这就是为什么如果你添加scala标签你可能会得到更好更详细的答案。

I don't think there is a way to do this. 我认为没有办法做到这一点。 But if you use scalatest to launch your tests instead of a main it's fairly easy. 但是,如果您使用scalatest来启动测试而不是主要测试,则相当容易。 You can specify just the path you want with testOnly for example, from sbt command line 例如,您可以从sbt命令行指定testOnly所需的路径

testOnly A.*

Or from the shell command line 或者从shell命令行

sbt 'testOnly A.*'

In fact, with tests you can even specify specific tests within a test harness by using 事实上,通过测试,您甚至可以使用在测试工具中指定特定测试

sbt 'testOnly A.* -- -z "dog"'

(notes, the quoting is significant), you can run only those tests in package a that have the word dog in the test name (注意,引用很重要),您只能在测试名称中包含单词dog的包a中运行那些测试

testOnly Foldername.test_bench_classname

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM