Skip to content
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

[DX-202] Execute all the tests #704

Merged
merged 5 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ src/components/base-component-jade/_package

test/fixtures/test.tar.gz
test/fixtures/targz-test

logintervals.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add newline please,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
"oc": "./src/oc-cli.js"
},
"scripts": {
"build": "node tasks/build.js && npm run test",
"changelog": "node tasks/changelog.js",
"build": "node tasks/build.js",
"git-stage": "node tasks/git-stage.js",
"major": "node tasks/version.js --type=\"major\"",
"minor": "node tasks/version.js --type=\"minor\"",
"patch": "node tasks/version.js --type=\"patch\"",
"major": "npm run version-major && npm run test-silent && npm run git-stage",
"minor": "npm run version-minor && npm run test-silent && npm run git-stage",
"patch": "npm run version-patch && npm run test-silent && npm run git-stage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also use the native npm version <update_type> to update version on npm btw

Copy link
Member Author

@matteofigus matteofigus Oct 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit different as it updates the oc-client component's version too - so that it matches the oc version.

"precommit": "lint-staged",
"start": "npm run build",
"test": "node tasks/mochaTest.js",
"test-silent": "node tasks/mochaTest.js --silent"
"test": "npm run build && node tasks/mochaTest.js",
"test-silent": "npm run build && node tasks/mochaTest.js --silent",
"version-major": "node tasks/version.js --type=\"major\"",
"version-minor": "node tasks/version.js --type=\"minor\"",
"version-patch": "node tasks/version.js --type=\"patch\""
},
"lint-staged": {
"*.js": [
Expand Down
14 changes: 8 additions & 6 deletions tasks/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const get = require('./git');

module.exports = () =>
new Promise(resolve => {
const writeChangelog = changelog => {
const writeChangelog = (changelog, cb) => {
let result = '## Change Log';
changelog.forEach(pr => {
if (pr.changes.length > 0) {
Expand All @@ -19,7 +19,7 @@ module.exports = () =>
);
}
});
fs.writeFileSync(path.join(__dirname, '../CHANGELOG.md'), result);
fs.writeFile(path.join(__dirname, '../CHANGELOG.md'), result, cb);
};

get.tags((err, tags) => {
Expand All @@ -32,12 +32,14 @@ module.exports = () =>
tag,
changes
});
next();
next(err);
});
},
() => {
writeChangelog(result);
resolve();
err => {
if (err) {
return reject(err);
}
writeChangelog(result, resolve);
}
);
});
Expand Down
26 changes: 12 additions & 14 deletions tasks/mochaTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const async = require('async');
const glob = require('glob');
const Mocha = require('mocha');
const minimist = require('minimist');
Expand All @@ -17,18 +18,15 @@ if (argv.silent) {
mocha.reporter('progress');
}

// set up files to be tested by mocha
const addTests = function() {
return new Promise(resolve => {
testDirs.forEach(dir => {
glob(path.join(__dirname, '..', dir), (err, files) => {
files.forEach(file => mocha.addFile(file));
resolve();
});
async.each(
testDirs,
(dir, next) => {
glob(path.join(__dirname, '..', dir), (err, files) => {
files.forEach(file => mocha.addFile(file));
next();
});
});
};

addTests().then(() => {
mocha.run(err => process.on('exit', () => process.exit(err)));
});
},
() => {
mocha.run(err => process.on('exit', () => process.exit(err)));
}
);