Skip to content

Commit

Permalink
Added an endpoint to list the available test run configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
odisseus committed Nov 16, 2020
1 parent 8cd7064 commit e1ef66b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ object Endpoints {
val RunApp = Request[ApplicationRunConfiguration, ProcessResult]("run/application")
val RunJUnit = Request[TestScope, TestsRunResult]("run/junit")
val RunTestsFromGenerated = Request[(TestScope, Option[String]), TestsRunResult]("run/test")
val TestConfigurations = Request[TestScope, Seq[String]]("run/testConfigurations")
val RerunFailedTests = Request[ProjectRef, TestsRunResult]("run/failedTests")
val Shutdown = Notification[Unit]("shutdown")
val SyncFiles = Request[Unit, Unit]("fs/sync")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ class ProbeDriver(
*/
def freezes: Seq[Freeze] = send(Endpoints.Freezes)

/**
* Returns the list of test configuration names that are available for the given scope
*/
def testConfigurations(testScope: TestScope): Seq[String] =
send(Endpoints.TestConfigurations, testScope)

/**
* Runs the specified test configuration with the first available test runner
*/
Expand All @@ -222,6 +228,10 @@ class ProbeDriver(
runTestsFromGenerated(runConfiguration, runnerToSelect = Some(runnerToSelect))
}

/**
* Runs the specified test configuration with a test runner containing provided `runnerToSelect` substring,
* or the first available test runner if `runnerToSelect` is `None`
*/
def runTestsFromGenerated(runConfiguration: TestScope, runnerToSelect: Option[String]): TestsRunResult = {
send(Endpoints.RunTestsFromGenerated, (runConfiguration, runnerToSelect))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BaseProbeHandlerContributor extends ProbeHandlerContributor {
.on(Endpoints.RunApp)(RunConfigurations.runApp)
.on(Endpoints.RunJUnit)(RunConfigurations.runJUnit)
.on(Endpoints.RerunFailedTests)(RunConfigurations.rerunFailedTests)
.on(Endpoints.TestConfigurations)(RunConfigurations.testConfigurations)
.on(Endpoints.RunTestsFromGenerated)((RunConfigurations.runTestsFromGenerated _).tupled)
.on(Endpoints.TakeScreenshot)(Screenshot.take)
.on(Endpoints.RunLocalInspection)(Inspections.runLocal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ object RunConfigurations extends IntelliJApi {
ExecutionManager.getInstance(project).restartRunProfile(environment)
}

def testConfigurations(
scope: TestScope
)(implicit ec: ExecutionContext): Seq[String] = {
val configurations = availableRunConfigurations(scope)
configurations.map(_.getConfigurationSettings.getName)
}

def runTestsFromGenerated(
scope: TestScope,
runnerToSelect: Option[String]
Expand Down

0 comments on commit e1ef66b

Please sign in to comment.