@@ -74,42 +74,73 @@ module.exports = function (grunt) {
7474 }
7575 ] ;
7676
77- // var sauceJobs = {};
78-
79- // [ "main",
80- // "filemanager-plugin",
81- // "visitor-plugin",
82- // "pre-processor-plugin",
83- // "post-processor-plugin",
84- // "global-vars",
85- // "modify-vars",
86- // "production",
87- // "rootpath-relative",
88- // "rootpath",
89- // "relative-urls",
90- // "browser",
91- // "no-js-errors",
92- // "legacy",
93- // "strict-units"
94- // ].map(function(testName) {
95- // sauceJobs[testName] = {
96- // options: {
97- // urls: ["http://localhost:8081/tmp/browser/test-runner-" + testName + ".html"],
98- // testname: 'Less.js test - ' + testName,
99- // browsers: browsers,
100- // public: 'public',
101- // recordVideo: false,
102- // videoUploadOnPass: false,
103- // recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
104- // build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
105- // tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH],
106- // sauceConfig: {
107- // 'idle-timeout': 100
108- // },
109- // throttled: 5
110- // }
111- // };
112- // });
77+ var sauceJobs = { } ;
78+
79+ var browserTests = [ "filemanager-plugin" ,
80+ "visitor-plugin" ,
81+ "global-vars" ,
82+ "modify-vars" ,
83+ "production" ,
84+ "rootpath-relative" ,
85+ "rootpath" ,
86+ "relative-urls" ,
87+ "browser" ,
88+ "no-js-errors" ,
89+ "legacy"
90+ ] ;
91+
92+ browserTests . map ( function ( testName ) {
93+ sauceJobs [ testName ] = {
94+ options : {
95+ urls : [ "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html" ] ,
96+ testname : 'Less.js test - ' + testName ,
97+ browsers : browsers ,
98+ public : 'public' ,
99+ recordVideo : false ,
100+ videoUploadOnPass : false ,
101+ recordScreenshots : process . env . TRAVIS_BRANCH !== "master" ,
102+ build : process . env . TRAVIS_BRANCH === "master" ? process . env . TRAVIS_JOB_ID : undefined ,
103+ tags : [ process . env . TRAVIS_BUILD_NUMBER , process . env . TRAVIS_PULL_REQUEST , process . env . TRAVIS_BRANCH ] ,
104+ sauceConfig : {
105+ 'idle-timeout' : 100
106+ } ,
107+ throttled : 5 ,
108+ onTestComplete : function ( result , callback ) {
109+ // Called after a unit test is done, per page, per browser
110+ // 'result' param is the object returned by the test framework's reporter
111+ // 'callback' is a Node.js style callback function. You must invoke it after you
112+ // finish your work.
113+ // Pass a non-null value as the callback's first parameter if you want to throw an
114+ // exception. If your function is synchronous you can also throw exceptions
115+ // directly.
116+ // Passing true or false as the callback's second parameter passes or fails the
117+ // test. Passing undefined does not alter the test result. Please note that this
118+ // only affects the grunt task's result. You have to explicitly update the Sauce
119+ // Labs job's status via its REST API, if you want so.
120+
121+ // This should be the encrypted value in Travis
122+ var user = process . env . SAUCE_USERNAME ;
123+ var pass = process . env . SAUCE_ACCESS_KEY ;
124+
125+ require ( 'request' ) . put ( {
126+ url : [ 'https://saucelabs.com/rest/v1' , user , 'jobs' , result . job_id ] . join ( '/' ) ,
127+ auth : { user : user , pass : pass } ,
128+ json : { passed : result . passed }
129+ } , function ( error , response , body ) {
130+ if ( error ) {
131+ console . log ( error ) ;
132+ callback ( error ) ;
133+ } else if ( response . statusCode !== 200 ) {
134+ console . log ( response ) ;
135+ callback ( new Error ( 'Unexpected response status' ) ) ;
136+ } else {
137+ callback ( null , result . passed ) ;
138+ }
139+ } ) ;
140+ }
141+ }
142+ } ;
143+ } ) ;
113144 // Project configuration.
114145 grunt . initConfig ( {
115146
@@ -378,62 +409,64 @@ module.exports = function (grunt) {
378409 }
379410 } ,
380411
381- 'saucelabs-jasmine' : {
382- all : {
383- options : {
384- urls : [ "main" , "filemanager-plugin" , "visitor-plugin" , "pre-processor-plugin" , "post-processor-plugin" , "global-vars" , "modify-vars" , "production" , "rootpath-relative" ,
385- "rootpath" , "relative-urls" , "browser" , "no-js-errors" , "legacy" , "strict-units"
386- ] . map ( function ( testName ) {
387- return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html" ;
388- } ) ,
389- testname : 'Sauce Unit Test for less.js' ,
390- browsers : browsers ,
391- public : 'public' ,
392- pollInterval : 2000 ,
393- statusCheckAttempts : 30 ,
394- recordVideo : false ,
395- videoUploadOnPass : false ,
396- recordScreenshots : process . env . TRAVIS_BRANCH !== "master" ,
397- build : process . env . TRAVIS_BRANCH === "master" ? process . env . TRAVIS_JOB_ID : undefined ,
398- tags : [ process . env . TRAVIS_BUILD_NUMBER , process . env . TRAVIS_PULL_REQUEST , process . env . TRAVIS_BRANCH ] ,
399- sauceConfig : {
400- 'idle-timeout' : 100
401- } ,
402- throttled : 5 ,
403- onTestComplete : function ( result , callback ) {
404- // Called after a unit test is done, per page, per browser
405- // 'result' param is the object returned by the test framework's reporter
406- // 'callback' is a Node.js style callback function. You must invoke it after you
407- // finish your work.
408- // Pass a non-null value as the callback's first parameter if you want to throw an
409- // exception. If your function is synchronous you can also throw exceptions
410- // directly.
411- // Passing true or false as the callback's second parameter passes or fails the
412- // test. Passing undefined does not alter the test result. Please note that this
413- // only affects the grunt task's result. You have to explicitly update the Sauce
414- // Labs job's status via its REST API, if you want so.
412+ 'saucelabs-jasmine' : sauceJobs ,
413+
414+ // {
415+ // all: {
416+ // options: {
417+ // urls: ["filemanager-plugin","visitor-plugin","pre-processor-plugin","post-processor-plugin","global-vars", "modify-vars", "production", "rootpath-relative",
418+ // "rootpath", "relative-urls", "browser", "no-js-errors", "legacy", "strict-units"
419+ // ].map(function(testName) {
420+ // return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html";
421+ // }),
422+ // testname: 'Sauce Unit Test for less.js',
423+ // browsers: browsers,
424+ // public: 'public',
425+ // pollInterval: 2000,
426+ // statusCheckAttempts: 30,
427+ // recordVideo: false,
428+ // videoUploadOnPass: false,
429+ // recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
430+ // build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
431+ // tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH],
432+ // sauceConfig: {
433+ // 'idle-timeout': 100
434+ // },
435+ // throttled: 5,
436+ // onTestComplete: function(result, callback) {
437+ // // Called after a unit test is done, per page, per browser
438+ // // 'result' param is the object returned by the test framework's reporter
439+ // // 'callback' is a Node.js style callback function. You must invoke it after you
440+ // // finish your work.
441+ // // Pass a non-null value as the callback's first parameter if you want to throw an
442+ // // exception. If your function is synchronous you can also throw exceptions
443+ // // directly.
444+ // // Passing true or false as the callback's second parameter passes or fails the
445+ // // test. Passing undefined does not alter the test result. Please note that this
446+ // // only affects the grunt task's result. You have to explicitly update the Sauce
447+ // // Labs job's status via its REST API, if you want so.
415448
416- // This should be the encrypted value in Travis
417- var user = process . env . SAUCE_USERNAME ;
418- var pass = process . env . SAUCE_ACCESS_KEY ;
419-
420- require ( 'request' ) . put ( {
421- url : [ 'https://saucelabs.com/rest/v1' , user , 'jobs' , result . job_id ] . join ( '/' ) ,
422- auth : { user : user , pass : pass } ,
423- json : { passed : result . passed }
424- } , function ( error , response , body ) {
425- if ( error ) {
426- callback ( error ) ;
427- } else if ( response . statusCode !== 200 ) {
428- callback ( new Error ( 'Unexpected response status' ) ) ;
429- } else {
430- callback ( null , result . passed ) ;
431- }
432- } ) ;
433- }
434- }
435- }
436- } ,
449+ // // This should be the encrypted value in Travis
450+ // var user = process.env.SAUCE_USERNAME;
451+ // var pass = process.env.SAUCE_ACCESS_KEY;
452+
453+ // require('request').put({
454+ // url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
455+ // auth: { user: user, pass: pass },
456+ // json: { passed: result.passed }
457+ // }, function (error, response, body) {
458+ // if (error) {
459+ // callback(error);
460+ // } else if (response.statusCode !== 200) {
461+ // callback(new Error('Unexpected response status'));
462+ // } else {
463+ // callback(null, result.passed);
464+ // }
465+ // });
466+ // }
467+ // }
468+ // }
469+ // },
437470
438471 // Clean the version of less built for the tests
439472 clean : {
@@ -511,11 +544,12 @@ module.exports = function (grunt) {
511544 'sauce-after-setup'
512545 ] ) ;
513546
514- // setup a web server to run the browser tests in a browser rather than phantom
515- grunt . registerTask ( 'sauce-after-setup' , [
516- 'saucelabs-jasmine' ,
517- 'clean:sauce_log'
518- ] ) ;
547+ var sauceTests = [ ] ;
548+ browserTests . map ( function ( testName ) {
549+ sauceTests . push ( 'saucelabs-jasmine:' + testName ) ;
550+ } ) ;
551+ sauceTests . push ( 'clean:sauce_log' ) ;
552+ grunt . registerTask ( 'sauce-after-setup' , sauceTests ) ;
519553
520554 var testTasks = [
521555 'clean' ,
0 commit comments