Added bad shader warning instead of hard fail
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "ShaderPackageRegistry.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -187,9 +188,39 @@ void TestDuplicateScan()
|
||||
ShaderPackageRegistry registry(4);
|
||||
std::map<std::string, ShaderPackage> packages;
|
||||
std::vector<std::string> order;
|
||||
std::vector<ShaderPackageStatus> statuses;
|
||||
std::string error;
|
||||
Expect(!registry.Scan(root, packages, order, error), "duplicate package ids are rejected");
|
||||
Expect(error.find("Duplicate shader id") != std::string::npos, "duplicate scan error is clear");
|
||||
Expect(registry.Scan(root, packages, order, statuses, error), "duplicate package ids do not fail the whole scan");
|
||||
Expect(packages.size() == 1, "first duplicate package remains available");
|
||||
Expect(statuses.size() == 2, "duplicate package is surfaced in shader status list");
|
||||
Expect(std::any_of(statuses.begin(), statuses.end(), [](const ShaderPackageStatus& status) {
|
||||
return !status.available && status.error.find("Duplicate shader id") != std::string::npos;
|
||||
}), "duplicate scan error is shown on unavailable package");
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
|
||||
void TestInvalidPackageDoesNotFailScan()
|
||||
{
|
||||
const std::filesystem::path root = MakeTestRoot();
|
||||
WriteShaderPackage(root, "good", R"({ "id": "good", "name": "Good", "parameters": [] })");
|
||||
WriteShaderPackage(root, "bad", R"({
|
||||
"id": "bad",
|
||||
"name": "Bad",
|
||||
"parameters": [{ "id": "enabled", "label": "Enabled", "type": "boolean" }]
|
||||
})");
|
||||
|
||||
ShaderPackageRegistry registry(4);
|
||||
std::map<std::string, ShaderPackage> packages;
|
||||
std::vector<std::string> order;
|
||||
std::vector<ShaderPackageStatus> statuses;
|
||||
std::string error;
|
||||
Expect(registry.Scan(root, packages, order, statuses, error), "invalid package does not fail the whole scan");
|
||||
Expect(packages.find("good") != packages.end(), "valid package remains available");
|
||||
Expect(packages.find("bad") == packages.end(), "invalid package is not available for rendering");
|
||||
Expect(std::any_of(statuses.begin(), statuses.end(), [](const ShaderPackageStatus& status) {
|
||||
return status.id.find("bad") != std::string::npos && !status.available && status.error.find("Unsupported parameter type") != std::string::npos;
|
||||
}), "invalid package is surfaced with its parse error");
|
||||
|
||||
std::filesystem::remove_all(root);
|
||||
}
|
||||
@@ -203,6 +234,7 @@ int main()
|
||||
TestInvalidTemporalSettings();
|
||||
TestDisabledTemporalSettingsAreIgnored();
|
||||
TestDuplicateScan();
|
||||
TestInvalidPackageDoesNotFailScan();
|
||||
|
||||
if (gFailures != 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user