Commit bd5d2ad9 authored by Xavier Guimard's avatar Xavier Guimard

Enable upstream tests using pkg-js-tools, this embeds some node modules in...

Enable upstream tests using pkg-js-tools, this embeds some node modules in debian/tests/test_modules. Add net-tools in dependencies
parent efea1f03
......@@ -3,9 +3,16 @@ Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.deb
Uploaders: Pirate Praveen <praveen@debian.org>
Section: javascript
Priority: optional
Testsuite: autopkgtest-pkg-nodejs
Build-Depends:
debhelper (>= 12~)
, mocha <!nocheck>
, net-tools <!nocheck>
, nodejs
, node-core-util-is <!nocheck>
, node-isstream <!nocheck>
, node-should <!nocheck>
, pkg-js-tools
Standards-Version: 4.4.0
Vcs-Browser: https://salsa.debian.org/js-team/node-address
Vcs-Git: https://salsa.debian.org/js-team/node-address.git
......@@ -15,6 +22,7 @@ Package: node-address
Architecture: all
Depends:
${misc:Depends}
, net-tools <!nocheck>
, nodejs
Description: Get current machine IP, MAC and DNS servers
DNS servers are read from /etc/resolv.conf.
......
......@@ -5,13 +5,7 @@
#export DH_VERBOSE=1
%:
dh $@
#override_dh_auto_build:
#override_dh_auto_test:
dh $@ --with nodejs
override_dh_installchangelogs:
dh_installchangelogs -k History.md
Tests: require
Depends: node-address
debian/tests/test_modules
test
NODE_PATH=debian/tests/test_modules mocha --check-leaks -R spec -t 10000 test/*.test.js
#!/bin/sh
set -e
nodejs -e "require('address');"
module.exports = require('./register')().implementation
module.exports = require('./register')().Promise
"use strict"
// global key for user preferred registration
var REGISTRATION_KEY = '@@any-promise/REGISTRATION',
// Prior registration (preferred or detected)
registered = null
/**
* Registers the given implementation. An implementation must
* be registered prior to any call to `require("any-promise")`,
* typically on application load.
*
* If called with no arguments, will return registration in
* following priority:
*
* For Node.js:
*
* 1. Previous registration
* 2. global.Promise if node.js version >= 0.12
* 3. Auto detected promise based on first sucessful require of
* known promise libraries. Note this is a last resort, as the
* loaded library is non-deterministic. node.js >= 0.12 will
* always use global.Promise over this priority list.
* 4. Throws error.
*
* For Browser:
*
* 1. Previous registration
* 2. window.Promise
* 3. Throws error.
*
* Options:
*
* Promise: Desired Promise constructor
* global: Boolean - Should the registration be cached in a global variable to
* allow cross dependency/bundle registration? (default true)
*/
module.exports = function(root, loadImplementation){
return function register(implementation, opts){
implementation = implementation || null
opts = opts || {}
// global registration unless explicitly {global: false} in options (default true)
var registerGlobal = opts.global !== false;
// load any previous global registration
if(registered === null && registerGlobal){
registered = root[REGISTRATION_KEY] || null
}
if(registered !== null
&& implementation !== null
&& registered.implementation !== implementation){
// Throw error if attempting to redefine implementation
throw new Error('any-promise already defined as "'+registered.implementation+
'". You can only register an implementation before the first '+
' call to require("any-promise") and an implementation cannot be changed')
}
if(registered === null){
// use provided implementation
if(implementation !== null && typeof opts.Promise !== 'undefined'){
registered = {
Promise: opts.Promise,
implementation: implementation
}
} else {
// require implementation if implementation is specified but not provided
registered = loadImplementation(implementation)
}
if(registerGlobal){
// register preference globally in case multiple installations
root[REGISTRATION_KEY] = registered
}
}
return registered
}
}
"use strict";
try {
module.exports = require('./register')().Promise || null
} catch(e) {
module.exports = null
}
{
"name": "any-promise",
"version": "1.3.0",
"description": "Resolve any installed ES6 compatible promise",
"main": "index.js",
"typings": "index.d.ts",
"browser": {
"./register.js": "./register-shim.js"
},
"scripts": {
"test": "ava"
},
"repository": {
"type": "git",
"url": "https://github.com/kevinbeaty/any-promise"
},
"keywords": [
"promise",
"es6"
],
"author": "Kevin Beaty",
"license": "MIT",
"bugs": {
"url": "https://github.com/kevinbeaty/any-promise/issues"
},
"homepage": "http://github.com/kevinbeaty/any-promise",
"dependencies": {},
"devDependencies": {
"ava": "^0.14.0",
"bluebird": "^3.0.0",
"es6-promise": "^3.0.0",
"is-promise": "^2.0.0",
"lie": "^3.0.0",
"mocha": "^2.0.0",
"native-promise-only": "^0.8.0",
"phantomjs-prebuilt": "^2.0.0",
"pinkie": "^2.0.0",
"promise": "^7.0.0",
"q": "^1.0.0",
"rsvp": "^3.0.0",
"vow": "^0.4.0",
"when": "^3.0.0",
"zuul": "^3.0.0"
}
}
"use strict";
module.exports = require('./loader')(window, loadImplementation)
/**
* Browser specific loadImplementation. Always uses `window.Promise`
*
* To register a custom implementation, must register with `Promise` option.
*/
function loadImplementation(){
if(typeof window.Promise === 'undefined'){
throw new Error("any-promise browser requires a polyfill or explicit registration"+
" e.g: require('any-promise/register/bluebird')")
}
return {
Promise: window.Promise,
implementation: 'window.Promise'
}
}
"use strict"
module.exports = require('./loader')(global, loadImplementation);
/**
* Node.js version of loadImplementation.
*
* Requires the given implementation and returns the registration
* containing {Promise, implementation}
*
* If implementation is undefined or global.Promise, loads it
* Otherwise uses require
*/
function loadImplementation(implementation){
var impl = null
if(shouldPreferGlobalPromise(implementation)){
// if no implementation or env specified use global.Promise
impl = {
Promise: global.Promise,
implementation: 'global.Promise'
}
} else if(implementation){
// if implementation specified, require it
var lib = require(implementation)
impl = {
Promise: lib.Promise || lib,
implementation: implementation
}
} else {
// try to auto detect implementation. This is non-deterministic
// and should prefer other branches, but this is our last chance
// to load something without throwing error
impl = tryAutoDetect()
}
if(impl === null){
throw new Error('Cannot find any-promise implementation nor'+
' global.Promise. You must install polyfill or call'+
' require("any-promise/register") with your preferred'+
' implementation, e.g. require("any-promise/register/bluebird")'+
' on application load prior to any require("any-promise").')
}
return impl
}
/**
* Determines if the global.Promise should be preferred if an implementation
* has not been registered.
*/
function shouldPreferGlobalPromise(implementation){
if(implementation){
return implementation === 'global.Promise'
} else if(typeof global.Promise !== 'undefined'){
// Load global promise if implementation not specified
// Versions < 0.11 did not have global Promise
// Do not use for version < 0.12 as version 0.11 contained buggy versions
var version = (/v(\d+)\.(\d+)\.(\d+)/).exec(process.version)
return !(version && +version[1] == 0 && +version[2] < 12)
}
// do not have global.Promise or another implementation was specified
return false
}
/**
* Look for common libs as last resort there is no guarantee that
* this will return a desired implementation or even be deterministic.
* The priority is also nearly arbitrary. We are only doing this
* for older versions of Node.js <0.12 that do not have a reasonable
* global.Promise implementation and we the user has not registered
* the preference. This preserves the behavior of any-promise <= 0.1
* and may be deprecated or removed in the future
*/
function tryAutoDetect(){
var libs = [
"es6-promise",
"promise",
"native-promise-only",
"bluebird",
"rsvp",
"when",
"q",
"pinkie",
"lie",
"vow"]
var i = 0, len = libs.length
for(; i < len; i++){
try {
return loadImplementation(libs[i])
} catch(e){}
}
return null
}
'use strict';
require('../register')('bluebird', {Promise: require('bluebird')})
'use strict';
require('../register')('es6-promise', {Promise: require('es6-promise').Promise})
'use strict';
require('../register')('lie', {Promise: require('lie')})
'use strict';
require('../register')('native-promise-only', {Promise: require('native-promise-only')})
'use strict';
require('../register')('pinkie', {Promise: require('pinkie')})
'use strict';
require('../register')('promise', {Promise: require('promise')})
'use strict';
require('../register')('q', {Promise: require('q').Promise})
'use strict';
require('../register')('rsvp', {Promise: require('rsvp').Promise})
'use strict';
require('../register')('vow', {Promise: require('vow').Promise})
'use strict';
require('../register')('when', {Promise: require('when').Promise})
{
"name": "is-class",
"main": "is-class.js",
"version": "0.0.4",
"homepage": "https://github.com/miguelmota/is-class",
"authors": [
"Miguel Mota <miguelmota2@gmail.com>"
],
"description": "Check if function is an ES6 class.",
"keywords": [
"predicate",
"function",
"class",
"es6"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"license": "MIT"
}
(function(root) {
var toString = Function.prototype.toString;
function fnBody(fn) {
return toString.call(fn).replace(/^[^{]*{\s*/,'').replace(/\s*}[^}]*$/,'');
}
function isClass(fn) {
return (typeof fn === 'function' &&
(/^class(?:\s|{)/.test(toString.call(fn)) ||
(/^.*classCallCheck\(/.test(fnBody(fn)))) // babel.js
);
}
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = isClass;
}
exports.isClass = isClass;
} else if (typeof define === 'function' && define.amd) {
define([], function() {
return isClass;
});
} else {
root.isClass = isClass;
}
})(this);
{
"name": "is-class-hotfix",
"version": "0.0.6",
"description": "Check if function is an ES6 class.",
"main": "is-class.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "tape test/*.js"
},
"repository": {
"type": "git",
"url": "https://github.com/miguelmota/is-class"
},
"keywords": [
"predicate",
"function",
"class",
"es6"
],
"author": "Miguel Mota <hello@miguelmota.com> (http://www.miguelmota.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/miguelmota/is-class/issues"
},
"homepage": "https://github.com/miguelmota/is-class",
"devDependencies": {
"tape": "^3.0.3"
}
}
'use strict';
var utils = require('core-util-is');
var isStearm = require('isstream');
// wait for https://github.com/miguelmota/is-class/pull/6 merge
var isClass = require('is-class-hotfix');
/**
* Expose all methods in core-util-is
*/
Object.keys(utils).map(function (name) {
exports[transform(name)] = utils[name];
});
/**
* Stream detected by isstream
*/
exports.stream = isStearm;
exports.readableStream = isStearm.isReadable;
exports.writableStream = isStearm.isWritable;
exports.duplexStream = isStearm.isDuplex;
/**
* Class detected by is-class
*/
exports.class = isClass;
/**
* Extend method
*/
exports.finite = Number.isFinite;
exports.NaN = Number.isNaN
exports.generator = function (obj) {
return obj
&& 'function' === typeof obj.next
&& 'function' === typeof obj.throw;
};
exports.generatorFunction = function (obj) {
return obj
&& obj.constructor
&& 'GeneratorFunction' === obj.constructor.name;
};
exports.asyncFunction = function (obj) {
return obj
&& obj.constructor
&& 'AsyncFunction' === obj.constructor.name;
};
exports.promise = function (obj) {
return obj
&& 'function' === typeof obj.then;
};
var MAX_INT_31 = Math.pow(2, 31);
exports.int = function (obj) {
return utils.isNumber(obj)
&& obj % 1 === 0;
};
exports.int32 = function (obj) {
return exports.int(obj)
&& obj < MAX_INT_31
&& obj >= -MAX_INT_31;
};
exports.long = function (obj) {
return exports.int(obj)
&& (obj >= MAX_INT_31 || obj < -MAX_INT_31);
};
exports.Long = function (obj) {
return exports.object(obj)
&& exports.number(obj.high)
&& exports.number(obj.low);
};
exports.double = function (obj) {
return utils.isNumber(obj)
&& !isNaN(obj)
&& obj % 1 !== 0;
};
/**
* override core-util-is
*/
exports.date = function isDate(obj) {
return obj instanceof Date;
};
exports.regExp = function isRegExp(obj) {
return obj instanceof RegExp;
};
exports.regexp = exports.regExp;
exports.error = function isError(obj) {
return obj instanceof Error;
};
exports.array = Array.isArray;
/**
* transform isNull type to null
* @param {[type]} m [description]
* @return {[type]} [description]
*/
function transform(m) {
var name = m.slice(2);
name = name[0].toLowerCase() + name.slice(1);
return name;
}
{
"name": "is-type-of",
"version": "1.2.1",
"description": "complete type checking for node",
"main": "index.js",
"scripts": {
"test": "nyc mocha test/*.test.js"
},
"repository": {
"type": "git",
"url": "git://github.com/node-modules/is-type-of.git"
},
"files": [
"index.js"
],
"keywords": [
"typeof",
"checker",
"type",
"is"
],
"author": "dead_horse <dead_horse@qq.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/node-modules/is-type-of/issues"
},
"homepage": "https://github.com/node-modules/is-type-of",
"dependencies": {
"core-util-is": "^1.0.2",
"is-class-hotfix": "~0.0.6",
"isstream": "~0.1.2"
},
"devDependencies": {
"autod": "^2.9.0",
"beautify-benchmark": "^0.2.4",
"benchmark": "^2.1.4",
"contributors": "*",
"long": "^3.2.0",
"mocha": "^3.5.0",
"nyc": "^11.1.0",
"semver": "^5.4.1"
}
}
all: test
test:
./node_modules/.bin/mocha -r should -r co-mocha
.PHONY: test
\ No newline at end of file
var ms = require('ms')
var sleep = function (time) {
time = isNaN(time) ? ms(time) : time;
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve()
}, time)
})
}
module.exports = exports = sleep
\ No newline at end of file
{
"name": "ko-sleep",
"version": "1.0.3",
"description": "a promise just sleep Zzzz...",
"main": "index.js",
"scripts": {
"test": "make test"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/alsotang/ko-sleep.git"
},
"keywords": [
"co",
"sleep",
"generator",
"yield"
],
"author": "alsotang <alsotang@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/alsotang/ko-sleep/issues"
},
"homepage": "https://github.com/alsotang/ko-sleep#readme",
"devDependencies": {
"co-mocha": "^1.1.2",
"mocha": "^2.3.3",
"should": "^7.1.1"
},
"dependencies": {
"ms": "^2.0.0"
}
}
var sleep = require('./')
describe('test.js', function () {
it('should sleep', function * () {
var start = new Date();
yield sleep(30);
(new Date - start).should.aboveOrEqual(30)
})
it('should sleep with human time string', function * () {
var start = new Date();
yield sleep('30ms');
(new Date - start).should.aboveOrEqual(30)
})
})
\ No newline at end of file
'use strict';
module.exports = require('./lib/mm');
require('./lib/es6');
'use strict';
const is = require('is-type-of');
const sleep = require('ko-sleep');
const mm = require('./mm');
const mockDatas = mm.datas;
// support generator
mm.datas = function(mod, method, datas, timeout) {
if (!is.generatorFunction(mod[method])) {
return mockDatas.call(mm, mod, method, datas, timeout);
}
if (timeout) {
timeout = parseInt(timeout, 10);
}
timeout = timeout || 0;
mm(mod, method, function* () {
yield sleep(timeout);
return datas;
});
return this;
};
const mockData = mm.data;
mm.data = function(mod, method, data, timeout) {