Skip to content

Commit

Permalink
refactor: move the should skip execution check inside skip event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
vedkribhu committed Oct 31, 2023
1 parent a9bb7c1 commit f407142
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
master:
new features:
- GH-1354 Added support for skipping execution through script
- GH-1354 Added support for skipping request execution through script

7.34.0:
date: 2023-10-19
Expand Down
7 changes: 3 additions & 4 deletions lib/runner/extensions/event.command.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ = require('lodash'),
EXECUTION_ASSERTION_EVENT_BASE = 'execution.assertion.',
EXECUTION_ERROR_EVENT_BASE = 'execution.error.',
EXECUTION_COOKIES_EVENT_BASE = 'execution.cookies.',
EXECUTION_SKIP_EVENT_BASE = 'execution.skip.',
EXECUTION_SKIP_REQUEST_EVENT_BASE = 'execution.skipRequest.',

COOKIES_EVENT_STORE_ACTION = 'store',
COOKIE_STORE_PUT_METHOD = 'putCookie',
Expand Down Expand Up @@ -448,8 +448,9 @@ module.exports = {
}.bind(this));
}.bind(this));

this.host.on(EXECUTION_SKIP_EVENT_BASE + executionId, function () {
this.host.on(EXECUTION_SKIP_REQUEST_EVENT_BASE + executionId, function () {
skippedExecutions.add(executionId);
shouldSkipExecution = true;
});

// finally execute the script
Expand Down Expand Up @@ -543,8 +544,6 @@ module.exports = {
// now that this script is done executing, we trigger the event and move to the next script
this.triggers.script(err || null, scriptCursor, result, script, event, item);

shouldSkipExecution = isExecutionSkipped(executionId);

// move to next script and pass on the results for accumulation
next(((stopOnScriptError || abortOnError || stopOnFailure) && err) ? err : null, _.assign({
event,
Expand Down
2 changes: 1 addition & 1 deletion lib/runner/extensions/item.command.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ module.exports = {
if (shouldSkipExecution) {
this.triggers.item(prereqExecutionError, coords, item);

return callback && callback.call(this, null, {
return callback && callback.call(this, prereqExecutionError, {
prerequest: prereqExecutions
});
}
Expand Down

0 comments on commit f407142

Please sign in to comment.