Skip to content

Commit

Permalink
Merge ee8b0b4 into aa4a134
Browse files Browse the repository at this point in the history
  • Loading branch information
okv committed Nov 29, 2018
2 parents aa4a134 + ee8b0b4 commit 97753b3
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/distributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ Distributor.prototype._runNext = function(callback) {
var stepCallback = this.slot();

var executor = node.runExecutor(executorId, executorParams, function(err) {
if (err && !err.projectStepError) {
logger.error(
'Error during project execution: ', err.stack || err
);
}

var changes = {
endDate: Date.now(),
completed: true
Expand Down
11 changes: 10 additions & 1 deletion lib/executor/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,16 @@ Executor.prototype.run = function(callback) {
};
});

funcs.push(this.slot());

var stepCallback = this.slot();
funcs.push(function(err) {
if (err) {
err.projectStepError = true;
}

stepCallback(err);
});

Steppy.apply(this, funcs);
},
function() {
Expand Down
76 changes: 76 additions & 0 deletions test/executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,82 @@ _(['local']).each(function(type) {
}
);


describe(
'with error produced by project step',
function() {
before(clearWorkspace);

it('instance should be created without errors', function() {
executor = createExecutor(makeExecutorParams({
project: {
steps: [
{type: 'shell', cmd: 'echo1'}
]
}
}));
});

var executorError;

it('should run with error', function(done) {
executor.run(function(err) {
expect(err).an(Error);
expect(err.message).match(/Error.*echo1/);
executorError = err;

done();
});
});

it(
'should produce error with `projectStepError`',
function() {
expect(executorError).have.key('projectStepError');
expect(executorError.projectStepError).equal(true);
}
);
}
);

describe(
'with error produced by scm (internal call)',
function() {
before(clearWorkspace);

it('instance should be created without errors', function() {
var executorParams = makeExecutorParams();
executorParams.project.scm = _({}).extend(
executorParams.project.scm,
{type: 'non-existing type'}
);

executor = createExecutor(executorParams);
});

var executorError;

it('should run with error', function(done) {
executor.run(function(err) {
expect(err).an(Error);
expect(err.message).eql(
'unknown scm type: non-existing type'
);
executorError = err;

done();
});
});

it(
'should produce error without `projectStepError`',
function() {
expect(executorError).not.have.key('projectStepError');
}
);
}
);

});

});

0 comments on commit 97753b3

Please sign in to comment.