Skip to content

Commit

Permalink
Added property accessors - performance issue solved by re-tooling val…
Browse files Browse the repository at this point in the history
…ue parsing

i.e. All values are anonymous strings until "queried"
- Unlike original PR, no change in existing test output for un-referenced properties
- unused variables would theoretically result in a tiny improvement in parsing time
  • Loading branch information
matthew-dean committed Jul 18, 2016
1 parent c17b2f0 commit a38f8a1
Show file tree
Hide file tree
Showing 17 changed files with 827 additions and 698 deletions.
226 changes: 130 additions & 96 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,42 +74,73 @@ module.exports = function (grunt) {
}
];

// var sauceJobs = {};

// [ "main",
// "filemanager-plugin",
// "visitor-plugin",
// "pre-processor-plugin",
// "post-processor-plugin",
// "global-vars",
// "modify-vars",
// "production",
// "rootpath-relative",
// "rootpath",
// "relative-urls",
// "browser",
// "no-js-errors",
// "legacy",
// "strict-units"
// ].map(function(testName) {
// sauceJobs[testName] = {
// options: {
// urls: ["http://localhost:8081/tmp/browser/test-runner-" + testName + ".html"],
// testname: 'Less.js test - ' + testName,
// browsers: browsers,
// public: 'public',
// recordVideo: false,
// videoUploadOnPass: false,
// recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
// build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
// tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH],
// sauceConfig: {
// 'idle-timeout': 100
// },
// throttled: 5
// }
// };
// });
var sauceJobs = {};

var browserTests = [ "filemanager-plugin",
"visitor-plugin",
"global-vars",
"modify-vars",
"production",
"rootpath-relative",
"rootpath",
"relative-urls",
"browser",
"no-js-errors",
"legacy"
];

browserTests.map(function(testName) {
sauceJobs[testName] = {
options: {
urls: ["http://localhost:8081/tmp/browser/test-runner-" + testName + ".html"],
testname: 'Less.js test - ' + testName,
browsers: browsers,
public: 'public',
recordVideo: false,
videoUploadOnPass: false,
recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH],
sauceConfig: {
'idle-timeout': 100
},
throttled: 5,
onTestComplete: function(result, callback) {
// Called after a unit test is done, per page, per browser
// 'result' param is the object returned by the test framework's reporter
// 'callback' is a Node.js style callback function. You must invoke it after you
// finish your work.
// Pass a non-null value as the callback's first parameter if you want to throw an
// exception. If your function is synchronous you can also throw exceptions
// directly.
// Passing true or false as the callback's second parameter passes or fails the
// test. Passing undefined does not alter the test result. Please note that this
// only affects the grunt task's result. You have to explicitly update the Sauce
// Labs job's status via its REST API, if you want so.

// This should be the encrypted value in Travis
var user = process.env.SAUCE_USERNAME;
var pass = process.env.SAUCE_ACCESS_KEY;

require('request').put({
url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
auth: { user: user, pass: pass },
json: { passed: result.passed }
}, function (error, response, body) {
if (error) {
console.log(error);
callback(error);
} else if (response.statusCode !== 200) {
console.log(response);
callback(new Error('Unexpected response status'));
} else {
callback(null, result.passed);
}
});
}
}
};
});
// Project configuration.
grunt.initConfig({

Expand Down Expand Up @@ -378,62 +409,64 @@ module.exports = function (grunt) {
}
},

'saucelabs-jasmine': {
all: {
options: {
urls: ["main", "filemanager-plugin","visitor-plugin","pre-processor-plugin","post-processor-plugin","global-vars", "modify-vars", "production", "rootpath-relative",
"rootpath", "relative-urls", "browser", "no-js-errors", "legacy", "strict-units"
].map(function(testName) {
return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html";
}),
testname: 'Sauce Unit Test for less.js',
browsers: browsers,
public: 'public',
pollInterval: 2000,
statusCheckAttempts: 30,
recordVideo: false,
videoUploadOnPass: false,
recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH],
sauceConfig: {
'idle-timeout': 100
},
throttled: 5,
onTestComplete: function(result, callback) {
// Called after a unit test is done, per page, per browser
// 'result' param is the object returned by the test framework's reporter
// 'callback' is a Node.js style callback function. You must invoke it after you
// finish your work.
// Pass a non-null value as the callback's first parameter if you want to throw an
// exception. If your function is synchronous you can also throw exceptions
// directly.
// Passing true or false as the callback's second parameter passes or fails the
// test. Passing undefined does not alter the test result. Please note that this
// only affects the grunt task's result. You have to explicitly update the Sauce
// Labs job's status via its REST API, if you want so.
'saucelabs-jasmine': sauceJobs,

// {
// all: {
// options: {
// urls: ["filemanager-plugin","visitor-plugin","pre-processor-plugin","post-processor-plugin","global-vars", "modify-vars", "production", "rootpath-relative",
// "rootpath", "relative-urls", "browser", "no-js-errors", "legacy", "strict-units"
// ].map(function(testName) {
// return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html";
// }),
// testname: 'Sauce Unit Test for less.js',
// browsers: browsers,
// public: 'public',
// pollInterval: 2000,
// statusCheckAttempts: 30,
// recordVideo: false,
// videoUploadOnPass: false,
// recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
// build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
// tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH],
// sauceConfig: {
// 'idle-timeout': 100
// },
// throttled: 5,
// onTestComplete: function(result, callback) {
// // Called after a unit test is done, per page, per browser
// // 'result' param is the object returned by the test framework's reporter
// // 'callback' is a Node.js style callback function. You must invoke it after you
// // finish your work.
// // Pass a non-null value as the callback's first parameter if you want to throw an
// // exception. If your function is synchronous you can also throw exceptions
// // directly.
// // Passing true or false as the callback's second parameter passes or fails the
// // test. Passing undefined does not alter the test result. Please note that this
// // only affects the grunt task's result. You have to explicitly update the Sauce
// // Labs job's status via its REST API, if you want so.

// This should be the encrypted value in Travis
var user = process.env.SAUCE_USERNAME;
var pass = process.env.SAUCE_ACCESS_KEY;

require('request').put({
url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
auth: { user: user, pass: pass },
json: { passed: result.passed }
}, function (error, response, body) {
if (error) {
callback(error);
} else if (response.statusCode !== 200) {
callback(new Error('Unexpected response status'));
} else {
callback(null, result.passed);
}
});
}
}
}
},
// // This should be the encrypted value in Travis
// var user = process.env.SAUCE_USERNAME;
// var pass = process.env.SAUCE_ACCESS_KEY;

// require('request').put({
// url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
// auth: { user: user, pass: pass },
// json: { passed: result.passed }
// }, function (error, response, body) {
// if (error) {
// callback(error);
// } else if (response.statusCode !== 200) {
// callback(new Error('Unexpected response status'));
// } else {
// callback(null, result.passed);
// }
// });
// }
// }
// }
// },

// Clean the version of less built for the tests
clean: {
Expand Down Expand Up @@ -511,11 +544,12 @@ module.exports = function (grunt) {
'sauce-after-setup'
]);

// setup a web server to run the browser tests in a browser rather than phantom
grunt.registerTask('sauce-after-setup', [
'saucelabs-jasmine',
'clean:sauce_log'
]);
var sauceTests = [];
browserTests.map(function(testName) {
sauceTests.push('saucelabs-jasmine:' + testName);
});
sauceTests.push('clean:sauce_log');
grunt.registerTask('sauce-after-setup', sauceTests);

var testTasks = [
'clean',
Expand Down
Loading

0 comments on commit a38f8a1

Please sign in to comment.