Configure expression tests on CI (#1109)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f8c2c6c8b3
commit
3b50c2e857
24
.github/workflows/linux-ci.yml
vendored
24
.github/workflows/linux-ci.yml
vendored
@@ -49,7 +49,7 @@ jobs:
|
||||
run: |
|
||||
cmake --version
|
||||
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Debug -DMLN_WITH_CLANG_TIDY=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DMLN_WITH_COVERAGE=ON
|
||||
cmake --build build --target mbgl-core mbgl-test-runner mbgl-render-test-runner
|
||||
cmake --build build --target mbgl-core mbgl-test-runner mbgl-render-test-runner mbgl-expression-test
|
||||
|
||||
- name: Archive mbgl-test-runner
|
||||
uses: actions/upload-artifact@v3
|
||||
@@ -64,6 +64,13 @@ jobs:
|
||||
name: mbgl-render-test-runner
|
||||
path: build/mbgl-render-test-runner
|
||||
retention-days: 1
|
||||
|
||||
- name: Archive mbgl-expression-test
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: mbgl-expression-test
|
||||
path: build/expression-test/mbgl-expression-test
|
||||
retention-days: 1
|
||||
|
||||
test:
|
||||
needs: build
|
||||
@@ -92,6 +99,21 @@ jobs:
|
||||
- name: Run C++ tests
|
||||
run: xvfb-run -a ./mbgl-test-runner
|
||||
|
||||
expression-test:
|
||||
needs: build
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Download mbgl-expression-test
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: mbgl-expression-test
|
||||
|
||||
- run: chmod +x ./mbgl-expression-test
|
||||
|
||||
- name: Run expression test
|
||||
run: ./mbgl-expression-test
|
||||
|
||||
render-test:
|
||||
needs: build
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
@@ -402,37 +402,42 @@ Ignores parseExpressionIgnores() {
|
||||
}
|
||||
|
||||
std::optional<TestData> parseTestData(const filesystem::path& path) {
|
||||
TestData data;
|
||||
auto maybeJson = readJson(path.string());
|
||||
if (!maybeJson.is<JSDocument>()) { // NOLINT
|
||||
mbgl::Log::Error(mbgl::Event::General, "Cannot parse test '" + path.string() + "'.");
|
||||
try {
|
||||
TestData data;
|
||||
auto maybeJson = readJson(path.string());
|
||||
if (!maybeJson.is<JSDocument>()) { // NOLINT
|
||||
mbgl::Log::Error(mbgl::Event::General, "Cannot parse test '" + path.string() + "'.");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
data.document = std::move(maybeJson.get<JSDocument>());
|
||||
|
||||
// Check that mandatory test data members are present.
|
||||
if (!data.document.HasMember("expression") || !data.document.HasMember("expected")) {
|
||||
Log::Error(Event::General, "Test fixture '" + path.string() + "' does not contain required data.");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Parse propertySpec
|
||||
if (data.document.HasMember("propertySpec")) {
|
||||
assert(data.document["propertySpec"].IsObject());
|
||||
parsePropertySpec(data.document["propertySpec"], data);
|
||||
}
|
||||
|
||||
// Parse expected
|
||||
parseExpected(data.document["expected"], data);
|
||||
|
||||
// Parse inputs
|
||||
if (data.document.HasMember("inputs") && !parseInputs(data.document["inputs"], data)) {
|
||||
Log::Error(Event::General, std::string("Can't convert inputs value for '") + path.string() + "'");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return {std::move(data)};
|
||||
} catch (const std::exception& ex) {
|
||||
Log::Error(Event::General, std::string("Cannot load test data from '" + path.string() + "': " + ex.what()));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
data.document = std::move(maybeJson.get<JSDocument>());
|
||||
|
||||
// Check that mandatory test data members are present.
|
||||
if (!data.document.HasMember("expression") || !data.document.HasMember("expected")) {
|
||||
Log::Error(Event::General, "Test fixture '" + path.string() + "' does not contain required data.");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Parse propertySpec
|
||||
if (data.document.HasMember("propertySpec")) {
|
||||
assert(data.document["propertySpec"].IsObject());
|
||||
parsePropertySpec(data.document["propertySpec"], data);
|
||||
}
|
||||
|
||||
// Parse expected
|
||||
parseExpected(data.document["expected"], data);
|
||||
|
||||
// Parse inputs
|
||||
if (data.document.HasMember("inputs") && !parseInputs(data.document["inputs"], data)) {
|
||||
Log::Error(Event::General, std::string("Can't convert inputs value for '") + path.string() + "'");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return {std::move(data)};
|
||||
}
|
||||
|
||||
std::string toJSON(const Value& value, unsigned indent, bool singleLine) {
|
||||
|
||||
@@ -47,7 +47,11 @@ int main(int argc, char** argv) try {
|
||||
}
|
||||
|
||||
if (!testRun) {
|
||||
stats.errored.emplace_back(id);
|
||||
if (shouldIgnore) {
|
||||
stats.ignoreFailed.emplace_back(TestRunOutput{id});
|
||||
} else {
|
||||
stats.errored.emplace_back(id);
|
||||
}
|
||||
printf(ANSI_COLOR_RED "* ERROR can't parse '%s' test" ANSI_COLOR_RESET "\n", id.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"expression-tests/legacy/interval/composite-default": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
|
||||
"expression-tests/legacy/interval/tokens-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/12747",
|
||||
"expression-tests/resolved-locale/basic": "Even the 'en' locale may not be present on some test systems.",
|
||||
"expression-tests/within/non-supported": "Something is wrong with GeoJSON geometry in test",
|
||||
"probes/file-size/fail-file-doesnt-match": "Should fail, doesn't match the expectation.",
|
||||
"probes/file-size/fail-file-not-found": "Should fail, file not found.",
|
||||
"probes/file-size/fail-size-is-over": "Should fail, size is bigger than expected.",
|
||||
|
||||
Reference in New Issue
Block a user