From 562299c761bf74666509a95fbf4bbc8f0dfebd1a Mon Sep 17 00:00:00 2001 From: David Worms Date: Tue, 9 Mar 2021 21:32:19 +0100 Subject: [PATCH] fix(core): bastard applied to all conditions and assertions --- packages/core/src/plugins/args.coffee | 2 -- packages/core/src/plugins/assertions.coffee | 6 ------ .../core/src/plugins/assertions_exists.coffee | 10 ++-------- packages/core/src/plugins/conditions.coffee | 10 ++-------- .../core/src/plugins/conditions_execute.coffee | 6 ------ .../core/src/plugins/conditions_exists.coffee | 6 ------ packages/core/src/plugins/conditions_os.coffee | 8 ++------ packages/core/test/actions/log/md.coffee | 15 --------------- 8 files changed, 6 insertions(+), 57 deletions(-) diff --git a/packages/core/src/plugins/args.coffee b/packages/core/src/plugins/args.coffee index 1e6e379dc..54df52175 100644 --- a/packages/core/src/plugins/args.coffee +++ b/packages/core/src/plugins/args.coffee @@ -17,9 +17,7 @@ module.exports = if child?.metadata?.raw_input #or child?.metadata?.raw arguments[0].args = [{}] -> - # console.log child, args actions = handler.apply null, arguments - # console.log actions # If raw_input is activated, just pass arguments as is # Always one action since arguments are erased if child?.metadata?.raw_input diff --git a/packages/core/src/plugins/assertions.coffee b/packages/core/src/plugins/assertions.coffee index 7dfcdb259..398f67787 100644 --- a/packages/core/src/plugins/assertions.coffee +++ b/packages/core/src/plugins/assertions.coffee @@ -41,10 +41,7 @@ handlers = for assertion in action.assertions.assert if typeof assertion is 'function' run = await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $assertion: true $depth: action.metadata.depth $raw_output: true $raw_input: true @@ -64,10 +61,7 @@ handlers = for assertion in action.assertions.unassert if typeof assertion is 'function' run = await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $assertion: true $depth: action.metadata.depth $raw_output: true $raw_input: true diff --git a/packages/core/src/plugins/assertions_exists.coffee b/packages/core/src/plugins/assertions_exists.coffee index e9629b69f..125b76b6f 100644 --- a/packages/core/src/plugins/assertions_exists.coffee +++ b/packages/core/src/plugins/assertions_exists.coffee @@ -18,7 +18,6 @@ module.exports = handler: (action, handler) -> # Ventilate assertions properties defined at root assertions = {} - # console.log action.metadata for property, value of action.metadata if /^(un)?assert_exists$/.test property throw Error 'ASSERTION_DUPLICATED_DECLARATION', [ @@ -45,13 +44,9 @@ module.exports = handlers = assert_exists: (action) -> final_run = true - # console.log action for assertion in action.assertions.assert_exists run = await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $assertion: true $depth: action.metadata.depth $raw_output: true $raw_input: true @@ -65,12 +60,11 @@ handlers = final_run = true for assertion in action.assertions.unassert_exists run = await session - $hooks: - on_result: ({action}) -> delete action.parent - $condition: true + $bastard: true $depth: action.metadata.depth $parent: action $raw_output: true + $raw_input: true $parent: action , -> {exists} = await @fs.base.exists target: assertion diff --git a/packages/core/src/plugins/conditions.coffee b/packages/core/src/plugins/conditions.coffee index 00f3f67e6..3da392f7f 100644 --- a/packages/core/src/plugins/conditions.coffee +++ b/packages/core/src/plugins/conditions.coffee @@ -12,9 +12,7 @@ module.exports = handler: (action, handler) -> # Ventilate conditions properties defined at root conditions = {} - # console.log action.metadata for property, value of action.metadata - # console.log property, /^(if|unless)($|_[\w_]+$)/.test property if /^(if|unless)($|_[\w_]+$)/.test property throw Error 'CONDITIONS_DUPLICATED_DECLARATION', [ "Property #{property} is defined multiple times," @@ -44,9 +42,7 @@ handlers = for condition in action.conditions.if if typeof condition is 'function' condition = await session - $hooks: - on_result: ({action}) -> delete action.parent - $condition: true + $bastard: true $depth: action.metadata.depth $parent: action $raw_output: true @@ -72,9 +68,7 @@ handlers = for condition in action.conditions.unless if typeof condition is 'function' condition = await session - $hooks: - on_result: ({action}) -> delete action.parent - $condition: true + $bastard: true $depth: action.metadata.depth $parent: action $raw_output: true diff --git a/packages/core/src/plugins/conditions_execute.coffee b/packages/core/src/plugins/conditions_execute.coffee index 51e931fe5..3cb62dbbd 100644 --- a/packages/core/src/plugins/conditions_execute.coffee +++ b/packages/core/src/plugins/conditions_execute.coffee @@ -25,10 +25,7 @@ handlers = for condition in action.conditions.if_execute try {$status} = await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $condition: true $depth: action.metadata.depth $namespace: ['execute'] $parent: action @@ -45,10 +42,7 @@ handlers = for condition in action.conditions.unless_execute try {$status} = await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $condition: true $depth: action.metadata.depth $namespace: ['execute'] $parent: action diff --git a/packages/core/src/plugins/conditions_exists.coffee b/packages/core/src/plugins/conditions_exists.coffee index 18c80335d..cc0e7527f 100644 --- a/packages/core/src/plugins/conditions_exists.coffee +++ b/packages/core/src/plugins/conditions_exists.coffee @@ -24,10 +24,7 @@ handlers = for condition in action.conditions.if_exists try await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $condition: true $depth: action.metadata.depth $parent: action , -> @@ -42,10 +39,7 @@ handlers = for condition in action.conditions.unless_exists try await session - # $hooks: - # on_result: ({action}) -> delete action.parent $bastard: true - # $condition: true $depth: action.metadata.depth $parent: action , -> diff --git a/packages/core/src/plugins/conditions_os.coffee b/packages/core/src/plugins/conditions_os.coffee index 03690dbcf..99494dc58 100644 --- a/packages/core/src/plugins/conditions_os.coffee +++ b/packages/core/src/plugins/conditions_os.coffee @@ -47,9 +47,7 @@ handlers = if_os: (action) -> final_run = true await session - $hooks: - on_result: ({action}) -> delete action.parent - $condition: true + $bastard: true $depth: action.metadata.depth $parent: action , -> @@ -82,9 +80,7 @@ handlers = unless_os: (action) -> final_run = true await session - $hooks: - on_result: ({action}) -> delete action.parent - $condition: true + $bastard: true $depth: action.metadata.depth $parent: action , -> diff --git a/packages/core/test/actions/log/md.coffee b/packages/core/test/actions/log/md.coffee index a6a38f9b1..977e3b1ed 100644 --- a/packages/core/test/actions/log/md.coffee +++ b/packages/core/test/actions/log/md.coffee @@ -7,21 +7,6 @@ return unless tags.posix describe 'actions.log.md', -> - they 'compatible with pseudo-child sessions', ({ssh}) -> - # if_exists, if_execute... - nikita - $ssh: ssh - $tmpdir: true - , ({metadata: {tmpdir}}) -> - await @log.md basedir: tmpdir - await @call - $unless_exists: "#{tmpdir}/toto" - , -> - console.log 'ok' - await @fs.assert - target: "#{tmpdir}/localhost.log" - content: /^Entering.*$/mg - they 'write entering message', ({ssh}) -> nikita $ssh: ssh