From fa406812355dab03fe539e11204ddbfba1d5abb8 Mon Sep 17 00:00:00 2001 From: ansgarz <ansgar.zwick@meissa.de> Date: Thu, 27 Feb 2025 21:40:44 +0100 Subject: [PATCH] [skip ci] remove method printDeprecationWarningIfLevel0 as neither useful nor necessary --- .../provs/framework/core/Prov.kt | 12 ----- .../provs/framework/core/ProvTest.kt | 53 ------------------- 2 files changed, 65 deletions(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt index b6cc544..3023af4 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt @@ -84,7 +84,6 @@ open class Prov protected constructor( * Returns success if all sub-tasks finished with success or if no sub-tasks are called at all. */ fun task(name: String? = null, taskLambda: Prov.() -> Unit): ProvResult { - printDeprecationWarningIfLevel0("task") return evaluate(ResultMode.ALL, name) { taskLambda(); ProvResult(true) } } @@ -95,7 +94,6 @@ open class Prov protected constructor( * taskWithResult also fails, else success depends on potentially called sub-tasks. */ fun taskWithResult(name: String? = null, taskLambda: Prov.() -> ProvResult): ProvResult { - printDeprecationWarningIfLevel0("taskWithResult") return evaluate(ResultMode.ALL, name) { taskLambda() } } @@ -103,7 +101,6 @@ open class Prov protected constructor( * defines a task, which returns the returned result from the lambda, the results of sub-tasks are not considered */ fun requireLast(name: String? = null, taskLambda: Prov.() -> ProvResult): ProvResult { - printDeprecationWarningIfLevel0("requireLast") return evaluate(ResultMode.LAST, name) { taskLambda() } } @@ -111,7 +108,6 @@ open class Prov protected constructor( * Defines a task, which always returns success. */ fun optional(name: String? = null, taskLambda: Prov.() -> ProvResult): ProvResult { - printDeprecationWarningIfLevel0("optional") return evaluate(ResultMode.OPTIONAL, name) { taskLambda() } } @@ -119,7 +115,6 @@ open class Prov protected constructor( * Defines a task, which exits the overall execution on failure result of the taskLambda. */ fun exitOnFailure(taskLambda: Prov.() -> ProvResult): ProvResult { - printDeprecationWarningIfLevel0("exitOnFailure") return evaluate(ResultMode.FAILEXIT) { taskLambda() } } @@ -127,7 +122,6 @@ open class Prov protected constructor( * Runs the provided task in the specified (running) container */ fun taskInContainer(containerName: String, taskLambda: Prov.() -> ProvResult): ProvResult { - printDeprecationWarningIfLevel0("taskInContainer") runInContainerWithName = containerName val res = evaluate(ResultMode.ALL) { taskLambda() } runInContainerWithName = null @@ -485,12 +479,6 @@ open class Prov protected constructor( } } } - - fun printDeprecationWarningIfLevel0(methodName: String) { - if (level == 0 && progressType != ProgressType.NONE) { - println("WARNING: method $methodName should not be used at top-level, use method <session> instead.") - } - } } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/ProvTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/ProvTest.kt index c592715..3f4189d 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/ProvTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/core/ProvTest.kt @@ -810,57 +810,4 @@ internal class ProvTest { exception.message ) } - - // method for task_warning_for_task_on_top_level_is_in_output - // must be declared outside test task_warning_for_task_on_top_level_is_in_output in order to avoid strange naming in result output - fun Prov.tst_task() = task { - task_returningTrue() - task_returningFalse() - } - - @Test - fun task_warning_for_task_on_top_level_is_in_output() { - // given - setRootLoggingLevel(Level.OFF) - - val outContent = ByteArrayOutputStream() - val errContent = ByteArrayOutputStream() - val originalOut = System.out - val originalErr = System.err - - System.setOut(PrintStream(outContent)) - System.setErr(PrintStream(errContent)) - - // when - Prov.newInstance(name = "test instance with no progress info", progressType = ProgressType.BASIC) - .tst_task().success - Prov.newInstance(name = "test instance with no progress info", progressType = ProgressType.BASIC) - .tst_task().success // test that also second run gets warning - - // then - System.setOut(originalOut) - System.setErr(originalErr) - - println(outContent.toString()) - - val expectedOutputOneRun = - "WARNING: method task should not be used at top-level, use method <session> instead.\n" + - "---------- Processing started ----------\n" + - "> \u001B[90mexecuting...\u001B[0m -- tst_task\n" + - "---> \u001B[90mexecuting...\u001B[0m -- task_returningTrue\n" + - "---> \u001B[90mexecuting...\u001B[0m -- task_returningFalse\n" + - "---------- Processing completed ----------\n" + - "============================================== SUMMARY (test instance with no progress info) =============================================\n" + - "> \u001B[91mFAILED\u001B[0m -- tst_task \n" + - "---> \u001B[92mSuccess\u001B[0m -- task_returningTrue \n" + - "---> \u001B[91mFAILED\u001B[0m -- task_returningFalse \n" + - "----------------------------------------------------------------------------------------------------\n" + - "Overall > \u001B[91mFAILED\u001B[0m \n" + - "============================================ SUMMARY END ===========================================\n" + - "\n" - - val expectedOutputDoubleRun = expectedOutputOneRun + expectedOutputOneRun - - assertEquals(expectedOutputDoubleRun, outContent.toString().replace("\r", "")) - } }