Skip to content

Commit

Permalink
Attach test tasks to check tasks
Browse files Browse the repository at this point in the history
Running `check` will trigger both `testWithQrun` and `testWithXrun`.
This might cause issues when one of the simulators is not available. To
combat this, we should only add tasks for the simulator that is present
on `PATH`.
  • Loading branch information
tudortimi committed Jan 25, 2023
1 parent 0c0748c commit 1e9118e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,23 @@ class SVUnitPluginSpec extends Specification {
dummyLog.text.contains "-f ${testProjectDir.root}/build/full_test_xrun_args.f"
}

def "'check' task executes test tasks"() {
File testSv = testProjectDir.newFolder('src', 'test', 'sv')
new File(testSv, 'dummy_test.sv').createNewFile()

when:
def result = newGradleRunnerWithFakeRunSVunit()
.withProjectDir(testProjectDir.root)
.withPluginClasspath()
.withArguments('check')
.build()

then:
result.task(":check").outcome == SUCCESS
result.task(":testWithXrun").outcome == SUCCESS
result.task(":testWithQrun").outcome == SUCCESS
}

def newGradleRunnerWithFakeRunSVunit() {
def runSVUnitFake = new File(getClass().getResource('/runSVUnit').toURI())
def env = System.getenv()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.internal.HasConvention;
import org.gradle.api.reflect.TypeOf;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.util.GUtil;

import java.io.File;
Expand Down Expand Up @@ -130,7 +131,7 @@ private void configureTestTask(Project project, SourceSet mainSourceSet, SourceS
GenFullArgsFile genFullTestArgsFile
= (GenFullArgsFile) project.getTasks().getByName(testSourceSet.getGenFullArgsFileTaskName(toolName));
Configuration svUnitRoot = project.getConfigurations().getByName("svUnitRoot");
project.getTasks().register(Names.getTestTaskName(toolName), TestTask.class, new Action<TestTask>() {
TaskProvider<TestTask> testTask = project.getTasks().register(Names.getTestTaskName(toolName), TestTask.class, new Action<TestTask>() {
@Override
public void execute(TestTask testTask) {
testTask.setDescription("Runs the unit tests using SVUnit.");
Expand All @@ -143,6 +144,7 @@ public void execute(TestTask testTask) {
testTask.getExtraArgs().set(toolChains.getRunSVUnit().getArgs());
}
});
project.getTasks().getByName("check").dependsOn(testTask);
}

}

0 comments on commit 1e9118e

Please sign in to comment.