Msp::GL::SL::Compiler::Mode compile_mode;
std::map<std::string, int> spec_values;
std::map<Msp::GL::SL::Stage::Type, std::string> expected_output;
- std::string expected_error;
+ std::string expected_diagnostic;
+ bool expect_success;
+
+ TestCase(): expect_success(true) { }
};
std::list<TestCase> test_cases;
const TestCase &load_test_case(const std::string &);
void verify_output(const std::string &, const std::string &);
- void verify_error(const std::string &, const std::string &);
+ void verify_diagnostic(const std::string &, const std::string &);
std::string extract_line(const std::string &, const std::string::const_iterator &);
virtual void fail(const std::string &) = 0;
};
}
pos = line.find("Expected error:");
+ if(pos==string::npos)
+ pos = line.find("Expected diagnostic:");
if(pos!=string::npos)
{
- target = &test_case.expected_error;
+ target = &test_case.expected_diagnostic;
+ test_case.expect_success = (line[pos+9]!='e');
continue;
}
}
}
-void GlslCompilerHelper::verify_error(const string &output, const string &expected)
+void GlslCompilerHelper::verify_diagnostic(const string &output, const string &expected)
{
auto i = output.begin();
auto j = expected.begin();
{
string out_line = extract_line(output, i);
string expect_line = extract_line(expected, j);
- fail(format("Incorrect error line:\n%s\nExpected:\n%s", out_line, expect_line));
+ fail(format("Incorrect diagnostic line:\n%s\nExpected:\n%s", out_line, expect_line));
}
}
++j;
if(i!=output.end())
- fail(format("Extra error line: %s", extract_line(output, i)));
+ fail(format("Extra diagnostic line: %s", extract_line(output, i)));
if(j!=expected.end())
- fail(format("Missing error line: %s", extract_line(expected, j)));
+ fail(format("Missing diagnostic line: %s", extract_line(expected, j)));
}
string GlslCompilerHelper::extract_line(const string &text, const string::const_iterator &iter)
}
catch(const GL::SL::invalid_shader_source &exc)
{
- if(!test_case->expected_error.empty())
+ if(!test_case->expect_success)
{
debug("Errors from compile:");
debug(exc.what());
- verify_error(exc.what(), test_case->expected_error);
+ verify_diagnostic(exc.what(), test_case->expected_diagnostic);
return;
}
throw;
}
- if(!test_case->expected_error.empty())
+ if(!test_case->expect_success)
fail("Error expected but none thrown");
+ verify_diagnostic(compiler.get_diagnostics(), test_case->expected_diagnostic);
+
auto stages = compiler.get_stages();
for(auto s: stages)
{
{
load_all_test_cases("glsl");
for(const auto &tc: test_cases)
- if(tc.expected_error.empty())
+ if(tc.expect_success)
add(&GlslCompilerIdempotence::run_test_case, &tc, tc.name);
}