Skip to content

Commit

Permalink
Add environment variables for sauce-labs in Grunt task
Browse files Browse the repository at this point in the history
To use sauce testing from a dev machine please contact ichernev on github.
  • Loading branch information
ichernev committed Dec 28, 2013
1 parent 8a57d61 commit 87238c4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
23 changes: 15 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ module.exports = function (grunt) {
dest: 'min/tests.js'
}
},

karma: {
env : {
sauceLabs : (grunt.file.exists('.sauce-labs.creds') ?
grunt.file.readJSON('.sauce-labs.creds') : {})
},
karma : {
options: {
frameworks: ['nodeunit'],
files: [
'min/moment-with-langs.js',
'min/tests.js',
// 'test/moment/**/*.js',
// 'test/lang/**/*.js',
'test/browser.js'
],
sauceLabs: {
Expand Down Expand Up @@ -175,6 +176,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-karma');

// Default task.
Expand All @@ -184,12 +186,17 @@ module.exports = function (grunt) {
grunt.registerTask('test', ['test:node', 'test:browser']);
grunt.registerTask('test:node', ['nodeunit']);
grunt.registerTask('test:browser', ['concat', 'embed_languages', 'karma:chrome']);
grunt.registerTask('test:sauce-browser', ['concat', 'embed_languages', 'karma:sauce']);
grunt.registerTask('test:sauce-browser', ['concat', 'embed_languages', 'env:sauceLabs', 'karma:sauce']);
grunt.registerTask('test:travis-sauce-browser', ['concat', 'embed_languages', 'karma:sauce']);

// travis build task
grunt.registerTask('build:travis', ['jshint', 'test:node', 'test:sauce-browser']);
grunt.registerTask('build:travis', [
'jshint', 'test:node', 'test:travis-sauce-browser'
]);

// Task to be run when releasing a new version
grunt.registerTask('release', ['jshint', 'nodeunit', 'concat',
'embed_languages', 'component', 'uglify']);
grunt.registerTask('release', [
'jshint', 'nodeunit', 'concat', 'embed_languages',
'component', 'uglify'
]);
};
29 changes: 13 additions & 16 deletions min/moment-with-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@

// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
isoRegex = /^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,
isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,

isoFormat = 'YYYY-MM-DDTHH:mm:ssZ',

isoDates = [
'YYYY-MM-DD',
'GGGG-[W]WW',
'GGGG-[W]WW-E',
'YYYY-DDD'
['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
['GGGG-[W]WW', /\d{4}-W\d{2}/],
['YYYY-DDD', /\d{4}-\d{3}/]
],

// iso time formats and regexes
Expand Down Expand Up @@ -366,7 +367,7 @@
// left zero fill a number
// see http://jsperf.com/left-zero-filling for performance comparison
function leftZeroFill(number, targetLength, forceSign) {
var output = Math.abs(number) + '',
var output = '' + Math.abs(number),
sign = number >= 0;

while (output.length < targetLength) {
Expand Down Expand Up @@ -1342,20 +1343,20 @@

// date from iso format
function makeDateFromString(config) {
var i,
var i, l,
string = config._i,
match = isoRegex.exec(string);

if (match) {
config._pf.iso = true;
for (i = 4; i > 0; i--) {
if (match[i]) {
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(string)) {
// match[5] should be "T" or undefined
config._f = isoDates[i - 1] + (match[6] || " ");
config._f = isoDates[i][0] + (match[6] || " ");
break;
}
}
for (i = 0; i < 4; i++) {
for (i = 0, l = isoTimes.length; i < l; i++) {
if (isoTimes[i][1].exec(string)) {
config._f += isoTimes[i][0];
break;
Expand Down Expand Up @@ -1496,11 +1497,7 @@

//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
// The only solid way to create an iso date from year is to use
// a string format (Date.UTC handles only years > 1900). Don't ask why
// it doesn't need Z at the end.
var d = new Date(leftZeroFill(year, 6, true) + '-01-01').getUTCDay(),
daysToAdd, dayOfYear;
var d = makeUTCDate(year, 0, 1).getUTCDay(), daysToAdd, dayOfYear;

weekday = weekday != null ? weekday : firstDayOfWeek;
daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"grunt-contrib-concat": "latest",
"grunt-contrib-uglify": "latest",
"grunt-contrib-watch": "latest",
"grunt-env": "latest",
"grunt-lib-legacyhelpers": "latest",
"grunt-karma": "~0.7.2",
"karma": "~0.11.0",
Expand Down

0 comments on commit 87238c4

Please sign in to comment.