From 14b5297626c0b251ac3b84ad9a9eebb7c0513cad Mon Sep 17 00:00:00 2001 From: Tobias Schlatter Date: Sat, 22 Jan 2022 13:10:51 +0100 Subject: [PATCH] Expose pathToInput for any inputKind Downstream tests (notably https://github.com/scala-js/scala-js/pull/4623) can profit from the ability to abstract over an input kind. --- .../org/scalajs/jsenv/test/kit/TestKit.scala | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/kit/TestKit.scala b/js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/kit/TestKit.scala index 8301dcf..7a264f3 100644 --- a/js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/kit/TestKit.scala +++ b/js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/kit/TestKit.scala @@ -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 @@ -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 {