summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-09-11 14:15:11 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-09-11 14:56:29 +0300
commit447b6364529abe6672fb33888e5525127d4e6b5c (patch)
tree97f211c5a9467cdd6a60bb4bfcd660b4286b9ff5
parentfdfb6b14df0ddfa8dcbd2e54d7864428c37e0833 (diff)
downloadqtlocation-mapboxgl-447b6364529abe6672fb33888e5525127d4e6b5c.tar.gz
expression-test
-rw-r--r--cmake/expression-test.cmake1
-rw-r--r--expression-test/expression_test_logger.cpp11
-rw-r--r--expression-test/expression_test_parser.cpp6
-rw-r--r--expression-test/expression_test_runner.cpp9
4 files changed, 13 insertions, 14 deletions
diff --git a/cmake/expression-test.cmake b/cmake/expression-test.cmake
index 6c5b71a4f6..ebfd119e28 100644
--- a/cmake/expression-test.cmake
+++ b/cmake/expression-test.cmake
@@ -19,6 +19,7 @@ target_include_directories(mbgl-expression-test
target_link_libraries(mbgl-expression-test PRIVATE
mbgl-core
+ Mapbox::Base::io
Mapbox::Base::Extras::args
Mapbox::Base::Extras::filesystem
Mapbox::Base::Extras::rapidjson
diff --git a/expression-test/expression_test_logger.cpp b/expression-test/expression_test_logger.cpp
index 9127a6d7ae..ee44896ab4 100644
--- a/expression-test/expression_test_logger.cpp
+++ b/expression-test/expression_test_logger.cpp
@@ -2,9 +2,10 @@
#include "expression_test_runner.hpp"
#include "filesystem.hpp"
-#include <mbgl/util/io.hpp>
#include <mbgl/util/string.hpp>
+#include <mapbox/io.hpp>
+
#include <sstream>
using namespace mbgl;
@@ -168,10 +169,8 @@ void printStats(const TestStats& stats) {
void writeHTMLResults(const TestStats& stats, const std::string& rootPath, bool shuffle, uint32_t seed) {
filesystem::path path = filesystem::path(rootPath) / "index.html"s;
- try {
- util::write_file(path.string(), createResultPage(stats, shuffle, seed));
- printf("Results at: %s\n", path.string().c_str());
- } catch (std::exception&) {
- printf(ANSI_COLOR_RED "* ERROR can't write result page %s" ANSI_COLOR_RESET "\n", path.string().c_str());
+ auto expected = mapbox::base::io::writeFile(path, createResultPage(stats, shuffle, seed));
+ if (!expected) {
+ printf(ANSI_COLOR_RED "* ERROR: %s" ANSI_COLOR_RESET "\n", expected.error().c_str());
}
}
diff --git a/expression-test/expression_test_parser.cpp b/expression-test/expression_test_parser.cpp
index 3c194ffee0..b9a8c0effb 100644
--- a/expression-test/expression_test_parser.cpp
+++ b/expression-test/expression_test_parser.cpp
@@ -1,6 +1,6 @@
#include "expression_test_parser.hpp"
-#include <mbgl/util/io.hpp>
+#include <mapbox/io.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/style/conversion/function.hpp>
@@ -50,9 +50,9 @@ void writeJSON(rapidjson::PrettyWriter<rapidjson::StringBuffer>& writer, const V
using ErrorMessage = std::string;
using JSONReply = variant<JSDocument, ErrorMessage>;
JSONReply readJson(const filesystem::path& jsonPath) {
- auto maybeJSON = util::readFile(jsonPath);
+ auto maybeJSON = mapbox::base::io::readFile(jsonPath);
if (!maybeJSON) {
- return { "Unable to open file "s + jsonPath.string() };
+ return { maybeJSON.error() };
}
JSDocument document;
diff --git a/expression-test/expression_test_runner.cpp b/expression-test/expression_test_runner.cpp
index 695d129049..d00a1c9c6e 100644
--- a/expression-test/expression_test_runner.cpp
+++ b/expression-test/expression_test_runner.cpp
@@ -3,7 +3,7 @@
#include "expression_test_logger.hpp"
#include "filesystem.hpp"
-#include <mbgl/util/io.hpp>
+#include <mapbox/io.hpp>
#include <rapidjson/writer.h>
#include <rapidjson/prettywriter.h>
@@ -193,10 +193,9 @@ void writeTestData(const JSDocument& document, const std::string& rootPath, cons
document.Accept(writer);
buffer.Put('\n');
filesystem::path path = filesystem::path(rootPath) / id / "test.json"s;
- try {
- util::write_file(path.string(), {buffer.GetString(), buffer.GetSize()});
- } catch (std::exception&) {
- printf(ANSI_COLOR_RED "* ERROR can't update '%s' test" ANSI_COLOR_RESET "\n", id.c_str());
+ auto expected = mapbox::base::io::writeFile(path, {buffer.GetString(), buffer.GetSize()});
+ if (!expected) {
+ printf(ANSI_COLOR_RED "* ERROR: %s" ANSI_COLOR_RESET "\n", expected.error().c_str());
}
}