summaryrefslogtreecommitdiff
path: root/render-test/ios/ios_test_runner.cpp
blob: f2184fdf729611265335cab47a37af532e8b5539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
//  ios_test_runner.cpp
//  RenderTestAPP
//
//  Created by Miao Zhao on 12/11/19.
//

#include "ios_test_runner.hpp"

#include <mbgl/render_test.hpp>

#include <mbgl/util/logging.hpp>

#include <vector>

void TestRunner::startTest(const std::string& manifest) {

    auto runTestWithManifest = [](const std::string& manifest) -> bool {
            std::vector<std::string> arguments = {"mbgl-render-test-runner", "-p", manifest};
            std::vector<char*> argv;
            for (const auto& arg : arguments) {
                argv.push_back(const_cast<char*>(arg.data()));
            }
            argv.push_back(nullptr);

            int finishedTestCount = 0;
            std::function<void()> testStatus = [&]() {
                mbgl::Log::Info(mbgl::Event::General, "Current finished tests number is '%d' ", ++finishedTestCount);
            };
            mbgl::Log::Info(
                mbgl::Event::General, "Start running RenderTestRunner with manifest: '%s'", manifest.c_str());
        
            auto result = mbgl::runRenderTests(static_cast<int>(argv.size() - 1), argv.data(), testStatus) == 0;
            mbgl::Log::Info(mbgl::Event::General, "End running RenderTestRunner with manifest: '%s'", manifest.c_str());
            return result;
        };

    try {
        runTestWithManifest(manifest);}
    catch(...){
          mbgl::Log::Info(mbgl::Event::General, "testFailed");
    }
    mbgl::Log::Info(mbgl::Event::General, "All tests are finished!");
}