Permalink
Browse files

util, feat: add 'modules' into returnValue of 'util.buildInfo'. (#458)

  • Loading branch information...
richardo2016 authored and xicilion committed Aug 13, 2018
1 parent d1842df commit d59f2d3414d88819144d9b4c23d0b017e99f75e7
Showing with 137 additions and 48 deletions.
  1. +14 −1 fibjs/src/util/util_info.cpp
  2. +28 −25 idl/us-en/util.idl
  3. +24 −21 idl/zh-cn/util.idl
  4. +71 −1 test/util_test.js
@@ -105,6 +105,19 @@ result_t util_base::buildInfo(v8::Local<v8::Object>& retVal)
vender->Set(isolate->NewString("zmq"), isolate->NewString(STR(ZMQ_VERSION_MAJOR) "." STR(ZMQ_VERSION_MINOR)));
}
{
v8::Local<v8::Array> modules = v8::Array::New(isolate->m_isolate);
retVal->Set(isolate->NewString("modules"), modules);
RootModule* pModule = RootModule::g_root;
intptr_t icnt = 0;
while (pModule) {
modules->Set((int32_t)(icnt++), isolate->NewString(pModule->name()));
pModule = pModule->m_next;
}
}
return 0;
}
}
}
View
@@ -271,31 +271,34 @@ module util
static LruCache;
/*! @brief Get current engine and components information
@return Struct info:
@code
{
"fibjs": "0.1.0",
"svn": 1753,
"build": "Dec 10 2013 21:44:17",
"vender": {
"ev": "4.11",
"exif": "0.6.21",
"gd": "2.1.0-alpha",
"jpeg": "8.3",
"log4cpp": "1.0",
"mongo": "0.7",
"pcre": "8.21",
"png": "1.5.4",
"sqlite": "3.8.1",
"tiff": "3.9.5",
"uuid": "1.6.2",
"v8": "3.23.17 (candidate)",
"zlib": "1.2.7",
"zmq": "3.1"
}
}
@endcode
```JavaScript
{
"fibjs": "0.25.0",
"clang": "9.1",
"date": "Jun 12 2018 07:22:40",
"vender": {
"ev": "4.24",
"expat": "2.2.5",
"gd": "2.2.4",
"jpeg": "8.3",
"leveldb": "1.17",
"mongo": "0.7",
"pcre": "8.21",
"png": "1.5.4",
"mbedtls": "2.6.1",
"snappy": "1.1.2",
"sqlite": "3.23.0",
"tiff": "3.9.5",
"uuid": "1.6.2",
"v8": "6.7.288.20",
"v8-snapshot": true,
"zlib": "1.2.7",
"zmq": "3.1"
}
}
```
@return Struct info
*/
static Object buildInfo();
};
View
@@ -451,27 +451,30 @@ module util
/*! @brief 查询当前引擎及各组件版本信息
```JavaScript
{
"fibjs": "0.1.0",
"svn": 1753,
"build": "Dec 10 2013 21:44:17",
"vender": {
"ev": "4.11",
"exif": "0.6.21",
"gd": "2.1.0-alpha",
"jpeg": "8.3",
"log4cpp": "1.0",
"mongo": "0.7",
"pcre": "8.21",
"png": "1.5.4",
"sqlite": "3.8.1",
"tiff": "3.9.5",
"uuid": "1.6.2",
"v8": "3.23.17 (candidate)",
"zlib": "1.2.7",
"zmq": "3.1"
}
}
{
"fibjs": "0.25.0",
"clang": "9.1",
"date": "Jun 12 2018 07:22:40",
"vender": {
"ev": "4.24",
"expat": "2.2.5",
"gd": "2.2.4",
"jpeg": "8.3",
"leveldb": "1.17",
"mongo": "0.7",
"pcre": "8.21",
"png": "1.5.4",
"mbedtls": "2.6.1",
"snappy": "1.1.2",
"sqlite": "3.23.0",
"tiff": "3.9.5",
"uuid": "1.6.2",
"v8": "6.7.288.20",
"v8-snapshot": true,
"zlib": "1.2.7",
"zmq": "3.1"
}
}
```
@return 返回组件版本对象
*/
View
@@ -1239,6 +1239,76 @@ describe('util', () => {
});
});
describe('buildInfo', () => {
it('properties', () => {
assert.property(util.buildInfo(), 'fibjs');
// clang
// gcc
// msvc
assert.property(util.buildInfo(), 'git');
assert.property(util.buildInfo(), 'date');
// debug
assert.property(util.buildInfo(), 'vender');
assert.property(util.buildInfo(), 'modules');
});
it('modules', () => {
const modules = util.buildInfo().modules;
// built-in modules
;[
"zmq",
"zlib",
"zip",
"xml",
"ws",
"vm",
"uuid",
"util",
"url",
"tty",
"timers",
"test",
"string_decoder",
"tls",
"ssl",
"querystring",
"punycode",
"profiler",
"process",
"path",
"os",
"net",
"mq",
"json",
"io",
"iconv",
"https",
"http",
"hex",
"hash",
"gd",
"fs",
"events",
"encoding",
"dns",
"dgram",
"db",
"crypto",
"coroutine",
"buffer",
"bson",
"base64vlq",
"base64",
"base32",
"assert"
].forEach(moduleName => {
assert.isTrue(modules.includes(moduleName))
assert.isObject(require(moduleName))
});
});
});
describe('LruCache', () => {
var c;
@@ -1492,4 +1562,4 @@ describe('util', () => {
});
});
require.main === module && test.run(console.DEBUG);
require.main === module && test.run(console.DEBUG);

0 comments on commit d59f2d3

Please sign in to comment.