summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzmiao <miao.zhao@mapbox.com>2019-10-10 18:26:17 +0300
committerzmiao <miao.zhao@mapbox.com>2019-10-15 11:46:44 +0300
commit2aaa0f5cd6861eff942f5699a2ed876ab33a4122 (patch)
tree4c1d1d527fdbb8177e464b55c21fe86e2630e481
parent8bbc7f3612811fb5d0ef207cd8d76c7ae2d22b54 (diff)
downloadqtlocation-mapboxgl-2aaa0f5cd6861eff942f5699a2ed876ab33a4122.tar.gz
[test-runner] make render test runner run on android
remove redundant code Move rebase extra codes [test-runner] update cmake lists fix android cmake include header file Make both build system compile fix cmake-format error [test-runner] Fix paths [render-test] Fix render test name wip [test-runner] fix cmake [test-runner] fix build error [test-runner] remove unnecessary code [test-runner] nit fix cmake-format error
-rw-r--r--CMakeLists.txt5
-rw-r--r--Makefile41
-rw-r--r--cmake/render-test.cmake50
-rw-r--r--next/platform/android/android.cmake16
-rw-r--r--next/platform/linux/linux.cmake37
-rw-r--r--next/platform/macos/macos.cmake16
-rw-r--r--next/render-test/CMakeLists.txt34
-rw-r--r--platform/android/MapboxGLAndroidSDK/build.gradle3
-rw-r--r--platform/android/config.cmake23
-rw-r--r--platform/android/src/test/render_test_runner.cpp11
-rw-r--r--platform/default/src/mbgl/gfx/headless_frontend.cpp2
-rw-r--r--platform/default/src/mbgl/render-test/main.cpp6
-rw-r--r--platform/linux/config.cmake14
-rw-r--r--platform/macos/config.cmake18
-rw-r--r--render-test/allocation_index.cpp (renamed from render-test/src/test-runner/allocation_index.cpp)0
-rw-r--r--render-test/allocation_index.hpp (renamed from render-test/src/test-runner/allocation_index.hpp)0
-rw-r--r--render-test/filesystem.hpp (renamed from render-test/src/test-runner/filesystem.hpp)0
-rw-r--r--render-test/include/mbgl/render_test.hpp (renamed from render-test/include/mbgl/render_test_runner.hpp)0
-rw-r--r--render-test/metadata.hpp (renamed from render-test/src/test-runner/metadata.hpp)0
-rw-r--r--render-test/parser.cpp (renamed from render-test/src/test-runner/parser.cpp)160
-rw-r--r--render-test/parser.hpp (renamed from render-test/src/test-runner/parser.hpp)10
-rw-r--r--render-test/render_test.cpp (renamed from render-test/src/test-runner/test_runner.cpp)69
-rw-r--r--render-test/runner.cpp (renamed from render-test/src/test-runner/runner.cpp)30
-rw-r--r--render-test/runner.hpp (renamed from render-test/src/test-runner/runner.hpp)7
-rw-r--r--render-test/src/mbgl/render_test_runner.cpp10
-rw-r--r--render-test/src/test-runner/test_runner.hpp7
26 files changed, 368 insertions, 201 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9afded1deb..4d47ccc33d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,10 +176,13 @@ include(cmake/core.cmake)
if(COMMAND mbgl_platform_test)
include(cmake/test.cmake)
- include(cmake/render-test.cmake)
include(cmake/expression-test.cmake)
endif()
+if(COMMAND mbgl_platform_render_test)
+ include(cmake/render-test.cmake)
+endif()
+
if(COMMAND mbgl_platform_benchmark)
include(cmake/benchmark.cmake)
endif()
diff --git a/Makefile b/Makefile
index 1c1199932e..b2a72f1672 100644
--- a/Makefile
+++ b/Makefile
@@ -470,11 +470,13 @@ MBGL_ANDROID_ABIS += x86-64;x86_64
MBGL_ANDROID_LOCAL_WORK_DIR = /data/local/tmp/core-tests
MBGL_ANDROID_LOCAL_BENCHMARK_DIR = /data/local/tmp/benchmark
+MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR = /data/local/tmp/test-runner
MBGL_ANDROID_LIBDIR = lib$(if $(filter arm-v8 x86-64,$1),64)
MBGL_ANDROID_DALVIKVM = dalvikvm$(if $(filter arm-v8 x86-64,$1),64,32)
MBGL_ANDROID_APK_SUFFIX = $(if $(filter Release,$(BUILDTYPE)),release,debug)
MBGL_ANDROID_CORE_TEST_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype)/$2/core-tests
MBGL_ANDROID_BENCHMARK_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype)/$2/benchmark
+MBGL_ANDROID_TEST_RUNNER_DIR = platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/$(buildtype)/$2/test-runner
MBGL_ANDROID_STL ?= c++_static
MBGL_ANDROID_GRADLE = ./gradlew --parallel --max-workers=$(JOBS) -Pmapbox.buildtype=$(buildtype) -Pmapbox.stl=$(MBGL_ANDROID_STL)
@@ -504,6 +506,10 @@ android-test-lib-$1: platform/android/gradle/configuration.gradle
android-benchmark-$1: platform/android/gradle/configuration.gradle
cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 -Pmapbox.with_benchmark=true :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
+.PHONY: android-test-runner-$1
+android-test-runner-$1: platform/android/gradle/configuration.gradle
+ cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 -Pmapbox.with_test_runner=true :MapboxGLAndroidSDKTestApp:assemble$(BUILDTYPE)
+
# Build SDK for for specified abi
.PHONY: android-lib-$1
android-lib-$1: platform/android/gradle/configuration.gradle
@@ -573,6 +579,41 @@ run-android-benchmark-$1-%: android-benchmark-$1
rm -rf $(MBGL_ANDROID_BENCHMARK_DIR)/results && mkdir -p $(MBGL_ANDROID_BENCHMARK_DIR)/results
adb pull $(MBGL_ANDROID_LOCAL_BENCHMARK_DIR)/results.json $(MBGL_ANDROID_BENCHMARK_DIR)/results > /dev/null 2>&1
+# Run render tests for specified abi
+.PHONY: run-android-test-runner-$1
+run-android-test-runner-$1: run-android-test-runner-$1-*
+
+run-android-test-runner-$1-%: android-test-runner-$1
+ mkdir -p $(MBGL_ANDROID_TEST_RUNNER_DIR)
+ unzip -o platform/android/MapboxGLAndroidSDKTestApp/build/outputs/apk/$(buildtype)/MapboxGLAndroidSDKTestApp-$(MBGL_ANDROID_APK_SUFFIX).apk classes.dex -d $(MBGL_ANDROID_TEST_RUNNER_DIR)
+
+ # Delete old test folder and create new one
+ adb shell "rm -Rf $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)"
+ adb shell "mkdir -p $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/platform && mkdir -p $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/platform/node && mkdir -p $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/platform/node/tests"
+ # Push compiled java sources, test data and executable to device
+ adb push $(MBGL_ANDROID_TEST_RUNNER_DIR)/classes.dex $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR) > /dev/null 2>&1
+ adb push platform/android/MapboxGLAndroidSDK/build/intermediates/intermediate-jars/$(buildtype)/jni/$2/libmapbox-gl.so $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR) > /dev/null 2>&1
+ # Push all the necessary test resources
+ # adb push mapbox-gl-js/test/integration/render-tests $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/render-tests > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/query-tests $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/query-tests > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/tiles $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/tiles > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/glyphs $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/glyphs > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/sprites $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/sprites > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/styles $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/styles > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/tilesets $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/tilesets > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/image $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/image > /dev/null 2>&1
+ adb push mapbox-gl-js/test/integration/video $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/video > /dev/null 2>&1
+ adb push vendor/mapbox-gl-styles/styles $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/mapbox-gl-js/test/integration/mapbox-gl-styles/styles > /dev/null 2>&1
+ adb push render-test/expected $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/render-test/expected > /dev/null 2>&1
+ adb push platform/node/test/ignores.json $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/platform/node/tests > /dev/null 2>&1
+ adb push platform/android/MapboxGLAndroidSDK/build/intermediates/cmake/$(buildtype)/obj/$2/mbgl-render-test $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR) > /dev/null 2>&1
+
+ # Run render tests.
+ adb shell "export LD_LIBRARY_PATH=$(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR) && cd $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR) && chmod +x mbgl-render-test && ./mbgl-render-test --class_path=$(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/classes.dex --rootPath=$(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)"
+
+ # Pull index.html from the device
+ adb pull $(MBGL_ANDROID_LOCAL_TEST_RUNNER_DIR)/index.html $(MBGL_ANDROID_TEST_RUNNER_DIR) > /dev/null 2>&1
+
# Run the test app on connected android device with specified abi
.PHONY: run-android-$1
run-android-$1: platform/android/gradle/configuration.gradle
diff --git a/cmake/render-test.cmake b/cmake/render-test.cmake
index 1fa011d461..799bd2946e 100644
--- a/cmake/render-test.cmake
+++ b/cmake/render-test.cmake
@@ -1,30 +1,48 @@
-add_executable(mbgl-render-test
- render-test/src/mbgl/allocation_index.cpp
- render-test/src/mbgl/render_test_runner.cpp
- render-test/src/mbgl/parser.cpp
- render-test/src/mbgl/runner.cpp
+add_executable(
+ mbgl-render-test
expression-test/test_runner_common.cpp
expression-test/test_runner_common.hpp
+ render-test/allocation_index.cpp
+ render-test/allocation_index.hpp
+ render-test/filesystem.hpp
+ render-test/filesystem.hpp
+ render-test/include/mbgl/render_test.hpp
+ render-test/metadata.hpp
+ render-test/parser.cpp
+ render-test/parser.hpp
+ render-test/render_test.cpp
+ render-test/runner.cpp
+ render-test/runner.hpp
)
-target_include_directories(mbgl-render-test
+target_include_directories(
+ mbgl-render-test
PRIVATE src
PRIVATE platform/default/include
- PRIVATE render-test/include
PRIVATE render-test/src
)
-target_link_libraries(mbgl-render-test PRIVATE
- mbgl-core
- mbgl-filesource
- Mapbox::Base::Extras::args
- mbgl-vendor-expected
- Mapbox::Base::Extras::filesystem
- Mapbox::Base::pixelmatch-cpp
- Mapbox::Base::Extras::rapidjson
+target_include_directories(
+ mbgl-render-test
+ PUBLIC render-test/include
+ PUBLIC include
)
-mbgl_platform_test()
+target_link_libraries(
+ mbgl-render-test
+ PRIVATE
+ mbgl-core
+ mbgl-filesource
+ Mapbox::Base::Extras::args
+ mbgl-vendor-expected
+ Mapbox::Base::Extras::filesystem
+ Mapbox::Base::pixelmatch-cpp
+ Mapbox::Base::Extras::rapidjson
+)
+
+mbgl_platform_render_test()
+
+create_source_groups(mbgl-render-test)
set_target_properties(mbgl-render-test PROPERTIES FOLDER "Executables")
diff --git a/next/platform/android/android.cmake b/next/platform/android/android.cmake
index 6d0ed6fe97..0e83edba55 100644
--- a/next/platform/android/android.cmake
+++ b/next/platform/android/android.cmake
@@ -295,16 +295,24 @@ target_link_libraries(
PRIVATE Mapbox::Base::jni.hpp mapbox-gl mbgl-benchmark
)
-add_executable(
+add_library(
+ mbgl-render-test-runner SHARED
+ ${MBGL_ROOT}/platform/android/src/test/render_test_runner.cpp ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c
+)
+
+target_include_directories(
mbgl-render-test-runner
- ${MBGL_ROOT}/platform/android/src/test/render_test_runner.cpp
- ${MBGL_ROOT}/platform/android/src/test/runtime.cpp
+ ${MBGL_ROOT}/platform/android/src/test/render_test_runner.cpp ${MBGL_ROOT}/platform/android/src/test/runtime.cpp
${MBGL_ROOT}/platform/android/src/test/runtime.hpp
)
target_link_libraries(
mbgl-render-test-runner
- PRIVATE Mapbox::Base::jni.hpp mapbox-gl mbgl-render-test
+ PRIVATE
+ Mapbox::Base::jni.hpp
+ mbgl-render-test
+ android
+ log
)
# Android has no concept of MinSizeRel on android.toolchain.cmake and provides configurations tuned for binary size. We can push it a bit
diff --git a/next/platform/linux/linux.cmake b/next/platform/linux/linux.cmake
index 18531a2856..108def8fb2 100644
--- a/next/platform/linux/linux.cmake
+++ b/next/platform/linux/linux.cmake
@@ -95,7 +95,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/bin)
add_subdirectory(${PROJECT_SOURCE_DIR}/expression-test)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/glfw)
add_subdirectory(${PROJECT_SOURCE_DIR}/platform/node)
-add_subdirectory(${PROJECT_SOURCE_DIR}/render-test)
add_executable(
mbgl-test-runner
@@ -122,5 +121,41 @@ target_link_libraries(
PRIVATE mbgl-benchmark
)
+add_executable(
+ mbgl-render-test-runner
+ ${MBGL_ROOT}/platform/default/src/mbgl/render-test/main.cpp
+)
+
+target_link_libraries(
+ mbgl-render-test-runner
+ PRIVATE mbgl-render-test
+)
+
add_test(NAME mbgl-benchmark-runner COMMAND mbgl-benchmark-runner WORKING_DIRECTORY ${MBGL_ROOT})
add_test(NAME mbgl-test-runner COMMAND mbgl-test-runner WORKING_DIRECTORY ${MBGL_ROOT})
+string(RANDOM LENGTH 5 ALPHABET 0123456789 MBGL_RENDER_TEST_SEED)
+add_test(
+ NAME mbgl-render-test-runner
+ COMMAND
+ mbgl-render-test-runner
+ render-tests
+ --recycle-map
+ --shuffle
+ --seed
+ ${MBGL_RENDER_TEST_SEED}
+ WORKING_DIRECTORY ${MBGL_ROOT}
+)
+
+add_test(
+ NAME mbgl-render-test-probes
+ COMMAND
+ mbgl-render-test-runner
+ render-tests
+ --recycle-map
+ --shuffle
+ --seed=${MBGL_RENDER_TEST_SEED}
+ --rootPath=render-test
+ WORKING_DIRECTORY ${MBGL_ROOT}
+)
+
+add_test(NAME mbgl-query-test COMMAND mbgl-render-test-runner query-tests WORKING_DIRECTORY ${MBGL_ROOT})
diff --git a/next/platform/macos/macos.cmake b/next/platform/macos/macos.cmake
index 37cc62c75a..58d7152b24 100644
--- a/next/platform/macos/macos.cmake
+++ b/next/platform/macos/macos.cmake
@@ -197,6 +197,7 @@ set_property(TARGET mbgl-render-test-runner PROPERTY FOLDER Executables)
add_test(NAME mbgl-benchmark-runner COMMAND mbgl-benchmark-runner WORKING_DIRECTORY ${MBGL_ROOT})
add_test(NAME mbgl-test-runner COMMAND mbgl-test-runner WORKING_DIRECTORY ${MBGL_ROOT})
+string(RANDOM LENGTH 5 ALPHABET 0123456789 MBGL_RENDER_TEST_SEED)
add_test(
NAME mbgl-render-test-runner
COMMAND
@@ -208,4 +209,17 @@ add_test(
${MBGL_RENDER_TEST_SEED}
WORKING_DIRECTORY ${MBGL_ROOT}
)
-add_test(NAME mbgl-query-test COMMAND mbgl-render-test query-tests WORKING_DIRECTORY ${MBGL_ROOT}) \ No newline at end of file
+
+add_test(
+ NAME mbgl-render-test-probes
+ COMMAND
+ mbgl-render-test-runner
+ render-tests
+ --recycle-map
+ --shuffle
+ --seed=${MBGL_RENDER_TEST_SEED}
+ --rootPath=render-test
+ WORKING_DIRECTORY ${MBGL_ROOT}
+)
+
+add_test(NAME mbgl-query-test COMMAND mbgl-render-test-runner query-tests WORKING_DIRECTORY ${MBGL_ROOT})
diff --git a/next/render-test/CMakeLists.txt b/next/render-test/CMakeLists.txt
index 81d9bdae91..c44d9df06b 100644
--- a/next/render-test/CMakeLists.txt
+++ b/next/render-test/CMakeLists.txt
@@ -1,20 +1,18 @@
-
add_library(
- mbgl-render-test STATIC EXCLUDE_FROM_ALL
- ${MBGL_ROOT}/render-test/src/mbgl/render_test_runner.cpp
- ${MBGL_ROOT}/render-test/filesystem.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/allocation_index.cpp
- ${MBGL_ROOT}/render-test/src/test-runner/allocation_index.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/filesystem.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/metadata.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/parser.cpp
- ${MBGL_ROOT}/render-test/src/test-runner/parser.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/runner.cpp
- ${MBGL_ROOT}/render-test/src/test-runner/runner.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/test_runner.hpp
- ${MBGL_ROOT}/render-test/src/test-runner/test_runner.cpp
+ mbgl-render-test SHARED EXCLUDE_FROM_ALL
${MBGL_ROOT}/expression-test/test_runner_common.cpp
${MBGL_ROOT}/expression-test/test_runner_common.hpp
+ ${MBGL_ROOT}/render-test/allocation_index.cpp
+ ${MBGL_ROOT}/render-test/allocation_index.hpp
+ ${MBGL_ROOT}/render-test/filesystem.hpp
+ ${MBGL_ROOT}/render-test/filesystem.hpp
+ ${MBGL_ROOT}/render-test/include/mbgl/render_test.hpp
+ ${MBGL_ROOT}/render-test/metadata.hpp
+ ${MBGL_ROOT}/render-test/parser.cpp
+ ${MBGL_ROOT}/render-test/parser.hpp
+ ${MBGL_ROOT}/render-test/render_test.cpp
+ ${MBGL_ROOT}/render-test/runner.cpp
+ ${MBGL_ROOT}/render-test/runner.hpp
)
target_compile_definitions(
@@ -25,8 +23,8 @@ target_compile_definitions(
# FIXME: Should not use core private interface
target_include_directories(
mbgl-render-test
- PRIVATE
- ${MBGL_ROOT}/src
+ PRIVATE
+ ${MBGL_ROOT}/src
${MBGL_ROOT}/platform/default/include
${MBGL_ROOT}/platform/gfx/gl/src
${MBGL_ROOT}/render-test/src
@@ -48,13 +46,9 @@ target_link_libraries(
mbgl-core
mbgl-vendor-boost
)
-if(CMAKE_SYSTEM_NAME STREQUAL Android)
- set_target_properties(mbgl-render-test PROPERTIES LINK_FLAGS_RELEASE "-fuse-ld=gold -O2 -flto -Wl,--icf=safe")
-endif()
if(CMAKE_SYSTEM_NAME STREQUAL Android)
set_target_properties(mbgl-render-test PROPERTIES LINK_FLAGS_RELEASE "-fuse-ld=gold -O2 -flto -Wl,--icf=safe")
endif()
set_property(TARGET mbgl-render-test PROPERTY FOLDER Core)
-
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index 5ee3af61e2..7f832e6f1d 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -44,6 +44,9 @@ android {
if (project.hasProperty("mapbox.with_benchmark")) {
nativeTargets.add("mbgl-benchmark")
}
+ if (project.hasProperty("mapbox.with_test_runner")) {
+ nativeTargets.add("mbgl-render-test")
+ }
nativeBuild(nativeTargets)
// avoid naming conflicts, force usage of prefix
diff --git a/platform/android/config.cmake b/platform/android/config.cmake
index 98d18ca324..495abe9510 100644
--- a/platform/android/config.cmake
+++ b/platform/android/config.cmake
@@ -106,6 +106,29 @@ macro(mbgl_platform_test)
)
endmacro()
+## Render Test executable ##
+macro(mbgl_platform_render_test)
+ target_sources(mbgl-render-test
+ PRIVATE platform/android/src/test/render_test_runner.cpp
+ PRIVATE platform/android/src/test/runtime.cpp
+ )
+
+ target_include_directories(mbgl-render-test
+ PRIVATE platform/android/include
+ )
+
+ set_target_properties(mbgl-render-test
+ PROPERTIES
+ LINK_FLAGS
+ "-fPIE -pie \
+ -Wl,--export-dynamic \
+ -Wl,--version-script=${CMAKE_SOURCE_DIR}/platform/android/src/test/version-script")
+
+ target_link_libraries(mbgl-render-test
+ PRIVATE mbgl-filesource
+ )
+endmacro()
+
## Benchmark ##
macro(mbgl_platform_benchmark)
target_sources(mbgl-benchmark
diff --git a/platform/android/src/test/render_test_runner.cpp b/platform/android/src/test/render_test_runner.cpp
index 9818135f85..aa330a2322 100644
--- a/platform/android/src/test/render_test_runner.cpp
+++ b/platform/android/src/test/render_test_runner.cpp
@@ -1,10 +1,19 @@
+#include <mbgl/render_test.hpp>
#include "runtime.hpp"
-#include <mbgl/render_test_runner.hpp>
int main(int argc, char *argv[]) {
if (!mbgl::android::initRuntime(argc, argv)) {
return 1;
}
+ for (int i = 1; i < argc; ++i) {
+ const std::string arg{argv[i]};
+ std::string kClassPathCommand("--class_path=");
+ if (arg.compare(0, kClassPathCommand.length(), kClassPathCommand) == 0) {
+ // Remove this item from the list
+ argv[i][0] = 0;
+ }
+ }
+
return mbgl::runRenderTests(argc, argv);
}
diff --git a/platform/default/src/mbgl/gfx/headless_frontend.cpp b/platform/default/src/mbgl/gfx/headless_frontend.cpp
index 287567adbd..95da7b42be 100644
--- a/platform/default/src/mbgl/gfx/headless_frontend.cpp
+++ b/platform/default/src/mbgl/gfx/headless_frontend.cpp
@@ -147,7 +147,7 @@ PremultipliedImage HeadlessFrontend::render(Map& map) {
if (error) {
std::rethrow_exception(error);
}
-
+
return result;
}
diff --git a/platform/default/src/mbgl/render-test/main.cpp b/platform/default/src/mbgl/render-test/main.cpp
index ecb7199652..9b22b20e00 100644
--- a/platform/default/src/mbgl/render-test/main.cpp
+++ b/platform/default/src/mbgl/render-test/main.cpp
@@ -1,7 +1,5 @@
-#include <mbgl/render_test_runner.hpp>
+#include <mbgl/render_test.hpp>
int main(int argc, char *argv[]) {
-
return mbgl::runRenderTests(argc, argv);
-
-} \ No newline at end of file
+}
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index 26de2430ce..6ad8a988b3 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -168,6 +168,20 @@ macro(mbgl_platform_test)
)
endmacro()
+macro(mbgl_platform_render_test)
+ target_sources(mbgl-render-test
+ PRIVATE platform/default/src/mbgl/render-test/main.cpp
+ )
+
+ target_include_directories(mbgl-render-test
+ PRIVATE platform/linux
+ )
+
+ target_link_libraries(mbgl-render-test
+ PRIVATE mbgl-filesource
+ PRIVATE mbgl-loop-uv
+ )
+endmacro()
macro(mbgl_platform_benchmark)
target_sources(mbgl-benchmark
diff --git a/platform/macos/config.cmake b/platform/macos/config.cmake
index 5b01811234..740335f05e 100644
--- a/platform/macos/config.cmake
+++ b/platform/macos/config.cmake
@@ -102,26 +102,22 @@ macro(mbgl_platform_test)
PRIVATE mbgl-loop-darwin
)
- target_sources(mbgl-test-render
+endmacro()
+
+macro(mbgl_platform_render_test)
+ target_sources(mbgl-render-test
PRIVATE platform/default/src/mbgl/layermanager/layer_manager.cpp
- PRIVATE platform/default/src/mbgl/test/main.cpp
+ PRIVATE platform/default/src/mbgl/render-test/main.cpp
)
- target_include_directories(mbgl-test
+ target_include_directories(mbgl-render-test
PRIVATE platform/macos
)
- set_source_files_properties(
- platform/default/src/mbgl/test/main.cpp
- PROPERTIES
- COMPILE_FLAGS -DWORK_DIRECTORY="${CMAKE_SOURCE_DIR}"
- )
-
- target_link_libraries(mbgl-test
+ target_link_libraries(mbgl-render-test
PRIVATE mbgl-filesource
PRIVATE mbgl-loop-darwin
)
-
endmacro()
macro(mbgl_platform_benchmark)
diff --git a/render-test/src/test-runner/allocation_index.cpp b/render-test/allocation_index.cpp
index 144c18ddd5..144c18ddd5 100644
--- a/render-test/src/test-runner/allocation_index.cpp
+++ b/render-test/allocation_index.cpp
diff --git a/render-test/src/test-runner/allocation_index.hpp b/render-test/allocation_index.hpp
index 71da441c1f..71da441c1f 100644
--- a/render-test/src/test-runner/allocation_index.hpp
+++ b/render-test/allocation_index.hpp
diff --git a/render-test/src/test-runner/filesystem.hpp b/render-test/filesystem.hpp
index cee7e9d911..cee7e9d911 100644
--- a/render-test/src/test-runner/filesystem.hpp
+++ b/render-test/filesystem.hpp
diff --git a/render-test/include/mbgl/render_test_runner.hpp b/render-test/include/mbgl/render_test.hpp
index 42a539603d..42a539603d 100644
--- a/render-test/include/mbgl/render_test_runner.hpp
+++ b/render-test/include/mbgl/render_test.hpp
diff --git a/render-test/src/test-runner/metadata.hpp b/render-test/metadata.hpp
index bd26e6a7ba..bd26e6a7ba 100644
--- a/render-test/src/test-runner/metadata.hpp
+++ b/render-test/metadata.hpp
diff --git a/render-test/src/test-runner/parser.cpp b/render-test/parser.cpp
index f4e54493eb..61ace4e3ed 100644
--- a/render-test/src/test-runner/parser.cpp
+++ b/render-test/parser.cpp
@@ -96,8 +96,11 @@ std::string prependFileScheme(const std::string &url) {
return fileScheme + url;
}
-mbgl::optional<std::string> getVendorPath(const std::string& url, const std::regex& regex, bool glyphsPath = false) {
- static const mbgl::filesystem::path vendorPath(std::string(TEST_RUNNER_ROOT_PATH) + "/vendor/");
+mbgl::optional<std::string> getVendorPath(const std::string& url,
+ const std::regex& regex,
+ const std::string& rootPath,
+ bool glyphsPath = false) {
+ static const mbgl::filesystem::path vendorPath(rootPath + "/vendor/");
mbgl::filesystem::path file = std::regex_replace(url, regex, vendorPath.string());
if (mbgl::filesystem::exists(file.parent_path())) {
@@ -111,8 +114,12 @@ mbgl::optional<std::string> getVendorPath(const std::string& url, const std::reg
return {};
}
-mbgl::optional<std::string> getIntegrationPath(const std::string& url, const std::string& parent, const std::regex& regex, bool glyphsPath = false) {
- static const mbgl::filesystem::path integrationPath(std::string(TEST_RUNNER_ROOT_PATH) + "/mapbox-gl-js/test/integration/");
+mbgl::optional<std::string> getIntegrationPath(const std::string& url,
+ const std::string& parent,
+ const std::regex& regex,
+ const std::string& rootPath,
+ bool glyphsPath = false) {
+ static const mbgl::filesystem::path integrationPath(rootPath + "/mapbox-gl-js/test/integration/");
mbgl::filesystem::path file = std::regex_replace(url, regex, integrationPath.string() + parent);
if (mbgl::filesystem::exists(file.parent_path())) {
@@ -126,54 +133,58 @@ mbgl::optional<std::string> getIntegrationPath(const std::string& url, const std
return {};
}
-mbgl::optional<std::string> localizeLocalURL(const std::string& url, bool glyphsPath = false) {
+mbgl::optional<std::string> localizeLocalURL(const std::string& url,
+ const std::string& rootPath,
+ bool glyphsPath = false) {
static const std::regex regex { "local://" };
- if (auto vendorPath = getVendorPath(url, regex, glyphsPath)) {
+ if (auto vendorPath = getVendorPath(url, regex, rootPath, glyphsPath)) {
return vendorPath;
} else {
- return getIntegrationPath(url, "", regex, glyphsPath);
+ return getIntegrationPath(url, "", regex, rootPath, glyphsPath);
}
}
-mbgl::optional<std::string> localizeHttpURL(const std::string& url) {
+mbgl::optional<std::string> localizeHttpURL(const std::string& url, const std::string& rootPath) {
static const std::regex regex { "http://localhost:2900" };
- if (auto vendorPath = getVendorPath(url, regex)) {
+ if (auto vendorPath = getVendorPath(url, regex, rootPath)) {
return vendorPath;
} else {
- return getIntegrationPath(url, "", regex);
+ return getIntegrationPath(url, "", regex, rootPath);
}
}
-mbgl::optional<std::string> localizeMapboxSpriteURL(const std::string& url) {
+mbgl::optional<std::string> localizeMapboxSpriteURL(const std::string& url, const std::string& rootPath) {
static const std::regex regex { "mapbox://" };
- return getIntegrationPath(url, "", regex);
+ return getIntegrationPath(url, "", regex, rootPath);
}
-mbgl::optional<std::string> localizeMapboxFontsURL(const std::string& url) {
+mbgl::optional<std::string> localizeMapboxFontsURL(const std::string& url, const std::string& rootPath) {
static const std::regex regex { "mapbox://fonts" };
- return getIntegrationPath(url, "glyphs/", regex, true);
+ return getIntegrationPath(url, "glyphs/", regex, rootPath, true);
}
-mbgl::optional<std::string> localizeMapboxTilesURL(const std::string& url) {
+mbgl::optional<std::string> localizeMapboxTilesURL(const std::string& url, const std::string& rootPath) {
static const std::regex regex { "mapbox://" };
- if (auto vendorPath = getVendorPath(url, regex)) {
+ if (auto vendorPath = getVendorPath(url, regex, rootPath)) {
return vendorPath;
} else {
- return getIntegrationPath(url, "tiles/", regex);
+ return getIntegrationPath(url, "tiles/", regex, rootPath);
}
}
-mbgl::optional<std::string> localizeMapboxTilesetURL(const std::string& url) {
+mbgl::optional<std::string> localizeMapboxTilesetURL(const std::string& url, const std::string& rootPath) {
static const std::regex regex { "mapbox://" };
- return getIntegrationPath(url, "tilesets/", regex);
+ return getIntegrationPath(url, "tilesets/", regex, rootPath);
}
-TestPaths makeTestPaths(mbgl::filesystem::path stylePath) {
+TestPaths makeTestPaths(mbgl::filesystem::path stylePath,
+ const mbgl::filesystem::path& testBasePath,
+ const std::vector<std::string>& platformExpectationPaths) {
std::vector<mbgl::filesystem::path> expectations{ stylePath };
expectations.front().remove_filename();
- const static std::regex regex{ TestRunner::getBasePath() };
- for (const std::string& path : TestRunner::getPlatformExpectationsPaths()) {
+ const static std::regex regex{testBasePath.string()};
+ for (const std::string& path : platformExpectationPaths) {
expectations.emplace_back(std::regex_replace(expectations.front().string(), regex, path));
assert(!expectations.back().empty());
}
@@ -334,6 +345,17 @@ std::vector<std::string> readExpectedJSONEntries(const mbgl::filesystem::path& b
return readExpectedEntries(regex, base);
}
+const std::string& getBasePath(const std::string& rootPath) {
+ const static std::string result = std::string(rootPath).append("/mapbox-gl-js/test/integration");
+ return result;
+}
+
+const std::vector<std::string>& getPlatformExpectationsPaths(const std::string& rootPath) {
+ // TODO: Populate from command line.
+ const static std::vector<std::string> result{std::string(rootPath).append("/render-test/expected")};
+ return result;
+}
+
ArgumentsTuple parseArguments(int argc, char** argv) {
args::ArgumentParser argumentParser("Mapbox GL Test Runner");
@@ -345,8 +367,8 @@ ArgumentsTuple parseArguments(int argc, char** argv) {
{ 's', "shuffle" });
args::ValueFlag<uint32_t> seedValue(argumentParser, "seed", "Shuffle seed (default: random)",
{ "seed" });
- args::ValueFlag<std::string> testPathValue(argumentParser, "rootPath", "Test root rootPath",
- { 'p', "rootPath" });
+ args::ValueFlag<std::string> testRootPathValue(argumentParser, "rootPath", "Test root rootPath",
+ { 'p', "rootPath" });
args::ValueFlag<std::regex> testFilterValue(argumentParser, "filter", "Test filter regex",
{ 'f', "filter" });
args::PositionalList<std::string> testNameValues(argumentParser, "URL", "Test name(s)");
@@ -375,19 +397,21 @@ ArgumentsTuple parseArguments(int argc, char** argv) {
exit(3);
}
- mbgl::filesystem::path rootPath {testPathValue ? args::get(testPathValue) : TestRunner::getBasePath()};
+ mbgl::filesystem::path rootPath{testRootPathValue ? args::get(testRootPathValue)
+ : std::string(TEST_RUNNER_ROOT_PATH)};
if (!mbgl::filesystem::exists(rootPath)) {
mbgl::Log::Error(mbgl::Event::General, "Provided rootPath '%s' does not exist.", rootPath.string().c_str());
exit(4);
}
+ mbgl::filesystem::path basePath{getBasePath(rootPath.string())};
std::vector<mbgl::filesystem::path> paths;
for (const auto& id : args::get(testNameValues)) {
- paths.emplace_back(rootPath / id);
+ paths.emplace_back(basePath.string() + "/" + id);
}
if (paths.empty()) {
- paths.emplace_back(rootPath);
+ paths.emplace_back(basePath);
}
// Recursively traverse through the test paths and collect test directories containing "style.json".
@@ -404,32 +428,32 @@ ArgumentsTuple parseArguments(int argc, char** argv) {
continue;
}
if (testPath.path().filename() == "style.json") {
- testPaths.emplace_back(makeTestPaths(testPath));
+ testPaths.emplace_back(
+ makeTestPaths(testPath, basePath, getPlatformExpectationsPaths(rootPath.string())));
}
}
}
- return ArgumentsTuple {
- recycleMapFlag ? args::get(recycleMapFlag) : false,
- shuffleFlag ? args::get(shuffleFlag) : false, seedValue ? args::get(seedValue) : 1u,
- testPathValue ? args::get(testPathValue) : TestRunner::getBasePath(),
- std::move(testPaths)
- };
+ return ArgumentsTuple{recycleMapFlag ? args::get(recycleMapFlag) : false,
+ shuffleFlag ? args::get(shuffleFlag) : false,
+ seedValue ? args::get(seedValue) : 1u,
+ rootPath,
+ std::move(testPaths)};
}
-std::vector<std::pair<std::string, std::string>> parseIgnores() {
+std::vector<std::pair<std::string, std::string>> parseIgnores(const std::string& testRootPath) {
std::vector<std::pair<std::string, std::string>> ignores;
- auto mainIgnoresPath = mbgl::filesystem::path(TEST_RUNNER_ROOT_PATH).append("platform/node/test/ignores.json");
+ auto mainIgnoresPath = mbgl::filesystem::path(testRootPath).append("platform/node/test/ignores.json");
mbgl::filesystem::path platformSpecificIgnores;
mbgl::filesystem::path ownTestsIgnores =
mbgl::filesystem::path(TEST_RUNNER_ROOT_PATH).append("render-test/tests/should-fail.json");
#ifdef __APPLE__
- platformSpecificIgnores = mbgl::filesystem::path(TEST_RUNNER_ROOT_PATH).append("render-test/mac-ignores.json");
+ platformSpecificIgnores = mbgl::filesystem::path(testRootPath).append("render-test/mac-ignores.json");
#elif __linux__
- platformSpecificIgnores = mbgl::filesystem::path(TEST_RUNNER_ROOT_PATH).append("render-test/linux-ignores.json");
+ platformSpecificIgnores = mbgl::filesystem::path(testRootPath).append("render-test/linux-ignores.json");
#endif
std::vector<mbgl::filesystem::path> ignoresPaths = {mainIgnoresPath, platformSpecificIgnores, ownTestsIgnores};
@@ -503,7 +527,7 @@ TestMetrics readExpectedMetrics(const mbgl::filesystem::path& path) {
return result;
}
-TestMetadata parseTestMetadata(const TestPaths& paths) {
+TestMetadata parseTestMetadata(const TestPaths& paths, const std::string& rootPath) {
TestMetadata metadata;
metadata.paths = paths;
@@ -514,7 +538,7 @@ TestMetadata parseTestMetadata(const TestPaths& paths) {
}
metadata.document = std::move(maybeJson.get<mbgl::JSDocument>());
- localizeStyleURLs(metadata.document, metadata.document);
+ localizeStyleURLs(metadata.document, metadata.document, rootPath);
if (!metadata.document.HasMember("metadata")) {
mbgl::Log::Warning(mbgl::Event::ParseStyle, "Style has no 'metadata': %s",
@@ -669,8 +693,11 @@ std::string createResultItem(const TestMetadata& metadata, bool hasFailedTests)
html.append(" src=\"data:image/png;base64," + encodeBase64(metadata.actual) + "\">\n");
}
} else {
- assert(!metadata.errorMessage.empty());
- html.append("<p style=\"color: red\"><strong>Error:</strong> " + metadata.errorMessage + "</p>\n");
+ if (metadata.errorMessage.empty()) {
+ html.append("<p style=\"color: red\"><strong>Error:</strong> " + "metadata.errorMessage is empty" + "</p>\n");
+ } else {
+ html.append("<p style=\"color: red\"><strong>Error:</strong> " + metadata.errorMessage + "</p>\n");
+ }
}
if (metadata.difference != 0.0) {
if (metadata.renderTest) {
@@ -762,21 +789,21 @@ std::string createResultPage(const TestStatistics& stats, const std::vector<Test
return resultsPage;
}
-std::string localizeURL(const std::string& url) {
+std::string localizeURL(const std::string& url, const std::string& rootPath) {
static const std::regex regex { "local://" };
- if (auto vendorPath = getVendorPath(url, regex)) {
+ if (auto vendorPath = getVendorPath(url, regex, rootPath)) {
return *vendorPath;
} else {
- return getIntegrationPath(url, "", regex).value_or(url);
+ return getIntegrationPath(url, "", regex, rootPath).value_or(url);
}
}
-void localizeSourceURLs(mbgl::JSValue& root, mbgl::JSDocument& document) {
+void localizeSourceURLs(mbgl::JSValue& root, mbgl::JSDocument& document, const std::string& rootPath) {
if (root.HasMember("urls") && root["urls"].IsArray()) {
for (auto& urlValue : root["urls"].GetArray()) {
- const std::string path = prependFileScheme(localizeMapboxTilesetURL(urlValue.GetString())
- .value_or(localizeLocalURL(urlValue.GetString())
- .value_or(urlValue.GetString())));
+ const std::string path = prependFileScheme(
+ localizeMapboxTilesetURL(urlValue.GetString(), rootPath)
+ .value_or(localizeLocalURL(urlValue.GetString(), rootPath).value_or(urlValue.GetString())));
urlValue.Set<std::string>(path, document.GetAllocator());
}
}
@@ -786,9 +813,9 @@ void localizeSourceURLs(mbgl::JSValue& root, mbgl::JSDocument& document) {
static const std::string video("video");
mbgl::JSValue& urlValue = root["url"];
- const std::string path = prependFileScheme(localizeMapboxTilesetURL(urlValue.GetString())
- .value_or(localizeLocalURL(urlValue.GetString())
- .value_or(urlValue.GetString())));
+ const std::string path = prependFileScheme(
+ localizeMapboxTilesetURL(urlValue.GetString(), rootPath)
+ .value_or(localizeLocalURL(urlValue.GetString(), rootPath).value_or(urlValue.GetString())));
urlValue.Set<std::string>(path, document.GetAllocator());
if (root["type"].GetString() != image && root["type"].GetString() != video) {
@@ -807,43 +834,44 @@ void localizeSourceURLs(mbgl::JSValue& root, mbgl::JSDocument& document) {
mbgl::JSValue& tilesValue = root["tiles"];
assert(tilesValue.IsArray());
for (auto& tileValue : tilesValue.GetArray()) {
- const std::string path = prependFileScheme(localizeMapboxTilesURL(tileValue.GetString())
- .value_or(localizeLocalURL(tileValue.GetString())
- .value_or(localizeHttpURL(tileValue.GetString())
- .value_or(tileValue.GetString()))));
+ const std::string path =
+ prependFileScheme(localizeMapboxTilesURL(tileValue.GetString(), rootPath)
+ .value_or(localizeLocalURL(tileValue.GetString(), rootPath)
+ .value_or(localizeHttpURL(tileValue.GetString(), rootPath)
+ .value_or(tileValue.GetString()))));
tileValue.Set<std::string>(path, document.GetAllocator());
}
}
if (root.HasMember("data") && root["data"].IsString()) {
mbgl::JSValue& dataValue = root["data"];
- const std::string path = prependFileScheme(localizeLocalURL(dataValue.GetString())
- .value_or(dataValue.GetString()));
+ const std::string path =
+ prependFileScheme(localizeLocalURL(dataValue.GetString(), rootPath).value_or(dataValue.GetString()));
dataValue.Set<std::string>(path, document.GetAllocator());
}
}
-void localizeStyleURLs(mbgl::JSValue& root, mbgl::JSDocument& document) {
+void localizeStyleURLs(mbgl::JSValue& root, mbgl::JSDocument& document, const std::string& rootPath) {
if (root.HasMember("sources")) {
mbgl::JSValue& sourcesValue = root["sources"];
for (auto& sourceProperty : sourcesValue.GetObject()) {
- localizeSourceURLs(sourceProperty.value, document);
+ localizeSourceURLs(sourceProperty.value, document, rootPath);
}
}
if (root.HasMember("glyphs")) {
mbgl::JSValue& glyphsValue = root["glyphs"];
- const std::string path = prependFileScheme(localizeMapboxFontsURL(glyphsValue.GetString())
- .value_or(localizeLocalURL(glyphsValue.GetString(), true)
- .value_or(glyphsValue.GetString())));
+ const std::string path = prependFileScheme(
+ localizeMapboxFontsURL(glyphsValue.GetString(), rootPath)
+ .value_or(localizeLocalURL(glyphsValue.GetString(), rootPath, true).value_or(glyphsValue.GetString())));
glyphsValue.Set<std::string>(path, document.GetAllocator());
}
if (root.HasMember("sprite")) {
mbgl::JSValue& spriteValue = root["sprite"];
- const std::string path = prependFileScheme(localizeMapboxSpriteURL(spriteValue.GetString())
- .value_or(localizeLocalURL(spriteValue.GetString())
- .value_or(spriteValue.GetString())));
+ const std::string path = prependFileScheme(
+ localizeMapboxSpriteURL(spriteValue.GetString(), rootPath)
+ .value_or(localizeLocalURL(spriteValue.GetString(), rootPath).value_or(spriteValue.GetString())));
spriteValue.Set<std::string>(path, document.GetAllocator());
}
}
diff --git a/render-test/src/test-runner/parser.hpp b/render-test/parser.hpp
index 3c857b7e1e..c52eb2f876 100644
--- a/render-test/src/test-runner/parser.hpp
+++ b/render-test/parser.hpp
@@ -24,16 +24,16 @@ std::vector<std::string> readExpectedJSONEntries(const mbgl::filesystem::path& b
TestMetrics readExpectedMetrics(const mbgl::filesystem::path& path);
ArgumentsTuple parseArguments(int argc, char** argv);
-std::vector<std::pair<std::string, std::string>> parseIgnores();
+std::vector<std::pair<std::string, std::string>> parseIgnores(const std::string& testRootPath);
-TestMetadata parseTestMetadata(const TestPaths& paths);
+TestMetadata parseTestMetadata(const TestPaths& paths, const std::string& rootPath);
std::string createResultPage(const TestStatistics&, const std::vector<TestMetadata>&, bool shuffle, uint32_t seed);
-std::string localizeURL(const std::string& url);
+std::string localizeURL(const std::string& url, const std::string& rootPath);
std::string toJSON(const mbgl::Value& value, unsigned indent, bool singleLine);
std::string toJSON(const std::vector<mbgl::Feature>& features, unsigned indent, bool singleLine);
-void localizeSourceURLs(mbgl::JSValue& root, mbgl::JSDocument& document);
-void localizeStyleURLs(mbgl::JSValue& root, mbgl::JSDocument& document); \ No newline at end of file
+void localizeSourceURLs(mbgl::JSValue& root, mbgl::JSDocument& document, const std::string& rootPath);
+void localizeStyleURLs(mbgl::JSValue& root, mbgl::JSDocument& document, const std::string& rootPath);
diff --git a/render-test/src/test-runner/test_runner.cpp b/render-test/render_test.cpp
index b441fcfaa0..8cb0d38900 100644
--- a/render-test/src/test-runner/test_runner.cpp
+++ b/render-test/render_test.cpp
@@ -1,24 +1,24 @@
#include "allocation_index.hpp"
-#include <mbgl/util/run_loop.hpp>
+#include <mbgl/render_test.hpp>
#include <mbgl/util/io.hpp>
+#include <mbgl/util/run_loop.hpp>
-#include "test_runner.hpp"
#include "metadata.hpp"
#include "parser.hpp"
#include "runner.hpp"
#include <random>
-#define ANSI_COLOR_RED "\x1b[31m"
-#define ANSI_COLOR_GREEN "\x1b[32m"
-#define ANSI_COLOR_YELLOW "\x1b[33m"
-#define ANSI_COLOR_BLUE "\x1b[34m"
-#define ANSI_COLOR_MAGENTA "\x1b[35m"
-#define ANSI_COLOR_CYAN "\x1b[36m"
-#define ANSI_COLOR_GRAY "\x1b[37m"
+#define ANSI_COLOR_RED "\x1b[31m"
+#define ANSI_COLOR_GREEN "\x1b[32m"
+#define ANSI_COLOR_YELLOW "\x1b[33m"
+#define ANSI_COLOR_BLUE "\x1b[34m"
+#define ANSI_COLOR_MAGENTA "\x1b[35m"
+#define ANSI_COLOR_CYAN "\x1b[36m"
+#define ANSI_COLOR_GRAY "\x1b[37m"
#define ANSI_COLOR_LIGHT_GRAY "\x1b[90m"
-#define ANSI_COLOR_RESET "\x1b[0m"
+#define ANSI_COLOR_RESET "\x1b[0m"
#if !defined(SANITIZE)
void* operator new(std::size_t sz) {
@@ -37,9 +37,9 @@ void operator delete(void* ptr, size_t) noexcept {
}
#endif
-namespace mbgl{
+namespace mbgl {
-int runTests(int argc, char* argv[]) {
+int runRenderTests(int argc, char* argv[]) {
bool recycleMap;
bool shuffle;
uint32_t seed;
@@ -49,18 +49,18 @@ int runTests(int argc, char* argv[]) {
std::tie(recycleMap, shuffle, seed, testRootPath, testPaths) = parseArguments(argc, argv);
const std::string::size_type rootLength = testRootPath.length();
- const auto ignores = parseIgnores();
+ const auto ignores = parseIgnores(testRootPath);
if (shuffle) {
printf(ANSI_COLOR_YELLOW "Shuffle seed: %d" ANSI_COLOR_RESET "\n", seed);
- std::seed_seq sequence { seed };
+ std::seed_seq sequence{seed};
std::mt19937 shuffler(sequence);
std::shuffle(testPaths.begin(), testPaths.end(), shuffler);
}
mbgl::util::RunLoop runLoop;
- TestRunner runner;
+ TestRunner runner(testRootPath);
std::vector<TestMetadata> metadatas;
metadatas.reserve(testPaths.size());
@@ -68,7 +68,7 @@ int runTests(int argc, char* argv[]) {
TestStatistics stats;
for (auto& testPath : testPaths) {
- TestMetadata metadata = parseTestMetadata(testPath);
+ TestMetadata metadata = parseTestMetadata(testPath, testRootPath);
if (!recycleMap) {
runner.reset();
@@ -77,7 +77,9 @@ int runTests(int argc, char* argv[]) {
std::string& id = metadata.id;
std::string& status = metadata.status;
std::string& color = metadata.color;
-
+#ifdef __ANDROID__
+ metadata.allowed = 0.0009;
+#endif
id = testPath.defaultExpectations();
id = id.substr(rootLength + 1, id.length() - rootLength - 2);
@@ -85,7 +87,8 @@ int runTests(int argc, char* argv[]) {
std::string ignoreReason;
const std::string ignoreName = id;
- const auto it = std::find_if(ignores.cbegin(), ignores.cend(), [&ignoreName](auto pair) { return pair.first == ignoreName; });
+ const auto it = std::find_if(
+ ignores.cbegin(), ignores.cend(), [&ignoreName](auto pair) { return pair.first == ignoreName; });
if (it != ignores.end()) {
shouldIgnore = true;
ignoreReason = it->second;
@@ -112,7 +115,8 @@ int runTests(int argc, char* argv[]) {
status = "ignored failed";
color = "#9E9E9E";
stats.ignoreFailedTests++;
- printf(ANSI_COLOR_LIGHT_GRAY "* ignore %s (%s)" ANSI_COLOR_RESET "\n", id.c_str(), ignoreReason.c_str());
+ printf(
+ ANSI_COLOR_LIGHT_GRAY "* ignore %s (%s)" ANSI_COLOR_RESET "\n", id.c_str(), ignoreReason.c_str());
}
} else {
if (passed) {
@@ -135,28 +139,37 @@ int runTests(int argc, char* argv[]) {
metadatas.push_back(std::move(metadata));
}
-
+ printf("Finished processing, creating result page now");
std::string resultsHTML = createResultPage(stats, metadatas, shuffle, seed);
mbgl::util::write_file(testRootPath + "/index.html", resultsHTML);
- const uint32_t count = stats.erroredTests + stats.failedTests +
- stats.ignoreFailedTests + stats.ignorePassedTests +
- stats.passedTests;
+ const uint32_t count =
+ stats.erroredTests + stats.failedTests + stats.ignoreFailedTests + stats.ignorePassedTests + stats.passedTests;
if (stats.passedTests) {
- printf(ANSI_COLOR_GREEN "%u passed (%.1lf%%)" ANSI_COLOR_RESET "\n", stats.passedTests, 100.0 * stats.passedTests / count);
+ printf(ANSI_COLOR_GREEN "%u passed (%.1lf%%)" ANSI_COLOR_RESET "\n",
+ stats.passedTests,
+ 100.0 * stats.passedTests / count);
}
if (stats.ignorePassedTests) {
- printf(ANSI_COLOR_YELLOW "%u passed but were ignored (%.1lf%%)" ANSI_COLOR_RESET "\n", stats.ignorePassedTests, 100.0 * stats.ignorePassedTests / count);
+ printf(ANSI_COLOR_YELLOW "%u passed but were ignored (%.1lf%%)" ANSI_COLOR_RESET "\n",
+ stats.ignorePassedTests,
+ 100.0 * stats.ignorePassedTests / count);
}
if (stats.ignoreFailedTests) {
- printf(ANSI_COLOR_LIGHT_GRAY "%u ignored (%.1lf%%)" ANSI_COLOR_RESET "\n", stats.ignoreFailedTests, 100.0 * stats.ignoreFailedTests / count);
+ printf(ANSI_COLOR_LIGHT_GRAY "%u ignored (%.1lf%%)" ANSI_COLOR_RESET "\n",
+ stats.ignoreFailedTests,
+ 100.0 * stats.ignoreFailedTests / count);
}
if (stats.failedTests) {
- printf(ANSI_COLOR_RED "%u failed (%.1lf%%)" ANSI_COLOR_RESET "\n", stats.failedTests, 100.0 * stats.failedTests / count);
+ printf(ANSI_COLOR_RED "%u failed (%.1lf%%)" ANSI_COLOR_RESET "\n",
+ stats.failedTests,
+ 100.0 * stats.failedTests / count);
}
if (stats.erroredTests) {
- printf(ANSI_COLOR_RED "%u errored (%.1lf%%)" ANSI_COLOR_RESET "\n", stats.erroredTests, 100.0 * stats.erroredTests / count);
+ printf(ANSI_COLOR_RED "%u errored (%.1lf%%)" ANSI_COLOR_RESET "\n",
+ stats.erroredTests,
+ 100.0 * stats.erroredTests / count);
}
printf("Results at: %s%s\n", testRootPath.c_str(), "/index.html");
diff --git a/render-test/src/test-runner/runner.cpp b/render-test/runner.cpp
index 3594c9488b..1501ce2a59 100644
--- a/render-test/src/test-runner/runner.cpp
+++ b/render-test/runner.cpp
@@ -32,20 +32,6 @@
using namespace mbgl;
-// static
-const std::string& TestRunner::getBasePath() {
- const static std::string result = std::string(TEST_RUNNER_ROOT_PATH).append("/mapbox-gl-js/test/integration");
- return result;
-}
-
-// static
-const std::vector<std::string>& TestRunner::getPlatformExpectationsPaths() {
- // TODO: Populate from command line.
- const static std::vector<std::string> result {
- std::string(TEST_RUNNER_ROOT_PATH).append("/render-test/expected")
- };
- return result;
-}
std::string simpleDiff(const Value& result, const Value& expected) {
std::vector<std::string> resultTokens{tokenize(toJSON(result, 2, false))};
@@ -85,6 +71,8 @@ std::string simpleDiff(const Value& result, const Value& expected) {
return diff.str();
}
+TestRunner::TestRunner(const std::string& rootPath_) : rootPath(rootPath_) {}
+
bool TestRunner::checkQueryTestResults(mbgl::PremultipliedImage&& actualImage,
std::vector<mbgl::Feature>&& features,
TestMetadata& metadata) {
@@ -354,6 +342,7 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
} catch (const std::exception&) {
return false;
}
+
} else if (operationArray[0].GetString() == sleepOp) {
// sleep
mbgl::util::Timer sleepTimer;
@@ -395,7 +384,7 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
std::string imagePath = operationArray[2].GetString();
imagePath.erase(std::remove(imagePath.begin(), imagePath.end(), '"'), imagePath.end());
- const mbgl::filesystem::path filePath(std::string(TEST_RUNNER_ROOT_PATH) + "/mapbox-gl-js/test/integration/" + imagePath);
+ const mbgl::filesystem::path filePath(rootPath + "/mapbox-gl-js/test/integration/" + imagePath);
mbgl::optional<std::string> maybeImage = mbgl::util::readFile(filePath.string());
if (!maybeImage) {
@@ -415,17 +404,18 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
// setStyle
assert(operationArray.Size() >= 2u);
if (operationArray[1].IsString()) {
- std::string stylePath = localizeURL(operationArray[1].GetString());
+ std::string stylePath = localizeURL(operationArray[1].GetString(), rootPath);
auto maybeStyle = readJson(stylePath);
if (maybeStyle.is<mbgl::JSDocument>()) {
auto& style = maybeStyle.get<mbgl::JSDocument>();
- localizeStyleURLs((mbgl::JSValue&)style, style);
+ localizeStyleURLs((mbgl::JSValue&)style, style, rootPath);
map.getStyle().loadJSON(serializeJsonValue(style));
}
} else {
- localizeStyleURLs(operationArray[1], metadata.document);
+ localizeStyleURLs(operationArray[1], metadata.document, rootPath);
map.getStyle().loadJSON(serializeJsonValue(operationArray[1]));
}
+
} else if (operationArray[0].GetString() == setCenterOp) {
// setCenter
assert(operationArray.Size() >= 2u);
@@ -524,7 +514,7 @@ bool TestRunner::runOperations(const std::string& key, TestMetadata& metadata) {
assert(operationArray[1].IsString());
assert(operationArray[2].IsObject());
- localizeSourceURLs(operationArray[2], metadata.document);
+ localizeSourceURLs(operationArray[2], metadata.document, rootPath);
mbgl::style::conversion::Error error;
auto converted = mbgl::style::conversion::convert<std::unique_ptr<mbgl::style::Source>>(operationArray[2], error, operationArray[1].GetString());
@@ -834,4 +824,4 @@ bool TestRunner::run(TestMetadata& metadata) {
void TestRunner::reset() {
maps.clear();
-}
+} \ No newline at end of file
diff --git a/render-test/src/test-runner/runner.hpp b/render-test/runner.hpp
index d8e5275f61..bdf2511b35 100644
--- a/render-test/src/test-runner/runner.hpp
+++ b/render-test/runner.hpp
@@ -10,15 +10,11 @@ struct TestMetadata;
class TestRunner {
public:
TestRunner() = default;
+ explicit TestRunner(const std::string& rootPath_);
bool run(TestMetadata&);
void reset();
- /// Returns path of the render tests root directory.
- static const std::string& getBasePath();
- /// Returns path of mapbox-gl-native expectations directory.
- static const std::vector<std::string>& getPlatformExpectationsPaths();
-
private:
bool runOperations(const std::string& key, TestMetadata&);
bool checkQueryTestResults(mbgl::PremultipliedImage&& actualImage,
@@ -33,4 +29,5 @@ private:
mbgl::Map map;
};
std::unordered_map<std::string, std::unique_ptr<Impl>> maps;
+ std::string rootPath{TEST_RUNNER_ROOT_PATH};
}; \ No newline at end of file
diff --git a/render-test/src/mbgl/render_test_runner.cpp b/render-test/src/mbgl/render_test_runner.cpp
deleted file mode 100644
index 978c7866a0..0000000000
--- a/render-test/src/mbgl/render_test_runner.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#include <mbgl/render_test_runner.hpp>
-#include "test-runner/test_runner.hpp"
-
-namespace mbgl{
-
-int runRenderTests(int argc, char* argv[]) {
- runTests(argc, argv);
-}
-} // namespace mbgl
diff --git a/render-test/src/test-runner/test_runner.hpp b/render-test/src/test-runner/test_runner.hpp
deleted file mode 100644
index 33a77e2cb8..0000000000
--- a/render-test/src/test-runner/test_runner.hpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#pragma once
-
-#include <mbgl/render_test_runner.hpp>
-
-namespace mbgl {
-int runTests(int argc, char* argv[]);
-} \ No newline at end of file