Skip to content

Commit

Permalink
test: improvements with Saucelabs/Codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
evilaliv3 authored and indutny committed Mar 31, 2016
1 parent d3049b8 commit 4cf66c9
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 13 deletions.
14 changes: 14 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
engines:
duplication:
enabled: true
config:
languages:
- javascript
eslint:
enabled: true
fixme:
enabled: true
ratings:
paths:
- "lib/**/*"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test/lib/
node_modules/
coverage/
npm-debug.log
Expand Down
20 changes: 16 additions & 4 deletions .travis.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,24 @@ node_js:
env:
global:
secure: ewqsRnX7z3+g6q+mM6peRPhuTlTlkJIRmVG/Ya9AcDXEb7as49KDTdqfMcOu7+FxF50ehqla+TRRCLRPOcVkWqs72OVUXEsjRASp9jQwpQGl+g/vZhyTMwlM2ENEkyiFQtobI1hYKgVW1ogftkc6vm7ywvoyTrFp/leVJBrTuHk=
secure: d4Yj0rUDUSFrUKU9vuZZc3p4aiQmKwZVWigVhybU2RfZHpxoakTYd3z7Ys23z+yQZt+BWcul1L3H5DwvACGTwyltwVmHzTWSBtunHax41TN9ZwOY4y37qWNfzEkz72URPL65ujd8ozkyxsiysAq+BE9+5gl9OZxfzExXNfRD3e4
matrix:
- TEST_SUITE=unit
- TEST_SUITE='npm run unit'
matrix:
include:
- node_js: "4"
env: TEST_SUITE=lint
env: TEST_SUITE='npm run lint'
- node_js: "4"
env: TEST_SUITE=coveralls
script: npm run $TEST_SUITE
env: TEST_SUITE='grunt coveralls'
- node_js: "4"
env: TEST_SUITE='grunt saucelabs'
allow_failures:
- env: TEST_SUITE='grunt saucelabs'
fast_finish: true
cache:
directories:
- node_modules
before_script:
- npm install -g grunt-cli
script:
- $TEST_SUITE
180 changes: 180 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
module.exports = function(grunt) {
grunt.initConfig({
browserify: {
unittests: {
files: {
'test/lib/unittests-bundle.js': [ 'test/index.js']
},
options: {
transform: ['brfs']
}
}
},
connect: {
server: {
options: {
port: 3000,
base: './test'
}
}
},
copy: {
test: {
expand: true,
flatten: true,
cwd: 'node_modules/',
src: ['mocha/mocha.css', 'mocha/mocha.js'],
dest: 'test/lib/'
}
},
mocha_istanbul: {
coverage: {
src: ['test'],
options: {
coverage: false,
timeout: 6000,
reportFormats: ['cobertura','lcovonly']
}
},
coveralls: {
src: ['test'],
options: {
coverage: true,
timeout: 6000,
reportFormats: ['cobertura','lcovonly']
}
}
},
'saucelabs-mocha': {
all: {
options: {
username: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
urls: ['http:https://127.0.0.1:3000/unittests.html'],
build: process.env.TRAVIS_JOB_ID,
testname: 'Sauce Unit Test for ellipticjs',
browsers: [
{
browserName: "safari",
platform: "OS X 10.11",
version: "9"
},
{
browserName: "safari",
platform: "OS X 10.10",
version: "8"
},
{
browserName: "microsoftedge",
version: "13.10586",
platform: "Windows 10"
},
{
browserName: "internet explorer",
version: "11",
platform: "Windows 8.1"
},
{
browserName: "internet explorer",
version: "10",
platform: "Windows 8"
},
{
browserName: "internet explorer",
version: "9",
platform: "Windows 7"
},
{
browserName: "internet explorer",
version: "8",
platform: "Windows 7"
},
{
browserName: "android",
platform: "Linux",
version: "5.1"
},
{
browserName: "android",
platform: "Linux",
version: "4.4"
},
{
browserName: "iphone",
platform: "OS X 10.10",
version: "7.1"
},
{
browserName: "iphone",
platform: "OS X 10.10",
version: "9.2"
},
{
browserName: "chrome",
platform: "Linux",
version: "38"
},
{
browserName: "chrome",
platform: "Linux",
version: "47"
},
{
browserName: "chrome",
platform: "Linux",
version: "beta"
},
{
browserName: "firefox",
platform: "Linux",
version: "38"
},
{
browserName: "firefox",
platform: "Linux",
version: "43"
},
{
browserName: "firefox",
platform: "Linux",
version: "beta"
}
],
public: "public",
maxRetries: 3,
throttled: 2,
pollInterval: 4000,
statusCheckAttempts: 200
}
},
},
uglify: {
scrypt: {
files: {
'elliptic.min.js' : [ 'elliptic.js' ]
}
}
}
});

grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-saucelabs');

grunt.event.on('coverage', function(lcov, done){
require('coveralls').handleInput(lcov, function(err){
if (err) {
return done(err);
}
done();
});
});

grunt.registerTask('build', ['uglify']);
grunt.registerTask('coverage', ['browserify', 'copy:test', 'mocha_istanbul:coverage']);
grunt.registerTask('coveralls', ['browserify', 'copy:test', 'mocha_istanbul:coveralls']);
grunt.registerTask('saucelabs', ['browserify', 'copy:test', 'connect', 'saucelabs-mocha']);
};
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Elliptic [![Build Status](https://secure.travis-ci.org/indutny/elliptic.png)](http:https://travis-ci.org/indutny/elliptic) [![Coverage Status](https://coveralls.io/repos/indutny/elliptic/badge.svg?branch=master&service=github)](https://coveralls.io/github/indutny/elliptic?branch=master)
# Elliptic [![Build Status](https://secure.travis-ci.org/indutny/elliptic.png)](http:https://travis-ci.org/indutny/elliptic) [![Coverage Status](https://coveralls.io/repos/indutny/elliptic/badge.svg?branch=master&service=github)](https://coveralls.io/github/indutny/elliptic?branch=master) [![Code Climate](https://codeclimate.com/github/indutny/elliptic/badges/gpa.svg)](https://codeclimate.com/github/indutny/elliptic)

[![Saucelabs Test Status](https://saucelabs.com/browser-matrix/elliptic.svg)](https://saucelabs.com/u/elliptic)

Fast elliptic-curve cryptography in a plain javascript implementation.

Expand Down
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
"lib"
],
"scripts": {
"coverage": "npm run unit --coverage",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/*.js",
"jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/*.js",
"jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
"jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",
"lint": "npm run jscs && npm run jshint",
"test": "npm run lint && npm run unit",
"unit": "istanbul test _mocha --reporter=spec test/*-test.js"
"unit": "istanbul test _mocha --reporter=spec test/index.js",
"test": "npm run lint && npm run unit"
},
"repository": {
"type": "git",
Expand All @@ -32,7 +30,15 @@
},
"homepage": "https://github.com/indutny/elliptic",
"devDependencies": {
"brfs": "^1.4.3",
"coveralls": "^2.11.3",
"grunt": "^0.4.5",
"grunt-browserify": "^5.0.0",
"grunt-contrib-connect": "^1.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-mocha-istanbul": "^3.0.1",
"grunt-saucelabs": "^8.6.2",
"istanbul": "^0.4.2",
"jscs": "^2.9.0",
"jshint": "^2.6.0",
Expand Down
3 changes: 1 addition & 2 deletions test/ed25519-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var assert = require('assert');
var fs = require('fs');
var elliptic = require('../');
var utils = elliptic.utils;
var toArray = elliptic.utils.toArray;
Expand Down Expand Up @@ -48,7 +47,7 @@ describe('sign.input ed25519 test vectors', function() {

before(function(done) {
ed25519 = new eddsa('ed25519');
fs.readFile(__dirname + '/fixtures/sign.input', function(err, f) {
require('fs').readFile(__dirname + '/fixtures/sign.input', function(err, f) {
lines = f.toString().split('\n');
assert.equal(lines.length, expectedTests + 1 /*blank line*/);
done();
Expand Down
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('Test specs', function () {
require('./api-test.js');
require('./curve-test.js');
require('./ecdh-test.js');
require('./ecdsa-test.js');
require('./ed25519-test.js');
require('./hmac-drbg-test.js');
});
39 changes: 39 additions & 0 deletions test/unittests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>scrypt-async Unit Tests</title>
<link rel="stylesheet" href="lib/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="lib/mocha.js"></script>
<script>
mocha.setup('bdd');
mocha.timeout(20000);
</script>
<script src="lib/unittests-bundle.js"></script>
<script>
mocha.setup('bdd');
mocha.timeout(20000);

var runner = mocha.run();
var failedTests = [];
runner.on('end', function(){
window.mochaResults = runner.stats;
window.mochaResults.reports = failedTests;
});
runner.on('fail', function(test, err) {
var flattenTitles = function(test) {
var titles = [];
while (test.parent.title) {
titles.push(test.parent.title);
test = test.parent;
}
return titles.reverse();
};
failedTests.push({name: test.title, result: false, message: err.message, stack: err.stack, titles: flattenTitles(test)});
});
</script>
</body>
</html>

0 comments on commit 4cf66c9

Please sign in to comment.