Skip to content

Commit

Permalink
fix(core): bastard applied to all conditions and assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Mar 9, 2021
1 parent 3fdaf1d commit 562299c
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 57 deletions.
2 changes: 0 additions & 2 deletions packages/core/src/plugins/args.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/plugins/assertions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 2 additions & 8 deletions packages/core/src/plugins/assertions_exists.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 2 additions & 8 deletions packages/core/src/plugins/conditions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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,"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/plugins/conditions_execute.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/plugins/conditions_exists.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
, ->
Expand All @@ -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
, ->
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/plugins/conditions_os.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
, ->
Expand Down Expand Up @@ -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
, ->
Expand Down
15 changes: 0 additions & 15 deletions packages/core/test/actions/log/md.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 562299c

Please sign in to comment.