Skip to content

Expose pathToInput for any inputKind #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Expose pathToInput for any inputKind
Downstream tests (notably
scala-js/scala-js#4623) can profit from the
ability to abstract over an input kind.
  • Loading branch information
gzm0 committed Jan 22, 2022
commit 14b5297626c0b251ac3b84ad9a9eebb7c0513cad
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,8 @@ final class TestKit(jsEnv: JSEnv, timeout: FiniteDuration,
}

/** Converts a Path to an Input based on this Kit's defaultInputKind */
def pathToInput(path: Path): Input = {
import TestKit.InputKind._

defaultInputKind match {
case Script => Input.Script(path)
case CommonJSModule => Input.CommonJSModule(path)
case ESModule => Input.ESModule(path)
}
}
def pathToInput(path: Path): Input =
TestKit.pathToInput(path, defaultInputKind)

private def io[T <: JSRun](config: RunConfig)(start: RunConfig => T): (T, IOReader, IOReader) = {
val out = new IOReader
Expand Down Expand Up @@ -174,6 +167,17 @@ object TestKit {
private val completer =
ExecutionContext.fromExecutor(Executors.newSingleThreadExecutor())

/** Converts a Path to an Input based on the inputKind. */
def pathToInput(path: Path, inputKind: InputKind): Input = {
import InputKind._

inputKind match {
case Script => Input.Script(path)
case CommonJSModule => Input.CommonJSModule(path)
case ESModule => Input.ESModule(path)
}
}

sealed trait InputKind

object InputKind {
Expand Down