Skip to content

Commit

Permalink
Updated test and refactored code, according to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniilsavchuk committed May 15, 2017
1 parent 51d85de commit 65f1f00
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 23 deletions.
25 changes: 3 additions & 22 deletions src/parser/WDL/entities/WDLWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,29 +170,10 @@ export default class WDLWorkflow {

resolveBinding(node, step, parentStep) {
const nodeValue = node.attributes.value;
const attributes = nodeValue.attributes;

const declaration = node.attributes.key ? node.attributes.key.source_string : undefined;

if (declaration && nodeValue.name === 'MemberAccess') {
const rhsPart = attributes && attributes.rhs ? attributes.rhs.source_string : '';
const lhsPart = attributes && attributes.lhs ? attributes.lhs.source_string : '';

const startStep = WDLWorkflow.findStepInStructureRecursively(this.workflowStep, lhsPart);
if (startStep && step) {
step.i[declaration].bind(startStep.o[rhsPart]);
}
} else if (declaration && nodeValue.str === 'identifier') {
const portName = nodeValue.source_string;
const portStep = WDLWorkflow.groupNameResolver(parentStep, portName);
if (_.isUndefined(portStep)) {
step.i[declaration].bind(portName);
} else {
step.i[declaration].bind(portStep.i[portName]);
}
} else {
const declaration = node.attributes.key.source_string;
if (declaration) {
const expression = extractExpression(nodeValue);
step.i[declaration].bind(expression.string);
step.i[declaration].bind(WDLWorkflow.getPortForBinding(this.workflowStep, parentStep, expression));
}
}

Expand Down
125 changes: 124 additions & 1 deletion test/parser/WDL/entities/WDLWorkflowTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,130 @@ describe('parser/WDL/entities/WDLWorkflow', () => {
expect(workflow.workflowStep.children.scatter_0.type).to.equal('scatter');
});

it('supports group level name resolving', () => {
const ast = {
name: {
id: 14,
str: 'identifier',
source_string: 'foo',
line: 2,
col: 10,
},
body: {
list: [
{
name: 'Declaration',
attributes: {
type: {
id: 43,
str: 'type',
source_string: 'File',
line: 3,
col: 1,
},
name: {
id: 14,
str: 'identifier',
source_string: 'wf_input',
line: 3,
col: 6,
},
expression: null,
},
},
{
name: 'Scatter',
attributes: {
item: {
id: 14,
str: 'identifier',
source_string: 'i',
line: 3,
col: 11,
},
collection: {
id: 14,
str: 'string',
source_string: '1234',
line: 3,
col: 16,
},
body: {
list: [
{
name: 'Call',
attributes: {
task: {
id: 11,
str: 'fqn',
source_string: 'bar',
line: 3,
col: 6,
},
alias: null,
body: {
name: 'CallBody',
attributes: {
declarations: {
list: [],
},
io: {
list: [
{
name: 'Inputs',
attributes: {
map: {
list: [
{
name: 'IOMapping',
attributes: {
key: {
id: 14,
str: 'identifier',
source_string: 'currSample',
line: 8,
col: 9,
},
value: {
id: 14,
str: 'identifier',
source_string: 'wf_input',
line: 8,
col: 20,
},
},
},
],
},
},
},
],
},
},
},
},
},
],
},
},
},
],
},
};

const context = {
actionMap: {
bar: {
i: {
currSample: new Port('currSample'),
},
},
},
};
const workflow = new WDLWorkflow(ast, context);
expect(workflow.workflowStep.children.scatter_0.type).to.equal('scatter');
});

it('supports loop', () => {
const ast = {
name: {
Expand Down Expand Up @@ -591,7 +715,6 @@ describe('parser/WDL/entities/WDLWorkflow', () => {
expect(workflow.workflowStep.action.o).to.have.all.keys(['bar.out']);
});


it('supports workflow outputs with wildcard2', () => {
const ast = {
name: {
Expand Down

0 comments on commit 65f1f00

Please sign in to comment.