Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
#2 Ensure TeamCity messages don't get parsed twice
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhunter committed Oct 9, 2013
1 parent d6ab4b0 commit 4084e15
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Gruntfile.js
Expand Up @@ -68,4 +68,7 @@ module.exports = function(grunt) {
grunt.registerTask('isolated_test', function(){
grunt.log.warn('foo-bar-uniqe-string');
});
grunt.registerTask('isolated_test_parse_twice', function(){
grunt.log.warn("##teamcity['someMessage']");
});
};
10 changes: 7 additions & 3 deletions tasks/teamcity.js
Expand Up @@ -73,9 +73,13 @@ module.exports = function(grunt) {
}

function tcFormat(text, status, errorDetails) {
return ("##teamcity[message text='" + text +
"' errorDetails='" + (errorDetails || '') +
"' status='" + status + "']\n").grey;
if (text.indexOf('##teamcity[') !== -1) {
return text;
}

return ("##teamcity[message text='" + text +
"' errorDetails='" + (errorDetails || '') +
"' status='" + status + "']\n").grey;
}

// verbatum from grunt.log
Expand Down
14 changes: 14 additions & 0 deletions test/teamcity_test.js
Expand Up @@ -69,5 +69,19 @@ exports.teamcity = {
test.equal(tcMsgCount, 1, 'Message is output in Teamcity format with custom status');
test.done();
});
},
message_not_parsed_twice: function(test){
test.expect(1);
exec('grunt teamcity:default_options isolated_test_parse_twice --no-color', function(err, stdout){
var tcMsgCount = 0;
stdout.split('\n').forEach(function(line){
if (line.contains("##teamcity[message text='##teamcity['someMessage']' errorDetails='' status='ERROR'")) {
tcMsgCount++;
}
});

test.equal(tcMsgCount, 0, 'Teamcity messages are not parsed twice');
test.done();
});
}
};

0 comments on commit 4084e15

Please sign in to comment.