diff --git a/baseline-cli/src/main/kotlin/BaselineCli.kt b/baseline-cli/src/main/kotlin/BaselineCli.kt index d1b6770..cf288fa 100644 --- a/baseline-cli/src/main/kotlin/BaselineCli.kt +++ b/baseline-cli/src/main/kotlin/BaselineCli.kt @@ -112,13 +112,14 @@ internal object BaselineCli { cliPrinter: (String) -> Unit, errPrinter: (String) -> Unit ): Int { - if (!Files.exists(baselinePath)) { - errPrinter("Please provide valid baseline report path") - return ERROR_EXIT - } val baseline: SarifReport try { - baseline = SarifUtil.readReport(baselinePath) ?: createSarifReport(emptyList()) + if (!Files.exists(baselinePath)) { + cliPrinter("Can't find baseline report file: $baselinePath. Baseline will be calculated against empty report.") + baseline = createSarifReport(emptyList()) + } else { + baseline = SarifUtil.readReport(baselinePath) ?: createSarifReport(emptyList()) + } } catch (e: JsonSyntaxException) { errPrinter("Error reading baseline report: ${e.message}") return ERROR_EXIT diff --git a/baseline-cli/src/test/kotlin/BaselineCliTest.kt b/baseline-cli/src/test/kotlin/BaselineCliTest.kt index f3177ed..6e53107 100644 --- a/baseline-cli/src/test/kotlin/BaselineCliTest.kt +++ b/baseline-cli/src/test/kotlin/BaselineCliTest.kt @@ -47,8 +47,9 @@ class BaselineCliTest { } // Assert - assertEquals(ERROR_EXIT, exitCode) - assertEquals("Please provide valid baseline report path", stderr.toString()) + assertEquals(0, exitCode) + assertTrue(stdout.contains("Can't find baseline report file: nonExistentBaselineReport.sarif.")) + assertTrue(stderr.contains("Found 2 new problems according to the checks applied")) } @Test