]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/glslcompiler.cpp
Check for extra error lines in compiler output
[libs/gl.git] / tests / glsl / glslcompiler.cpp
index 70ccf3b200f733504d89583396e1fb9594c3d9d8..acca61d36a217e7bec5dcc572576209a5bfb3244 100644 (file)
@@ -99,9 +99,9 @@ const GlslCompilerTest::TestCase &GlslCompilerTest::load_test_case(const string
 void GlslCompilerTest::run_test_case(const TestCase *test_case)
 {
        GL::SL::Compiler compiler(GL::SL::Features::all());
-       compiler.set_source(test_case->source, "<test>");
        try
        {
+               compiler.set_source(test_case->source, "<test>");
                compiler.compile(GL::SL::Compiler::PROGRAM);
        }
        catch(const GL::SL::invalid_shader_source &exc)
@@ -116,6 +116,9 @@ void GlslCompilerTest::run_test_case(const TestCase *test_case)
                throw;
        }
 
+       if(!test_case->expected_error.empty())
+               fail("Error expected but none thrown");
+
        auto stages = compiler.get_stages();
        for(auto s: stages)
        {
@@ -197,6 +200,11 @@ void GlslCompilerTest::verify_error(const string &output, const string &expected
                ++i;
        while(j!=expected.end() && isspace(*j))
                ++j;
+
+       if(i!=output.end())
+               fail(format("Extra error line: %s", extract_line(output, i)));
+       if(j!=expected.end())
+               fail(format("Missing error line: %s", extract_line(expected, j)));
 }
 
 string GlslCompilerTest::extract_line(const string &text, const string::const_iterator &iter)