fixes for minified version test minified version in SauceLabs

This commit is contained in:
Ivan Tivonenko
2016-02-06 05:15:56 +02:00
parent 66b07623b0
commit 8767fc0068
10 changed files with 108 additions and 85 deletions

View File

@@ -13,6 +13,17 @@ var fs = require('fs');
var pkg = require('./package.json');
var uglifyOptions = {
mangle: {
except: ['_', 'RippleError', 'RippledError', 'UnexpectedError',
'LedgerVersionError', 'ConnectionError', 'NotConnectedError',
'DisconnectedError', 'TimeoutError', 'ResponseFormatError',
'ValidationError', 'NotFoundError', 'MissingLedgerHistoryError',
'PendingLedgerVersionError'
]
}
};
function webpackConfig(extension, overrides) {
overrides = overrides || {};
var defaults = {
@@ -85,13 +96,17 @@ gulp.task('build-tests', function(callback) {
'integration/'), done);
});
function createLink(from, to) {
if (fs.existsSync(to)) {
fs.unlinkSync(to);
}
fs.linkSync(from, to);
}
function createBuildLink(callback) {
return function(err, res) {
var latestBuildName = './build/ripple-latest.js';
if (fs.existsSync(latestBuildName)) {
fs.unlinkSync(latestBuildName);
}
fs.linkSync('./build/ripple-' + pkg.version + '.js', latestBuildName);
createLink('./build/ripple-' + pkg.version + '.js',
'./build/ripple-latest.js');
callback(err, res);
};
}
@@ -102,9 +117,13 @@ gulp.task('build', function(callback) {
gulp.task('build-min', ['build'], function() {
return gulp.src(['./build/ripple-', '.js'].join(pkg.version))
.pipe(uglify())
.pipe(uglify(uglifyOptions))
.pipe(rename(['ripple-', '-min.js'].join(pkg.version)))
.pipe(gulp.dest('./build/'));
.pipe(gulp.dest('./build/'))
.on('end', function() {
createLink('./build/ripple-' + pkg.version + '-min.js',
'./build/ripple-latest-min.js');
});
});
gulp.task('build-debug', function(callback) {

4
npm-shrinkwrap.json generated
View File

@@ -155,8 +155,8 @@
}
},
"ripple-binary-codec": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.1.tgz",
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.1.2.tgz",
"dependencies": {
"babel-runtime": {
"version": "5.8.34",

View File

@@ -23,7 +23,7 @@
"jayson": "^1.2.2",
"lodash": "^3.1.0",
"ripple-address-codec": "^2.0.1",
"ripple-binary-codec": "^0.1.1",
"ripple-binary-codec": "^0.1.2",
"ripple-hashes": "^0.1.0",
"ripple-keypairs": "^0.10.0",
"ripple-lib-transactionparser": "^0.6.0",

View File

@@ -36,11 +36,13 @@ unittest() {
mocha --opts test-compiled/mocha.opts test-compiled
# compile tests for browser testing
gulp build build-tests
gulp build-min build-tests
node --harmony test-compiled/mocked-server.js > /dev/null &
echo "Running tests in PhantomJS"
mocha-phantomjs test/localrunner.html
echo "Running tests using minified version in PhantomJS"
mocha-phantomjs test/localrunnermin.html
echo "Running tests in SauceLabs"
http-server &
@@ -56,7 +58,7 @@ integrationtest() {
mocha test/integration/http-integration-test.js
# run integration tests in PhantomJS
gulp build-tests build
gulp build-tests build-min
echo "Running integragtion tests in PhantomJS"
mocha-phantomjs test/localintegrationrunner.html
}

View File

@@ -11,7 +11,7 @@ function setPrototypeOf(object, prototype) {
function getConstructorName(object) {
// hack for internet explorer
return process.browser ?
object.constructor.toString().match(/^function\s(.+)\(/)[1] :
object.constructor.toString().match(/^function\s+([^(]*)/)[1] :
object.constructor.name;
}

View File

@@ -0,0 +1,37 @@
'use strict';
// this one will be directly run in browser, so disable eslint
/* eslint-disable no-var, no-extend-native, consistent-this, func-style */
(function() {
var phantomTest = /PhantomJS/;
if (phantomTest.test(navigator.userAgent)) {
// mocha-phantomjs-core has wrong shim for Function.bind, so we
// will replace it with correct one
// this bind polyfill copied from MDN documentation
Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError(
'Function.prototype.bind - what is trying to be bound is not callable'
);
}
var aArgs = Array.prototype.slice.call(arguments, 1);
var fToBind = this;
var FNOP = function() {};
var fBound = function() {
return fToBind.apply(this instanceof FNOP ? this : oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
if (this.prototype) {
// native functions don't have a prototype
FNOP.prototype = this.prototype;
}
fBound.prototype = new FNOP();
return fBound;
};
}
})();

View File

@@ -9,41 +9,7 @@
<div id="deb"></div>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script>
(function() {
var phantomTest = /PhantomJS/;
if (phantomTest.test(navigator.userAgent)) {
// mocha-phantomjs-core has wrong shim for Function.bind, so we
// will replace it with correct one
// this bind polyfill copied from MDN documentation
Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof fNOP
? this
: oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
if (this.prototype) {
// native functions don't have a prototype
fNOP.prototype = this.prototype;
}
fBound.prototype = new fNOP();
return fBound;
};
}
})();
</script>
<script src="hacks/phantomhacks.js"></script>
<script src="../build/ripple-latest.js"></script>
<script>
if (window.initMochaPhantomJS) {

View File

@@ -9,41 +9,7 @@
<div id="deb"></div>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script>
(function() {
var phantomTest = /PhantomJS/;
if (phantomTest.test(navigator.userAgent)) {
// mocha-phantomjs-core has wrong shim for Function.bind, so we
// will replace it with correct one
// this bind polyfill copied from MDN documentation
Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof fNOP
? this
: oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
if (this.prototype) {
// native functions don't have a prototype
fNOP.prototype = this.prototype;
}
fBound.prototype = new fNOP();
return fBound;
};
}
})();
</script>
<script src="hacks/phantomhacks.js"></script>
<script src="../build/ripple-latest.js"></script>
<script>
if (window.initMochaPhantomJS) {

33
test/localrunnermin.html Normal file
View File

@@ -0,0 +1,33 @@
<html>
<head>
<meta charset="utf-8">
<!-- encoding must be set for mocha's special characters to render properly -->
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<script src="./vendor/lodash.min.js"></script>
</head>
<body>
<div id="deb"></div>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script src="hacks/phantomhacks.js"></script>
<script src="../build/ripple-latest-min.js"></script>
<script>
if (window.initMochaPhantomJS) {
window.initMochaPhantomJS();
}
mocha.ui('bdd')
</script>
<script src="../test-compiled-for-web/api-test.js"></script>
<script src="../test-compiled-for-web/broadcast-api-test.js"></script>
<script src="../test-compiled-for-web/connection-test.js"></script>
<script src="../test-compiled-for-web/rangeset-test.js"></script>
<script>
mocha.run()
</script>
</body>
</html>

View File

@@ -10,9 +10,9 @@
<div id="mocha"></div>
<script src="/node_modules/mocha/mocha.js"></script>
<script src="/node_modules/mocha-sauce/client.js"></script>
<script src="/node_modules/mocha-in-sauce/client.js"></script>
<script src="/build/ripple-latest.js"></script>
<script src="/build/ripple-latest-min.js"></script>
<script>
mocha.ui('bdd')
</script>