Commit b937093e by shrekshao Committed by Commit Bot

HLSL tests with regex

HLSL adds a unique id suffix to user defined variable and these numbers are currently hardcoded in tests. It could easily fail if new tokens are added to angle builtin variables. Introduce C++11 regex feature into the foundInHLSLCode to avoid over strict tests. Bug: angleproject:3551 Change-Id: Ia3052afec667a7ac11198be31b5c1d03c856a723 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1670581Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Shrek Shao <shrekshao@google.com>
parent 5ff8cae9
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// utilities for compiler unit tests. // utilities for compiler unit tests.
#include "tests/test_utils/compiler_test.h" #include "tests/test_utils/compiler_test.h"
#include <regex>
#include "angle_gl.h" #include "angle_gl.h"
#include "compiler/translator/Compiler.h" #include "compiler/translator/Compiler.h"
...@@ -156,6 +157,20 @@ bool MatchOutputCodeTest::compileWithSettings(ShShaderOutput output, ...@@ -156,6 +157,20 @@ bool MatchOutputCodeTest::compileWithSettings(ShShaderOutput output,
compileOptions, translatedCode, infoLog); compileOptions, translatedCode, infoLog);
} }
bool MatchOutputCodeTest::foundInCodeRegex(ShShaderOutput output, const char *regexToFind) const
{
const auto code = mOutputCode.find(output);
EXPECT_NE(mOutputCode.end(), code);
if (code == mOutputCode.end())
{
return std::string::npos;
}
std::regex r(regexToFind);
return std::regex_search(code->second, r);
}
bool MatchOutputCodeTest::foundInCode(ShShaderOutput output, const char *stringToFind) const bool MatchOutputCodeTest::foundInCode(ShShaderOutput output, const char *stringToFind) const
{ {
const auto code = mOutputCode.find(output); const auto code = mOutputCode.find(output);
......
...@@ -64,6 +64,8 @@ class MatchOutputCodeTest : public testing::Test ...@@ -64,6 +64,8 @@ class MatchOutputCodeTest : public testing::Test
return foundInCode(SH_GLSL_COMPATIBILITY_OUTPUT, stringToFind); return foundInCode(SH_GLSL_COMPATIBILITY_OUTPUT, stringToFind);
} }
bool foundInCodeRegex(ShShaderOutput output, const char *regexToFind) const;
bool foundInCode(ShShaderOutput output, const char *stringToFind) const; bool foundInCode(ShShaderOutput output, const char *stringToFind) const;
// Test that the strings are found in the specified output in the specified order. // Test that the strings are found in the specified output in the specified order.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment