[node] Output debug logs when a render test times out
This commit is contained in:
@@ -47,6 +47,7 @@ NAN_MODULE_INIT(NodeMap::Init) {
|
||||
Nan::SetPrototypeMethod(tpl, "load", Load);
|
||||
Nan::SetPrototypeMethod(tpl, "render", Render);
|
||||
Nan::SetPrototypeMethod(tpl, "release", Release);
|
||||
Nan::SetPrototypeMethod(tpl, "dumpDebugLogs", DumpDebugLogs);
|
||||
|
||||
constructor.Reset(tpl->GetFunction());
|
||||
Nan::Set(target, Nan::New("Map").ToLocalChecked(), tpl->GetFunction());
|
||||
@@ -327,6 +328,14 @@ void NodeMap::release() {
|
||||
map.reset(nullptr);
|
||||
}
|
||||
|
||||
NAN_METHOD(NodeMap::DumpDebugLogs) {
|
||||
auto nodeMap = Nan::ObjectWrap::Unwrap<NodeMap>(info.Holder());
|
||||
|
||||
if (!nodeMap->isValid()) return Nan::ThrowError(releasedMessage());
|
||||
|
||||
nodeMap->map->dumpDebugLogs();
|
||||
info.GetReturnValue().SetUndefined();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Instance
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
static NAN_METHOD(Load);
|
||||
static NAN_METHOD(Render);
|
||||
static NAN_METHOD(Release);
|
||||
static NAN_METHOD(DumpDebugLogs);
|
||||
|
||||
void startRender(std::unique_ptr<NodeMap::RenderOptions> options);
|
||||
void renderFinished();
|
||||
@@ -38,7 +39,6 @@ public:
|
||||
static std::unique_ptr<NodeMap::RenderOptions> ParseOptions(v8::Local<v8::Object>);
|
||||
static Nan::Persistent<v8::Function> constructor;
|
||||
|
||||
private:
|
||||
NodeMap(v8::Local<v8::Object>);
|
||||
~NodeMap();
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@ if (process.argv[1] === __filename && process.argv.length > 2) {
|
||||
tests = process.argv.slice(2);
|
||||
}
|
||||
|
||||
mbgl.on('message', function(msg) {
|
||||
console.log('%s (%s): %s', msg.severity, msg.class, msg.text);
|
||||
});
|
||||
|
||||
suite.run('native', {tests: tests}, function (style, options, callback) {
|
||||
var map = new mbgl.Map({
|
||||
ratio: options.pixelRatio,
|
||||
@@ -20,9 +24,18 @@ suite.run('native', {tests: tests}, function (style, options, callback) {
|
||||
}
|
||||
});
|
||||
|
||||
var timedOut = false;
|
||||
var watchdog = setTimeout(function () {
|
||||
timedOut = true;
|
||||
map.dumpDebugLogs();
|
||||
callback(new Error('timed out after 20 seconds'));
|
||||
}, 20000);
|
||||
|
||||
map.load(style);
|
||||
map.render(options, function (err, pixels) {
|
||||
map.release();
|
||||
if (timedOut) return;
|
||||
clearTimeout(watchdog);
|
||||
callback(err, pixels);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user