Skip to content

Commit 653b2f1

Browse files
committed
chore: make --test an Option[Boolean]
1 parent a192831 commit 653b2f1

File tree

11 files changed

+18
-15
lines changed

11 files changed

+18
-15
lines changed

modules/cli/src/main/scala/scala/cli/commands/compile/Compile.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ object Compile extends ScalaCommand[CompileOptions] with BuildCommandHelpers {
102102
configDb.get(Keys.actions).getOrElse(None)
103103
)
104104

105+
val shouldBuildTestScope = options.shared.scope.test.getOrElse(false)
105106
if (options.watch.watchMode) {
106107
val watcher = Build.watch(
107108
inputs,
@@ -110,7 +111,7 @@ object Compile extends ScalaCommand[CompileOptions] with BuildCommandHelpers {
110111
None,
111112
logger,
112113
crossBuilds = cross,
113-
buildTests = options.shared.scope.test,
114+
buildTests = shouldBuildTestScope,
114115
partial = None,
115116
actionableDiagnostics = actionableDiagnostics,
116117
postAction = () => WatchUtil.printWatchMessage()
@@ -129,7 +130,7 @@ object Compile extends ScalaCommand[CompileOptions] with BuildCommandHelpers {
129130
None,
130131
logger,
131132
crossBuilds = cross,
132-
buildTests = options.shared.scope.test,
133+
buildTests = shouldBuildTestScope,
133134
partial = None,
134135
actionableDiagnostics = actionableDiagnostics
135136
)

modules/cli/src/main/scala/scala/cli/commands/dependencyupdate/DependencyUpdate.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object DependencyUpdate extends ScalaCommand[DependencyUpdateOptions] {
2525
args: RemainingArgs,
2626
logger: Logger
2727
): Unit = {
28-
if options.shared.scope.test then
28+
if options.shared.scope.test.nonEmpty then
2929
logger.message(
3030
s"""$warnPrefix Including the test scope does not change the behaviour of this command.
3131
|$warnPrefix Test dependencies are updated regardless.""".stripMargin

modules/cli/src/main/scala/scala/cli/commands/doc/Doc.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object Doc extends ScalaCommand[DocOptions] {
5252
configDb.get(Keys.actions).getOrElse(None)
5353
)
5454

55-
val withTestScope = options.shared.scope.test
55+
val withTestScope = options.shared.scope.test.getOrElse(false)
5656
Build.build(
5757
inputs,
5858
initialBuildOptions,

modules/cli/src/main/scala/scala/cli/commands/export0/Export.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ object Export extends ScalaCommand[ExportOptions] {
136136
override def sharedOptions(opts: ExportOptions): Option[SharedOptions] = Some(opts.shared)
137137

138138
override def runCommand(options: ExportOptions, args: RemainingArgs, logger: Logger): Unit = {
139-
if options.shared.scope.test then {
139+
if options.shared.scope.test.nonEmpty then {
140140
logger.error(
141141
s"""Including the test scope sources together with the main scope is currently not supported.
142142
|Note that test scope sources will still be exported as per the output build tool tests definition demands.""".stripMargin

modules/cli/src/main/scala/scala/cli/commands/fmt/Fmt.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object Fmt extends ScalaCommand[FmtOptions] {
4343
override def runCommand(options: FmtOptions, args: RemainingArgs, logger: Logger): Unit = {
4444
val buildOptions = buildOptionsOrExit(options)
4545

46-
if options.shared.scope.test then
46+
if options.shared.scope.test.nonEmpty then
4747
logger.message(
4848
s"""$warnPrefix Including the test scope does not change the behaviour of this command.
4949
|$warnPrefix Test scope inputs are formatted, regardless.""".stripMargin

modules/cli/src/main/scala/scala/cli/commands/package0/Package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
8888
configDb.get(Keys.actions).getOrElse(None)
8989
)
9090

91-
val withTestScope = options.shared.scope.test
91+
val withTestScope = options.shared.scope.test.getOrElse(false)
9292
if options.watch.watchMode then {
9393
var expectedModifyEpochSecondOpt = Option.empty[Long]
9494
val watcher = Build.watch(

modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
266266
() => configDb,
267267
options.mainClass,
268268
dummy = options.sharedPublish.dummy,
269-
buildTests = options.shared.scope.test
269+
buildTests = options.shared.scope.test.getOrElse(false)
270270
)
271271
}
272272

modules/cli/src/main/scala/scala/cli/commands/publish/PublishLocal.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ object PublishLocal extends ScalaCommand[PublishLocalOptions] {
8686
configDb = () => ConfigDb.empty, // shouldn't be used, no need of repo credentials here
8787
mainClassOptions = options.mainClass,
8888
dummy = options.sharedPublish.dummy,
89-
buildTests = options.shared.scope.test
89+
buildTests = options.shared.scope.test.getOrElse(false)
9090
)
9191
}
9292
}

modules/cli/src/main/scala/scala/cli/commands/repl/Repl.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ object Repl extends ScalaCommand[ReplOptions] with BuildCommandHelpers {
190190
configDb.get(Keys.actions).getOrElse(None)
191191
)
192192

193+
val shouldBuildTestScope = options.shared.scope.test.getOrElse(false)
193194
if (inputs.isEmpty) {
194195
val allArtifacts =
195196
Seq(initialBuildOptions.artifacts(logger, Scope.Main).orExit(logger)) ++
196-
(if options.shared.scope.test
197+
(if shouldBuildTestScope
197198
then Seq(initialBuildOptions.artifacts(logger, Scope.Test).orExit(logger))
198199
else Nil)
199200
// synchronizing, so that multiple presses to enter (handled by WatchUtil.waitForCtrlC)
@@ -224,7 +225,7 @@ object Repl extends ScalaCommand[ReplOptions] with BuildCommandHelpers {
224225
None,
225226
logger,
226227
crossBuilds = cross,
227-
buildTests = options.shared.scope.test,
228+
buildTests = shouldBuildTestScope,
228229
partial = None,
229230
actionableDiagnostics = actionableDiagnostics,
230231
postAction = () => WatchUtil.printWatchMessage()
@@ -252,7 +253,7 @@ object Repl extends ScalaCommand[ReplOptions] with BuildCommandHelpers {
252253
None,
253254
logger,
254255
crossBuilds = cross,
255-
buildTests = options.shared.scope.test,
256+
buildTests = shouldBuildTestScope,
256257
partial = None,
257258
actionableDiagnostics = actionableDiagnostics
258259
)

modules/cli/src/main/scala/scala/cli/commands/run/Run.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ object Run extends ScalaCommand[RunOptions] with BuildCommandHelpers {
233233
configDb.get(Keys.actions).getOrElse(None)
234234
)
235235

236+
val shouldBuildTestScope = options.shared.scope.test.getOrElse(false)
236237
if options.sharedRun.watch.watchMode then {
237238

238239
/** A handle to the Runner process, used to kill the process if it's still alive when a change
@@ -258,7 +259,7 @@ object Run extends ScalaCommand[RunOptions] with BuildCommandHelpers {
258259
docCompilerMakerOpt = None,
259260
logger = logger,
260261
crossBuilds = cross,
261-
buildTests = options.shared.scope.test,
262+
buildTests = shouldBuildTestScope,
262263
partial = None,
263264
actionableDiagnostics = actionableDiagnostics,
264265
postAction = () =>
@@ -331,7 +332,7 @@ object Run extends ScalaCommand[RunOptions] with BuildCommandHelpers {
331332
None,
332333
logger,
333334
crossBuilds = cross,
334-
buildTests = options.shared.scope.test,
335+
buildTests = shouldBuildTestScope,
335336
partial = None,
336337
actionableDiagnostics = actionableDiagnostics
337338
)

0 commit comments

Comments
 (0)