Skip to content

Commit

Permalink
Merge pull request #104 from tudortimi/apply-base-plugin-in-hdvl-base…
Browse files Browse the repository at this point in the history
…-plugin

Apply base plugin in HDVL base plugin
  • Loading branch information
tudortimi authored Jan 25, 2023
2 parents 93a5c76 + 59996f2 commit ee7289f
Show file tree
Hide file tree
Showing 3 changed files with 24 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 @@ -33,6 +33,8 @@ public class HDVLBasePlugin implements Plugin<Project> {

@Override
public void apply(Project project) {
project.getPluginManager().apply("base");

final DefaultHDVLPluginExtension extension = new DefaultHDVLPluginExtension(project);
project.getExtensions().add("hdvl", extension);
project.getExtensions().add("sourceSets", extension.getSourceSets());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
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.language.base.plugins.LifecycleBasePlugin;
import org.gradle.util.GUtil;

import java.io.File;
Expand Down Expand Up @@ -130,9 +132,10 @@ 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.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
testTask.setDescription("Runs the unit tests using SVUnit.");
testTask.getToolName().set(toolName.toLowerCase());
testTask.getMainArgsFile().set(genFullArgsFile.getDestination());
Expand All @@ -143,6 +146,7 @@ public void execute(TestTask testTask) {
testTask.getExtraArgs().set(toolChains.getRunSVUnit().getArgs());
}
});
project.getTasks().getByName("check").dependsOn(testTask);
}

}

0 comments on commit ee7289f

Please sign in to comment.