Add R script adapter
This commit is contained in:
@ -418,7 +418,29 @@ configureEditors: function () {
|
|||||||
card.find('.row .col-sm-9').eq(1).find('.number').eq(0).text(parseFloat((result.score * result.weight).toFixed(2)));
|
card.find('.row .col-sm-9').eq(1).find('.number').eq(0).text(parseFloat((result.score * result.weight).toFixed(2)));
|
||||||
card.find('.row .col-sm-9').eq(1).find('.number').eq(1).text(result.weight);
|
card.find('.row .col-sm-9').eq(1).find('.number').eq(1).text(result.weight);
|
||||||
card.find('.row .col-sm-9').eq(2).html(result.message);
|
card.find('.row .col-sm-9').eq(2).html(result.message);
|
||||||
if (result.error_messages) card.find('.row .col-sm-9').eq(3).text(result.error_messages.join(' '));
|
|
||||||
|
// Add error message from code to card
|
||||||
|
if (result.error_messages) {
|
||||||
|
const targetNode = card.find('.row .col-sm-9').eq(3);
|
||||||
|
|
||||||
|
// one or more errors?
|
||||||
|
if (result.error_messages.length > 1) {
|
||||||
|
// delete all current elements
|
||||||
|
targetNode.text('');
|
||||||
|
// create a new list and appand each element
|
||||||
|
const ul = document.createElement("ul");
|
||||||
|
ul.setAttribute('class', 'error_messages_list');
|
||||||
|
result.error_messages.forEach(function (item) {
|
||||||
|
var li = document.createElement("li");
|
||||||
|
var text = document.createTextNode(item);
|
||||||
|
li.appendChild(text);
|
||||||
|
ul.append(li);
|
||||||
|
})
|
||||||
|
targetNode.append(ul);
|
||||||
|
} else {
|
||||||
|
targetNode.text(result.error_messages.join(''));
|
||||||
|
}
|
||||||
|
}
|
||||||
//card.find('.row .col-sm-9').eq(4).find('a').attr('href', '#output-' + index);
|
//card.find('.row .col-sm-9').eq(4).find('a').attr('href', '#output-' + index);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -152,6 +152,11 @@ button i.fa-spin {
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error_messages_list {
|
||||||
|
list-style-type: disc;
|
||||||
|
padding-inline-start: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
.enforce-top-margin {
|
.enforce-top-margin {
|
||||||
margin-top: 5px !important;
|
margin-top: 5px !important;
|
||||||
}
|
}
|
||||||
|
17
lib/r_script_adapter.rb
Normal file
17
lib/r_script_adapter.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class RScriptAdapter < TestingFrameworkAdapter
|
||||||
|
REGEXP = /(\d+) examples?, (\d+) passed?/
|
||||||
|
ASSERTION_ERROR_REGEXP = /AssertionError:\s(.*)/
|
||||||
|
|
||||||
|
def self.framework_name
|
||||||
|
'R Script'
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_output(output)
|
||||||
|
captures = REGEXP.match(output[:stdout]).captures.map(&:to_i)
|
||||||
|
count = captures.first
|
||||||
|
passed = captures.second
|
||||||
|
failed = count - passed
|
||||||
|
assertion_error_matches = output[:stdout].scan(ASSERTION_ERROR_REGEXP).flatten || []
|
||||||
|
{count: count, failed: failed, error_messages: assertion_error_matches}
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user