Skip to content

Fix: Omit flaky performance test on single-core and for CI #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
"webworkers"
],
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/core": "7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-config-bliss": "^4.7.0",
"eslint": "7.0.0",
"eslint-config-bliss": "5.0.0",
"is-ci": "^2.0.0",
"jasmine-node": "^3.0.0",
"q": "^1.5.1"
},
Expand Down Expand Up @@ -67,12 +68,15 @@
},
"babel": {
"presets": [
["@babel/preset-env", {
"targets": {
"chrome": "58",
"node": "10"
[
"@babel/preset-env",
{
"targets": {
"chrome": "58",
"node": "10"
}
}
}]
]
]
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ describe('API', () => {
});

p.map(addOne)
.then(data => data.reduce(sum))
.then(data => data.reduce((a,b)=>a+b,0))
.then(data => {
expect(data).toEqual(9);
done();
Expand Down
20 changes: 19 additions & 1 deletion test/specs/performance.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
const os = require('os')
const isCI = require('is-ci')
const isSingleCore = 1 === os.cpus().length;

let extraInfo = 'This test is flaky so please rerun. Will be skipped on single core machines and for CI'

if(isSingleCore){
extraInfo += 'This test has been skipped as its running on a single core machine';
}

if (isCI) {
console.log('This test has been skipped as its running in a CI enviroment')
}

describe('Performance', () => {
const isNode = typeof module !== 'undefined' && module.exports;
const Parallel = isNode ? require('../../lib/parallel.js') : self.Parallel;

it('.map() should be using multi-threading (could fail on single-core)', () => {
it(`.map() should be using multi-threading (${extraInfo})`, () => {
if(isCI || isSingleCore){
return;
}

const slowSquare = function(n) {
let i = 0;
while (++i < n * n) {}
Expand Down
4 changes: 2 additions & 2 deletions test/specs/q-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Q-API', () => {
const p = new Parallel([1, 2, 3]);

Q.when(p.map(addOne))
.then(() => p.spawn(data => data.reduce(sum)))
.then(() => p.spawn(data => data.reduce((a,b)=>a+b,0)))
.then(data => {
expect(result).toEqual(9);
});
Expand All @@ -90,7 +90,7 @@ describe('Q-API', () => {
const p = new Parallel([1, 2, 3]);

Q.when(p.map(addOne))
.then(qe => p.then(data => data.reduce(sum)))
.then(qe => p.then(data => data.reduce((a,b)=>a+b,0)))
.then(data => {
expect(data).toEqual(9);
done();
Expand Down
Loading