Skip to content

Commit

Permalink
Don't look for _examples if we are only validating inline examples
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrosario committed Sep 18, 2024
1 parent 971ff21 commit 54de424
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 1 addition & 7 deletions application/src/main/kotlin/application/ExamplesCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ class ExamplesCommand : Callable<Unit> {
exitProcess(1)
}
} else {
val examplesDir = contractFile.absoluteFile.parentFile.resolve(contractFile.nameWithoutExtension + "_examples")
if (!examplesDir.isDirectory) {
logger.log("$examplesDir does not exist, did not find any files to validate")
exitProcess(1)
}

val (internalResult, externalResults) = ExamplesInteractiveServer.validateAll(contractFile, examplesDir)
val (internalResult, externalResults) = ExamplesInteractiveServer.validateAll(contractFile)

val hasFailures = internalResult is Result.Failure || externalResults?.any { it.value is Result.Failure } == true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class ExamplesInteractiveServer(
return file.absolutePath
}

fun validateAll(contractFile: File, examplesDir: File): Pair<Result?, Map<String, Result>?> {
fun validateAll(contractFile: File): Pair<Result?, Map<String, Result>?> {
val feature = parseContractFileToFeature(contractFile)

val (validateInline, validateExternal) = if(!Flags.getBooleanValue("VALIDATE_INLINE_EXAMPLES") && !Flags.getBooleanValue("IGNORE_INLINE_EXAMPLES")) {
Expand All @@ -356,8 +356,16 @@ class ExamplesInteractiveServer(
validateInlineExamples(feature)
} else null

val externalResult = if(validateExternal)
val externalResult = if(validateExternal) {
val examplesDir =
contractFile.absoluteFile.parentFile.resolve(contractFile.nameWithoutExtension + "_examples")
if (!examplesDir.isDirectory) {
logger.log("$examplesDir does not exist, did not find any files to validate")
exitProcess(1)
}

validateExternalExamples(examplesDir, feature)
}
else null

return inlineResult to externalResult
Expand Down

0 comments on commit 54de424

Please sign in to comment.