exclude the title test from running on Macs running node less than 10

This commit is contained in:
Dan Rowe 2013-07-03 17:25:53 -04:00
Родитель 4541e11702
Коммит 23aab12cd2
2 изменённых файлов: 26 добавлений и 26 удалений

Просмотреть файл

@ -19,14 +19,7 @@ exports.init = function(config) {
exports.set_title = function(config) {
if (config.title !== undefined) {
if (config.title) {
if (process.title.length >= config.title.length) {
process.title = config.title;
} else {
// check that conf is defined so we don't error in tests
if (conf !== undefined && conf.debug) {
util.log("config.title is to long, needs to be less than or equal to" + process.title.length);
}
}
}
} else {
process.title = 'statsd';

Просмотреть файл

@ -1,32 +1,34 @@
var process_mgmt = require('../lib/process_mgmt');
var process_mgmt = require('../lib/process_mgmt')
, os = require('os');
var config = {}
, can_set_title = true;
module.exports = {
setUp: function(callback) {
config = {};
version_number = process.version.split(".")[1];
platform = os.platform();
can_set_title = (version_number >= 10 || platform != 'darwin');
callback();
},
test_valid_title: function(test){
test.expect(1);
process_title = process.title;
config.title = process_title.substring(1);
process_mgmt.set_title(config);
test.ok(process.title == config.title, "Can set a title that is less than or equal to the process title length");
test.done();
},
test_invalid_title: function(test){
process_title = process.title;
test_title = process.title + "1";
config.title = test_title;
process_mgmt.set_title(config);
test.ok(process.title == process_title, "Can't set a title that is longer than the process.title length");
test_setting_title: function(test){
if (can_set_title) {
test.expect(1);
process_title = process.title;
config.title = "test-statsd";
process_mgmt.set_title(config);
test.ok(process.title == config.title, "Can set a title that is less than or equal to the process title length");
} else {
console.log("Not running this test, due to this being a node version before v0.10 and a Darwin os");
}
test.done();
},
test_no_title: function(test){
test.expect(1);
process_title = process.title;
config.title = false;
process_mgmt.set_title(config);
@ -35,9 +37,14 @@ module.exports = {
},
test_default_title: function(test){
default_title = 'statsd';
process_mgmt.set_title(config);
test.ok(process.title == default_title, "If no config.title option set, set the process.title to statsd");
if (can_set_title) {
test.expect(1);
default_title = 'statsd';
process_mgmt.set_title(config);
test.ok(process.title == default_title, "If no config.title option set, set the process.title to statsd");
} else {
console.log("Not running this test, due to this being a node version before v0.10 and a Darwin os");
}
test.done();
}