mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Add diag::Formatter::Style::print_newline_at_end
Automatically prints a newline at the end of the last diagnostic in a list. Defaults to true. Disabled for many tests that assume no newline at end of string. Change-Id: Id1c2f7771f03f22d926fafc2bebebcef056ac5e8 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37260 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
4a0b9f77ef
commit
d221738e20
@@ -39,7 +39,7 @@ class Reader {
|
||||
|
||||
/// @returns the parser error string
|
||||
std::string error() const {
|
||||
diag::Formatter formatter{{false, false, false}};
|
||||
diag::Formatter formatter{{false, false, false, false}};
|
||||
return formatter.format(diags_);
|
||||
}
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ class ParserImpl {
|
||||
|
||||
/// @returns the parser error string
|
||||
std::string error() const {
|
||||
diag::Formatter formatter{{false, false, false}};
|
||||
diag::Formatter formatter{{false, false, false, false}};
|
||||
return formatter.format(diags_);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,17 +21,22 @@ namespace reader {
|
||||
namespace wgsl {
|
||||
namespace {
|
||||
|
||||
const diag::Formatter::Style formatter_style{
|
||||
/* print_file: */ true, /* print_severity: */ true,
|
||||
/* print_line: */ true, /* print_newline_at_end: */ false};
|
||||
|
||||
class ParserImplErrorTest : public ParserImplTest {};
|
||||
|
||||
#define EXPECT(SOURCE, EXPECTED) \
|
||||
do { \
|
||||
std::string source = SOURCE; \
|
||||
std::string expected = EXPECTED; \
|
||||
auto p = parser(source); \
|
||||
p->set_max_errors(5); \
|
||||
EXPECT_EQ(false, p->Parse()); \
|
||||
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
|
||||
EXPECT_EQ(expected, diag::Formatter().format(p->diagnostics())); \
|
||||
#define EXPECT(SOURCE, EXPECTED) \
|
||||
do { \
|
||||
std::string source = SOURCE; \
|
||||
std::string expected = EXPECTED; \
|
||||
auto p = parser(source); \
|
||||
p->set_max_errors(5); \
|
||||
EXPECT_EQ(false, p->Parse()); \
|
||||
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
|
||||
EXPECT_EQ(expected, \
|
||||
diag::Formatter(formatter_style).format(p->diagnostics())); \
|
||||
} while (false)
|
||||
|
||||
TEST_F(ParserImplErrorTest, AdditiveInvalidExpr) {
|
||||
|
||||
@@ -21,16 +21,21 @@ namespace reader {
|
||||
namespace wgsl {
|
||||
namespace {
|
||||
|
||||
const diag::Formatter::Style formatter_style{
|
||||
/* print_file: */ true, /* print_severity: */ true,
|
||||
/* print_line: */ true, /* print_newline_at_end: */ false};
|
||||
|
||||
class ParserImplErrorResyncTest : public ParserImplTest {};
|
||||
|
||||
#define EXPECT(SOURCE, EXPECTED) \
|
||||
do { \
|
||||
std::string source = SOURCE; \
|
||||
std::string expected = EXPECTED; \
|
||||
auto p = parser(source); \
|
||||
EXPECT_EQ(false, p->Parse()); \
|
||||
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
|
||||
EXPECT_EQ(expected, diag::Formatter().format(p->diagnostics())); \
|
||||
#define EXPECT(SOURCE, EXPECTED) \
|
||||
do { \
|
||||
std::string source = SOURCE; \
|
||||
std::string expected = EXPECTED; \
|
||||
auto p = parser(source); \
|
||||
EXPECT_EQ(false, p->Parse()); \
|
||||
EXPECT_EQ(true, p->diagnostics().contains_errors()); \
|
||||
EXPECT_EQ(expected, \
|
||||
diag::Formatter(formatter_style).format(p->diagnostics())); \
|
||||
} while (false)
|
||||
|
||||
TEST_F(ParserImplErrorResyncTest, BadFunctionDecls) {
|
||||
|
||||
Reference in New Issue
Block a user