summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-06-03 18:05:04 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-08-05 11:42:22 +0200
commit692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6 (patch)
tree1d08af7d56e986dba2b548ff9b9a7e1a77c713ed /test
parente3ee55b28d0b230d054c9718f79a1f6d685cd62b (diff)
downloadqtlocation-mapboxgl-692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6.tar.gz
[build] switch to CMake
This is very much a work in progress.
Diffstat (limited to 'test')
-rw-r--r--test/src/main.cpp15
-rw-r--r--test/src/mbgl/test/util.cpp17
-rw-r--r--test/src/mbgl/test/util.hpp2
-rw-r--r--test/test.gypi169
4 files changed, 30 insertions, 173 deletions
diff --git a/test/src/main.cpp b/test/src/main.cpp
index a481dc5dc3..d01cf75ffc 100644
--- a/test/src/main.cpp
+++ b/test/src/main.cpp
@@ -1,5 +1,20 @@
#include <mbgl/test.hpp>
+#include <unistd.h>
+#include <cstring>
+#include <cerrno>
+#include <cstdio>
+
+#define xstr(s) str(s)
+#define str(s) #s
int main(int argc, char *argv[]) {
+#ifdef WORK_DIRECTORY
+ const int result = chdir(xstr(WORK_DIRECTORY));
+ if (result != 0) {
+ fprintf(stderr, "failed to change directory: %s\n", strerror(errno));
+ return errno;
+ }
+#endif
+
return mbgl::runTests(argc, argv);
}
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index 4021fd89b1..393d65b667 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -14,10 +14,17 @@
#include <unistd.h>
+#ifndef NODE_EXECUTABLE
+#define NODE_EXECUTABLE node
+#endif
+
+#define xstr(s) str(s)
+#define str(s) #s
+
namespace mbgl {
namespace test {
-Server::Server(const char* executable) {
+Server::Server(const char* script) {
int input[2];
int output[2];
@@ -48,14 +55,18 @@ Server::Server(const char* executable) {
close(output[1]);
close(output[0]);
+ const char* executable = xstr(NODE_EXECUTABLE);
+
+ fprintf(stderr, "executable: %s\n", executable);
+
// Launch the actual server process.
- int ret = execl(executable, executable, nullptr);
+ int ret = execl(executable, executable, script, nullptr);
// This call should not return. In case execl failed, we exit anyway.
if (ret < 0) {
Log::Error(Event::Setup, "Failed to start server: %s", strerror(errno));
}
- exit(0);
+ abort();
} else {
// This is the parent process.
diff --git a/test/src/mbgl/test/util.hpp b/test/src/mbgl/test/util.hpp
index 30108a8866..66499c6fd6 100644
--- a/test/src/mbgl/test/util.hpp
+++ b/test/src/mbgl/test/util.hpp
@@ -59,7 +59,7 @@ namespace test {
class Server {
public:
- Server(const char* executable);
+ Server(const char* script);
~Server();
private:
diff --git a/test/test.gypi b/test/test.gypi
deleted file mode 100644
index 82bd02bd83..0000000000
--- a/test/test.gypi
+++ /dev/null
@@ -1,169 +0,0 @@
-{
- 'targets': [
- {
- 'target_name': 'test-lib',
- 'type': 'static_library',
- 'standalone_static_library': 1,
- 'hard_dependency': 1,
- 'dependencies': [
- 'core',
- ],
-
- 'include_dirs': [
- '../include',
- '../src',
- '../platform/default',
- 'include',
- 'src',
- ],
-
- 'sources': [
- 'util/async_task.cpp',
- 'util/geo.cpp',
- 'util/image.cpp',
- 'util/mapbox.cpp',
- 'util/memory.cpp',
- 'util/merge_lines.cpp',
- 'util/run_loop.cpp',
- 'util/number_conversions.cpp',
- 'util/text_conversions.cpp',
- 'util/thread.cpp',
- 'util/thread_local.cpp',
- 'util/tile_cover.cpp',
- 'util/timer.cpp',
- 'util/token.cpp',
- 'util/work_queue.cpp',
- 'util/projection.cpp',
-
- 'algorithm/covered_by_children.cpp',
- 'algorithm/generate_clip_ids.cpp',
- 'algorithm/mock.hpp',
- 'algorithm/update_renderables.cpp',
-
- 'api/annotations.cpp',
- 'api/api_misuse.cpp',
- 'api/repeated_render.cpp',
- 'api/render_missing.cpp',
- 'api/set_style.cpp',
- 'api/custom_layer.cpp',
-
- 'geometry/binpack.cpp',
-
- 'gl/object.cpp',
-
- 'map/map.cpp',
- 'map/transform.cpp',
-
- 'math/minmax.cpp',
- 'math/clamp.cpp',
-
- 'text/quads.cpp',
-
- 'tile/geometry_tile_data.cpp',
- 'tile/tile_id.cpp',
-
- 'storage/offline.cpp',
- 'storage/offline_database.cpp',
- 'storage/offline_download.cpp',
- 'storage/asset_file_source.cpp',
- 'storage/default_file_source.cpp',
- 'storage/http_file_source.cpp',
- 'storage/online_file_source.cpp',
- 'storage/headers.cpp',
- 'storage/resource.cpp',
-
- 'style/glyph_store.cpp',
- 'style/source.cpp',
- 'style/style.cpp',
- 'style/style_layer.cpp',
- 'style/tile_source.cpp',
- 'style/filter.cpp',
- 'style/functions.cpp',
- 'style/style_parser.cpp',
-
- 'sprite/sprite_atlas.cpp',
- 'sprite/sprite_image.cpp',
- 'sprite/sprite_parser.cpp',
- 'sprite/sprite_store.cpp',
-
- 'src/mbgl/test/stub_file_source.hpp',
- 'src/mbgl/test/stub_file_source.cpp',
- 'src/mbgl/test/util.hpp',
- 'src/mbgl/test/util.cpp',
- 'src/mbgl/test/fixture_log_observer.hpp',
- 'src/mbgl/test/fixture_log_observer.cpp',
- 'src/mbgl/test/test.cpp'
- ],
-
- 'variables': {
- 'cflags_cc': [
- '<@(gtest_cflags)',
- '<@(opengl_cflags)',
- '<@(protozero_cflags)',
- '<@(boost_cflags)',
- '<@(sqlite_cflags)',
- '<@(geojsonvt_cflags)',
- '<@(supercluster_cflags)',
- '<@(kdbush_cflags)',
- '<@(rapidjson_cflags)',
- '<@(pixelmatch_cflags)',
- '<@(earcut_cflags)',
- ],
- 'ldflags': [
- '<@(gtest_ldflags)',
- '<@(sqlite_ldflags)',
- ],
- 'libraries': [
- '<@(gtest_static_libs)',
- '<@(sqlite_static_libs)'
- ],
- },
-
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'OTHER_CPLUSPLUSFLAGS': [ '<@(cflags_cc)' ],
- },
- }, {
- 'cflags_cc': [ '<@(cflags_cc)' ],
- }],
- ],
- 'link_settings': {
- 'conditions': [
- ['OS == "mac"', {
- 'libraries': [ '<@(libraries)' ],
- 'xcode_settings': { 'OTHER_LDFLAGS': [ '<@(ldflags)' ] }
- }, {
- 'libraries': [ '<@(libraries)', '<@(ldflags)' ],
- }]
- ],
- },
-
- 'direct_dependent_settings': {
- 'include_dirs': [
- 'include',
- ],
-
- # Force the linker to include all the objects from the lib-test archive. Otherwise they'd
- # be discarded because there are no undefined symbols to pull them in, and the resulting
- # executable would run zero tests.
-
- 'conditions': [
- ['OS == "mac"', {
- 'xcode_settings': {
- 'OTHER_LDFLAGS': [
- '-Wl,-force_load,<(PRODUCT_DIR)/libtest-lib.a',
- ],
- }
- }, {
- 'link_settings': {
- 'ldflags': [
- '-Wl,-whole-archive <(PRODUCT_DIR)/libtest-lib.a -Wl,-no-whole-archive',
- ],
- },
- }],
- ],
- },
- },
- ]
-}