summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-10-28 11:58:42 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-10-28 15:54:34 -0700
commit014b517820b935137d1f6cf654c42fb041ee2d71 (patch)
tree52faeed442d203a9cdfa5fc28f195da3f9897cbc /platform
parentdd56e832b5035a07ae6d1d362ee2560b24ae0681 (diff)
downloadqtlocation-mapboxgl-014b517820b935137d1f6cf654c42fb041ee2d71.tar.gz
[node] Output debug logs when a render test times out
Diffstat (limited to 'platform')
-rw-r--r--platform/node/src/node_map.cpp9
-rw-r--r--platform/node/src/node_map.hpp2
-rw-r--r--platform/node/test/render.test.js13
3 files changed, 23 insertions, 1 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index bbc3e0658d..76e14e3b94 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -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
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index 90edf44f73..d3b69e7c28 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -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();
diff --git a/platform/node/test/render.test.js b/platform/node/test/render.test.js
index 1a7ee6eaf3..5dd0c5ee10 100644
--- a/platform/node/test/render.test.js
+++ b/platform/node/test/render.test.js
@@ -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);
});
});