Skip to content

Commit 961a950

Browse files
committed
NIT: Refactor TestUtil
- add missing type annotations
1 parent bcaebd1 commit 961a950

File tree

1 file changed

+15
-13
lines changed
  • modules/integration/src/test/scala/scala/cli/integration

1 file changed

+15
-13
lines changed

modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package scala.cli.integration
22

3+
import os.{CommandResult, Path}
4+
35
import java.io.File
46
import java.util.concurrent.atomic.AtomicInteger
57
import java.util.concurrent.{ExecutorService, Executors, ScheduledExecutorService, ThreadFactory}
@@ -10,11 +12,11 @@ import scala.util.Properties
1012

1113
object TestUtil {
1214

13-
val cliKind = sys.props("test.scala-cli.kind")
14-
val isNativeCli = cliKind.startsWith("native")
15-
val isCI = System.getenv("CI") != null
16-
val cliPath = sys.props("test.scala-cli.path")
17-
val cli = cliCommand(cliPath)
15+
val cliKind: String = sys.props("test.scala-cli.kind")
16+
val isNativeCli: Boolean = cliKind.startsWith("native")
17+
val isCI: Boolean = System.getenv("CI") != null
18+
val cliPath: String = sys.props("test.scala-cli.path")
19+
val cli: Seq[String] = cliCommand(cliPath)
1820

1921
def cliCommand(cliPath: String): Seq[String] =
2022
if (isNativeCli)
@@ -23,7 +25,7 @@ object TestUtil {
2325
Seq("java", "-Xmx512m", "-Xms128m", "-jar", cliPath)
2426

2527
// format: off
26-
val extraOptions = List(
28+
val extraOptions: List[String] = List(
2729
"--bloop-startup-timeout", "2min",
2830
"--bloop-bsp-timeout", "1min"
2931
)
@@ -58,7 +60,7 @@ object TestUtil {
5860
.map(_.getAbsolutePath)
5961
}
6062

61-
def cs = Constants.cs
63+
def cs: String = Constants.cs
6264

6365
def threadPool(prefix: String, size: Int): ExecutorService =
6466
Executors.newFixedThreadPool(size, daemonThreadFactory(prefix))
@@ -68,9 +70,9 @@ object TestUtil {
6870

6971
private def daemonThreadFactory(prefix: String): ThreadFactory =
7072
new ThreadFactory {
71-
val counter = new AtomicInteger
72-
def threadNumber() = counter.incrementAndGet()
73-
def newThread(r: Runnable) =
73+
val counter = new AtomicInteger
74+
def threadNumber(): Int = counter.incrementAndGet()
75+
def newThread(r: Runnable): Thread =
7476
new Thread(r, s"$prefix-thread-${threadNumber()}") {
7577
setDaemon(true)
7678
setPriority(Thread.NORM_PRIORITY)
@@ -105,19 +107,19 @@ object TestUtil {
105107

106108
def retryOnCi[T](maxAttempts: Int = 3, waitDuration: FiniteDuration = 5.seconds)(
107109
run: => T
108-
) = retry(if (isCI) maxAttempts else 1, waitDuration)(run)
110+
): T = retry(if (isCI) maxAttempts else 1, waitDuration)(run)
109111

110112
// Same as os.RelPath.toString, but for the use of File.separator instead of "/"
111113
def relPathStr(relPath: os.RelPath): String =
112114
(Seq.fill(relPath.ups)("..") ++ relPath.segments).mkString(File.separator)
113115

114-
def kill(pid: Int) =
116+
def kill(pid: Int): CommandResult =
115117
if (Properties.isWin)
116118
os.proc("taskkill", "/F", "/PID", pid).call()
117119
else
118120
os.proc("kill", pid).call()
119121

120-
def pwd =
122+
def pwd: Path =
121123
if (Properties.isWin)
122124
os.Path(os.pwd.toIO.getCanonicalFile)
123125
else

0 commit comments

Comments
 (0)