Honor default value true for collectOutput

Fixes #2629
This commit is contained in:
eikek 2024-05-28 20:54:53 +02:00
parent 870bfd9cf0
commit fd2b897f2f
2 changed files with 11 additions and 2 deletions

View File

@ -110,7 +110,7 @@ private[addons] object RunnerUtil {
): F[AddonResult] =
for {
stdout <-
if (ctx.meta.options.exists(_.collectOutput)) CollectOut.buffer[F]
if (ctx.meta.parseResult) CollectOut.buffer[F]
else CollectOut.none[F].pure[F]
cmdResult <- SysExec(cmd, logger, ctx.baseDir.some)
.flatMap(
@ -135,7 +135,7 @@ private[addons] object RunnerUtil {
out <- stdout.get
_ <- logger.debug(s"Addon stdout: $out")
result = Option
.when(ctx.meta.options.exists(_.collectOutput) && out.nonEmpty)(
.when(ctx.meta.parseResult && out.nonEmpty)(
JsonParser
.decode[AddonOutput](out)
.fold(AddonResult.decodingError, AddonResult.success)

View File

@ -35,4 +35,13 @@ class AddonMetaTest extends CatsEffectSuite with TestLoggingConfig with Fixtures
_ = assertEquals(meta, dummyAddonMeta)
} yield ()
}
test("parse yaml with defaults") {
val yamlStr = """meta:
| name: "test"
| version: "0.1.0"
|""".stripMargin
val meta = AddonMeta.fromYamlString(yamlStr).fold(throw _, identity)
assert(meta.parseResult)
}
}