Commit bdfd1e4b authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] More flexibel and uniform error reporting

This CL changes the existing TorqueError struct into a more general
TorqueMessage by adding a "kind" enum. The contextual for lint errors
is removed and replaced by a list of TorqueMessages.

A MessageBuilder is introduced to help with the different
combinations of present information and method of reporting. A lint
error with custom SourcePosition can be reported like this:

Lint("naming convention error").Position(<src_pos_var>);

While a fatal error, with CurrentSourcePosition can be thrown
like this:

Error("something went horrible wrong").Throw();

This approach is both backwards compatible and should prove flexible
enough to add more information to messages or add other message kinds.

Bug: v8:7793
Change-Id: Ib04fa188e34b3e8e9a6526a086f80da8f690a6f5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1617245
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61696}
parent 7b38d42a
...@@ -67,6 +67,9 @@ class ContextualVariable { ...@@ -67,6 +67,9 @@ class ContextualVariable {
private: private:
V8_EXPORT_PRIVATE static VarType*& Top(); V8_EXPORT_PRIVATE static VarType*& Top();
static bool HasScope() { return Top() != nullptr; }
friend class MessageBuilder;
}; };
// Usage: DECLARE_CONTEXTUAL_VARIABLE(VarName, VarType) // Usage: DECLARE_CONTEXTUAL_VARIABLE(VarName, VarType)
......
...@@ -184,13 +184,15 @@ JsonParserResult ParseJson(const std::string& input) { ...@@ -184,13 +184,15 @@ JsonParserResult ParseJson(const std::string& input) {
// Torque needs a CurrentSourceFile scope during parsing. // Torque needs a CurrentSourceFile scope during parsing.
// As JSON lives in memory only, a unknown file scope is created. // As JSON lives in memory only, a unknown file scope is created.
SourceFileMap::Scope source_map_scope; SourceFileMap::Scope source_map_scope;
TorqueMessages::Scope messages_scope;
CurrentSourceFile::Scope unkown_file(SourceFileMap::AddSource("<json>")); CurrentSourceFile::Scope unkown_file(SourceFileMap::AddSource("<json>"));
JsonParserResult result; JsonParserResult result;
try { try {
result.value = (*JsonGrammar().Parse(input)).Cast<JsonValue>(); result.value = (*JsonGrammar().Parse(input)).Cast<JsonValue>();
} catch (TorqueError& error) { } catch (TorqueAbortCompilation&) {
result.error = error; CHECK(!TorqueMessages::Get().empty());
result.error = TorqueMessages::Get().front();
} }
return result; return result;
} }
......
...@@ -17,7 +17,7 @@ namespace ls { ...@@ -17,7 +17,7 @@ namespace ls {
struct JsonParserResult { struct JsonParserResult {
JsonValue value; JsonValue value;
base::Optional<TorqueError> error; base::Optional<TorqueMessage> error;
}; };
V8_EXPORT_PRIVATE JsonParserResult ParseJson(const std::string& input); V8_EXPORT_PRIVATE JsonParserResult ParseJson(const std::string& input);
......
...@@ -86,32 +86,21 @@ void ResetCompilationErrorDiagnostics(MessageWriter writer) { ...@@ -86,32 +86,21 @@ void ResetCompilationErrorDiagnostics(MessageWriter writer) {
// 2) send one notification per entry (per file). // 2) send one notification per entry (per file).
class DiagnosticCollector { class DiagnosticCollector {
public: public:
void AddTorqueError(const TorqueError& error) { void AddTorqueMessage(const TorqueMessage& message) {
SourceId id = error.position ? error.position->source : SourceId::Invalid(); SourceId id =
message.position ? message.position->source : SourceId::Invalid();
auto& notification = GetOrCreateNotificationForSource(id); auto& notification = GetOrCreateNotificationForSource(id);
Diagnostic diagnostic = notification.params().add_diagnostics(); Diagnostic diagnostic = notification.params().add_diagnostics();
diagnostic.set_severity(Diagnostic::kError); diagnostic.set_severity(ServerityFor(message.kind));
diagnostic.set_message(error.message); diagnostic.set_message(message.message);
diagnostic.set_source("Torque Compiler"); diagnostic.set_source("Torque Compiler");
if (error.position) { if (message.position) {
PopulateRangeFromSourcePosition(diagnostic.range(), *error.position); PopulateRangeFromSourcePosition(diagnostic.range(), *message.position);
} }
} }
void AddLintError(const LintError& error) {
auto& notification =
GetOrCreateNotificationForSource(error.position.source);
Diagnostic diagnostic = notification.params().add_diagnostics();
diagnostic.set_severity(Diagnostic::kWarning);
diagnostic.set_message(error.message);
diagnostic.set_source("Torque Compiler");
PopulateRangeFromSourcePosition(diagnostic.range(), error.position);
}
std::map<SourceId, PublishDiagnosticsNotification>& notifications() { std::map<SourceId, PublishDiagnosticsNotification>& notifications() {
return notifications_; return notifications_;
} }
...@@ -139,16 +128,25 @@ class DiagnosticCollector { ...@@ -139,16 +128,25 @@ class DiagnosticCollector {
range.end().set_character(position.end.column); range.end().set_character(position.end.column);
} }
Diagnostic::DiagnosticSeverity ServerityFor(TorqueMessage::Kind kind) {
switch (kind) {
case TorqueMessage::Kind::kError:
return Diagnostic::kError;
case TorqueMessage::Kind::kLint:
return Diagnostic::kWarning;
}
}
std::map<SourceId, PublishDiagnosticsNotification> notifications_; std::map<SourceId, PublishDiagnosticsNotification> notifications_;
}; };
void SendCompilationDiagnostics(const TorqueCompilerResult& result, void SendCompilationDiagnostics(const TorqueCompilerResult& result,
MessageWriter writer) { MessageWriter writer) {
DiagnosticCollector collector; DiagnosticCollector collector;
if (result.error) collector.AddTorqueError(*result.error);
for (const LintError& error : result.lint_errors) { // TODO(szuend): Split up messages by SourceId and sort them by line number.
collector.AddLintError(error); for (const TorqueMessage& message : result.messages) {
collector.AddTorqueMessage(message);
} }
for (auto& pair : collector.notifications()) { for (auto& pair : collector.notifications()) {
......
...@@ -39,7 +39,7 @@ void ReadAndParseTorqueFile(const std::string& path) { ...@@ -39,7 +39,7 @@ void ReadAndParseTorqueFile(const std::string& path) {
} }
if (!maybe_content) { if (!maybe_content) {
ReportErrorWithoutPosition("Cannot open file path/uri: ", path); Error("Cannot open file path/uri: ", path).Throw();
} }
ParseTorque(*maybe_content); ParseTorque(*maybe_content);
...@@ -102,20 +102,21 @@ TorqueCompilerResult CompileTorque(const std::string& source, ...@@ -102,20 +102,21 @@ TorqueCompilerResult CompileTorque(const std::string& source,
SourceFileMap::Scope source_map_scope; SourceFileMap::Scope source_map_scope;
CurrentSourceFile::Scope no_file_scope(SourceFileMap::AddSource("<torque>")); CurrentSourceFile::Scope no_file_scope(SourceFileMap::AddSource("<torque>"));
CurrentAst::Scope ast_scope; CurrentAst::Scope ast_scope;
LintErrors::Scope lint_errors_scope; TorqueMessages::Scope messages_scope;
LanguageServerData::Scope server_data_scope; LanguageServerData::Scope server_data_scope;
TorqueCompilerResult result; TorqueCompilerResult result;
try { try {
ParseTorque(source); ParseTorque(source);
CompileCurrentAst(options); CompileCurrentAst(options);
} catch (TorqueError& error) { } catch (TorqueAbortCompilation&) {
result.error = error; // Do nothing. The relevant TorqueMessage is part of the
// TorqueMessages contextual.
} }
result.source_file_map = SourceFileMap::Get(); result.source_file_map = SourceFileMap::Get();
result.language_server_data = std::move(LanguageServerData::Get()); result.language_server_data = std::move(LanguageServerData::Get());
result.lint_errors = LintErrors::Get(); result.messages = std::move(TorqueMessages::Get());
return result; return result;
} }
...@@ -125,20 +126,21 @@ TorqueCompilerResult CompileTorque(std::vector<std::string> files, ...@@ -125,20 +126,21 @@ TorqueCompilerResult CompileTorque(std::vector<std::string> files,
SourceFileMap::Scope source_map_scope; SourceFileMap::Scope source_map_scope;
CurrentSourceFile::Scope unknown_source_file_scope(SourceId::Invalid()); CurrentSourceFile::Scope unknown_source_file_scope(SourceId::Invalid());
CurrentAst::Scope ast_scope; CurrentAst::Scope ast_scope;
LintErrors::Scope lint_errors_scope; TorqueMessages::Scope messages_scope;
LanguageServerData::Scope server_data_scope; LanguageServerData::Scope server_data_scope;
TorqueCompilerResult result; TorqueCompilerResult result;
try { try {
for (const auto& path : files) ReadAndParseTorqueFile(path); for (const auto& path : files) ReadAndParseTorqueFile(path);
CompileCurrentAst(options); CompileCurrentAst(options);
} catch (TorqueError& error) { } catch (TorqueAbortCompilation&) {
result.error = error; // Do nothing. The relevant TorqueMessage is part of the
// TorqueMessages contextual.
} }
result.source_file_map = SourceFileMap::Get(); result.source_file_map = SourceFileMap::Get();
result.language_server_data = std::move(LanguageServerData::Get()); result.language_server_data = std::move(LanguageServerData::Get());
result.lint_errors = LintErrors::Get(); result.messages = std::move(TorqueMessages::Get());
return result; return result;
} }
......
...@@ -35,13 +35,8 @@ struct TorqueCompilerResult { ...@@ -35,13 +35,8 @@ struct TorqueCompilerResult {
// Set the corresponding options flag to enable. // Set the corresponding options flag to enable.
LanguageServerData language_server_data; LanguageServerData language_server_data;
// Lint errors collected during compilation. These are // Errors collected during compilation.
// mainly naming convention violations. std::vector<TorqueMessage> messages;
std::vector<LintError> lint_errors;
// If any error occurred during either parsing or compilation,
// this field will be set.
base::Optional<TorqueError> error;
}; };
V8_EXPORT_PRIVATE TorqueCompilerResult V8_EXPORT_PRIVATE TorqueCompilerResult
......
...@@ -249,7 +249,7 @@ void CheckNotDeferredStatement(Statement* statement) { ...@@ -249,7 +249,7 @@ void CheckNotDeferredStatement(Statement* statement) {
CurrentSourcePosition::Scope source_position(statement->pos); CurrentSourcePosition::Scope source_position(statement->pos);
if (BlockStatement* block = BlockStatement::DynamicCast(statement)) { if (BlockStatement* block = BlockStatement::DynamicCast(statement)) {
if (block->deferred) { if (block->deferred) {
ReportLintError( Lint(
"cannot use deferred with a statement block here, it will have no " "cannot use deferred with a statement block here, it will have no "
"effect"); "effect");
} }
...@@ -657,14 +657,10 @@ class AnnotationSet { ...@@ -657,14 +657,10 @@ class AnnotationSet {
auto list = iter->NextAs<std::vector<Identifier*>>(); auto list = iter->NextAs<std::vector<Identifier*>>();
for (const Identifier* i : list) { for (const Identifier* i : list) {
if (allowed.find(i->value) == allowed.end()) { if (allowed.find(i->value) == allowed.end()) {
std::stringstream s; Lint("Annotation ", i->value, " is not allowed here").Position(i->pos);
s << "Annotation " << i->value << " is not allowed here";
ReportLintError(s.str(), i->pos);
} }
if (!set_.insert(i->value).second) { if (!set_.insert(i->value).second) {
std::stringstream s; Lint("Duplicate annotation ", i->value).Position(i->pos);
s << "Duplicate annotation " << i->value;
ReportLintError(s.str(), i->pos);
} }
} }
} }
......
...@@ -9,6 +9,15 @@ namespace v8 { ...@@ -9,6 +9,15 @@ namespace v8 {
namespace internal { namespace internal {
namespace torque { namespace torque {
std::string ErrorPrefixFor(TorqueMessage::Kind kind) {
switch (kind) {
case TorqueMessage::Kind::kError:
return "Torque Error";
case TorqueMessage::Kind::kLint:
return "Lint error";
}
}
int WrappedMain(int argc, const char** argv) { int WrappedMain(int argc, const char** argv) {
std::string output_directory; std::string output_directory;
std::vector<std::string> files; std::vector<std::string> files;
...@@ -35,19 +44,16 @@ int WrappedMain(int argc, const char** argv) { ...@@ -35,19 +44,16 @@ int WrappedMain(int argc, const char** argv) {
// resolve the file name. Needed to report errors and lint warnings. // resolve the file name. Needed to report errors and lint warnings.
SourceFileMap::Scope source_file_map_scope(result.source_file_map); SourceFileMap::Scope source_file_map_scope(result.source_file_map);
if (result.error) { for (const TorqueMessage& message : result.messages) {
TorqueError& error = *result.error; if (message.position) {
if (error.position) std::cerr << PositionAsString(*error.position) << ": "; std::cerr << *message.position << ": ";
std::cerr << "Torque error: " << error.message << "\n"; }
v8::base::OS::Abort();
}
for (const LintError& error : result.lint_errors) { std::cerr << ErrorPrefixFor(message.kind) << ": " << message.message
std::cerr << PositionAsString(error.position) << "\n";
<< ": Lint error: " << error.message << "\n";
} }
if (!result.lint_errors.empty()) v8::base::OS::Abort(); if (!result.messages.empty()) v8::base::OS::Abort();
return 0; return 0;
} }
......
...@@ -341,12 +341,12 @@ void ClassType::Finalize() const { ...@@ -341,12 +341,12 @@ void ClassType::Finalize() const {
if (const ClassType* super_class = ClassType::DynamicCast(parent())) { if (const ClassType* super_class = ClassType::DynamicCast(parent())) {
if (super_class->HasIndexedField()) flags_ |= ClassFlag::kHasIndexedField; if (super_class->HasIndexedField()) flags_ |= ClassFlag::kHasIndexedField;
if (!super_class->IsAbstract() && !HasSameInstanceTypeAsParent()) { if (!super_class->IsAbstract() && !HasSameInstanceTypeAsParent()) {
ReportLintError( Lint(
"Super class must either be abstract (annotate super class with " "Super class must either be abstract (annotate super class with "
"@abstract) " "@abstract) "
"or this class must have the same instance type as the super class " "or this class must have the same instance type as the super class "
"(annotate this class with @hasSameInstanceTypeAsParent).", "(annotate this class with @hasSameInstanceTypeAsParent).")
this->decl_->name->pos); .Position(this->decl_->name->pos);
} }
} }
} }
...@@ -359,11 +359,10 @@ void ClassType::Finalize() const { ...@@ -359,11 +359,10 @@ void ClassType::Finalize() const {
if (!field_type->IsSubtypeOf(TypeOracle::GetObjectType()) || if (!field_type->IsSubtypeOf(TypeOracle::GetObjectType()) ||
field_type->IsSubtypeOf(TypeOracle::GetSmiType()) || field_type->IsSubtypeOf(TypeOracle::GetSmiType()) ||
field_type->IsSubtypeOf(TypeOracle::GetNumberType())) { field_type->IsSubtypeOf(TypeOracle::GetNumberType())) {
std::stringstream s; Lint("Generation of C++ class for Torque class ", name(),
s << "Generation of C++ class for Torque class " << name() " is not supported yet, because the type of field ",
<< " is not supported yet, because the type of field " f.name_and_type.name, " cannot be handled yet")
<< f.name_and_type.name << " cannot be handled yet"; .Position(f.pos);
ReportLintError(s.str(), f.pos);
} }
} }
} }
......
...@@ -15,7 +15,7 @@ namespace v8 { ...@@ -15,7 +15,7 @@ namespace v8 {
namespace internal { namespace internal {
namespace torque { namespace torque {
DEFINE_CONTEXTUAL_VARIABLE(LintErrors) DEFINE_CONTEXTUAL_VARIABLE(TorqueMessages)
std::string StringLiteralUnquote(const std::string& s) { std::string StringLiteralUnquote(const std::string& s) {
DCHECK(('"' == s.front() && '"' == s.back()) || DCHECK(('"' == s.front() && '"' == s.back()) ||
...@@ -124,23 +124,27 @@ std::string CurrentPositionAsString() { ...@@ -124,23 +124,27 @@ std::string CurrentPositionAsString() {
return PositionAsString(CurrentSourcePosition::Get()); return PositionAsString(CurrentSourcePosition::Get());
} }
[[noreturn]] void ThrowTorqueError(const std::string& message, void NamingConventionError(const std::string& type, const std::string& name,
bool include_position) { const std::string& convention) {
TorqueError error(message); Lint(type, " \"", name, "\" does not follow \"", convention,
if (include_position) error.position = CurrentSourcePosition::Get(); "\" naming convention.");
throw error;
} }
void ReportLintError(const std::string& error, SourcePosition pos) { MessageBuilder::MessageBuilder(const std::string& message,
LintErrors::Get().push_back({error, pos}); TorqueMessage::Kind kind) {
base::Optional<SourcePosition> position;
if (CurrentSourcePosition::HasScope()) {
position = CurrentSourcePosition::Get();
}
message_ = TorqueMessage{message, position, kind};
} }
void NamingConventionError(const std::string& type, const std::string& name, void MessageBuilder::Report() const {
const std::string& convention) { TorqueMessages::Get().push_back(message_);
std::stringstream sstream; }
sstream << type << " \"" << name << "\" does not follow \"" << convention
<< "\" naming convention."; [[noreturn]] void MessageBuilder::Throw() const {
ReportLintError(sstream.str()); throw TorqueAbortCompilation{};
} }
namespace { namespace {
......
...@@ -28,16 +28,60 @@ std::string StringLiteralQuote(const std::string& s); ...@@ -28,16 +28,60 @@ std::string StringLiteralQuote(const std::string& s);
V8_EXPORT_PRIVATE base::Optional<std::string> FileUriDecode( V8_EXPORT_PRIVATE base::Optional<std::string> FileUriDecode(
const std::string& s); const std::string& s);
struct LintError { struct TorqueMessage {
enum class Kind { kError, kLint };
std::string message; std::string message;
SourcePosition position; base::Optional<SourcePosition> position;
Kind kind;
};
DECLARE_CONTEXTUAL_VARIABLE(TorqueMessages, std::vector<TorqueMessage>);
class V8_EXPORT_PRIVATE MessageBuilder {
public:
MessageBuilder(const std::string& message, TorqueMessage::Kind kind);
MessageBuilder& Position(SourcePosition position) {
message_.position = position;
return *this;
}
[[noreturn]] void Throw() const;
~MessageBuilder() {
// This will also get called in case the error is thrown.
Report();
}
private:
MessageBuilder() = delete;
void Report() const;
TorqueMessage message_;
}; };
DECLARE_CONTEXTUAL_VARIABLE(LintErrors, std::vector<LintError>);
void ReportLintError(const std::string& error, // Used for throwing exceptions. Retrieve TorqueMessage from the contextual
SourcePosition pos = CurrentSourcePosition::Get()); // for specific error information.
struct TorqueAbortCompilation {};
// Prints a LintError with the format "{type} '{name}' doesn't follow template <class... Args>
static MessageBuilder Message(TorqueMessage::Kind kind, Args&&... args) {
std::stringstream stream;
USE((stream << std::forward<Args>(args))...);
return MessageBuilder(stream.str(), kind);
}
template <class... Args>
MessageBuilder Error(Args&&... args) {
return Message(TorqueMessage::Kind::kError, std::forward<Args>(args)...);
}
template <class... Args>
MessageBuilder Lint(Args&&... args) {
return Message(TorqueMessage::Kind::kLint, std::forward<Args>(args)...);
}
// Report a LintError with the format "{type} '{name}' doesn't follow
// '{convention}' naming convention". // '{convention}' naming convention".
void NamingConventionError(const std::string& type, const std::string& name, void NamingConventionError(const std::string& type, const std::string& name,
const std::string& convention); const std::string& convention);
...@@ -48,26 +92,9 @@ bool IsSnakeCase(const std::string& s); ...@@ -48,26 +92,9 @@ bool IsSnakeCase(const std::string& s);
bool IsValidNamespaceConstName(const std::string& s); bool IsValidNamespaceConstName(const std::string& s);
bool IsValidTypeName(const std::string& s); bool IsValidTypeName(const std::string& s);
struct TorqueError {
explicit TorqueError(const std::string& message) : message(message) {}
std::string message;
base::Optional<SourcePosition> position;
};
[[noreturn]] void ThrowTorqueError(const std::string& error,
bool include_position);
template <class... Args> template <class... Args>
[[noreturn]] void ReportError(Args&&... args) { [[noreturn]] void ReportError(Args&&... args) {
std::stringstream s; Error(std::forward<Args>(args)...).Throw();
USE((s << std::forward<Args>(args))...);
ThrowTorqueError(s.str(), true);
}
template <class... Args>
[[noreturn]] void ReportErrorWithoutPosition(Args&&... args) {
std::stringstream s;
USE((s << std::forward<Args>(args))...);
ThrowTorqueError(s.str(), false);
} }
std::string CapifyStringWithUnderscores(const std::string& camellified_string); std::string CapifyStringWithUnderscores(const std::string& camellified_string);
......
...@@ -115,10 +115,12 @@ TEST(LanguageServerMessage, GotoDefinition) { ...@@ -115,10 +115,12 @@ TEST(LanguageServerMessage, GotoDefinition) {
TEST(LanguageServerMessage, CompilationErrorSendsDiagnostics) { TEST(LanguageServerMessage, CompilationErrorSendsDiagnostics) {
DiagnosticsFiles::Scope diagnostic_files_scope; DiagnosticsFiles::Scope diagnostic_files_scope;
LanguageServerData::Scope server_data_scope; LanguageServerData::Scope server_data_scope;
TorqueMessages::Scope messages_scope;
SourceFileMap::Scope source_file_map_scope; SourceFileMap::Scope source_file_map_scope;
TorqueCompilerResult result; TorqueCompilerResult result;
result.error = TorqueError("compilation failed somehow"); { Error("compilation failed somehow"); }
result.messages = std::move(TorqueMessages::Get());
result.source_file_map = SourceFileMap::Get(); result.source_file_map = SourceFileMap::Get();
CompilationFinished(std::move(result), [](JsonValue& raw_response) { CompilationFinished(std::move(result), [](JsonValue& raw_response) {
...@@ -137,17 +139,21 @@ TEST(LanguageServerMessage, CompilationErrorSendsDiagnostics) { ...@@ -137,17 +139,21 @@ TEST(LanguageServerMessage, CompilationErrorSendsDiagnostics) {
TEST(LanguageServerMessage, LintErrorSendsDiagnostics) { TEST(LanguageServerMessage, LintErrorSendsDiagnostics) {
DiagnosticsFiles::Scope diagnostic_files_scope; DiagnosticsFiles::Scope diagnostic_files_scope;
LintErrors::Scope lint_errors_scope; TorqueMessages::Scope messages_scope;
LanguageServerData::Scope server_data_scope; LanguageServerData::Scope server_data_scope;
SourceFileMap::Scope sourc_file_map_scope; SourceFileMap::Scope sourc_file_map_scope;
SourceId test_id = SourceFileMap::AddSource("test.tq"); SourceId test_id = SourceFileMap::AddSource("test.tq");
// No compilation errors but two lint warnings. // No compilation errors but two lint warnings.
{
SourcePosition pos1{test_id, {0, 0}, {0, 1}};
SourcePosition pos2{test_id, {1, 0}, {1, 1}};
Lint("lint error 1").Position(pos1);
Lint("lint error 2").Position(pos2);
}
TorqueCompilerResult result; TorqueCompilerResult result;
SourcePosition pos1{test_id, {0, 0}, {0, 1}}; result.messages = std::move(TorqueMessages::Get());
SourcePosition pos2{test_id, {1, 0}, {1, 1}};
result.lint_errors.push_back({"lint error 1", pos1});
result.lint_errors.push_back({"lint error 2", pos2});
result.source_file_map = SourceFileMap::Get(); result.source_file_map = SourceFileMap::Get();
CompilationFinished(std::move(result), [](JsonValue& raw_response) { CompilationFinished(std::move(result), [](JsonValue& raw_response) {
......
...@@ -42,8 +42,8 @@ TEST(Torque, TypeNamingConventionLintError) { ...@@ -42,8 +42,8 @@ TEST(Torque, TypeNamingConventionLintError) {
const TorqueCompilerResult result = TestCompileTorque(source); const TorqueCompilerResult result = TestCompileTorque(source);
ASSERT_EQ(result.lint_errors.size(), static_cast<size_t>(1)); ASSERT_EQ(result.messages.size(), static_cast<size_t>(1));
EXPECT_THAT(result.lint_errors[0].message, HasSubstr("\"foo\"")); EXPECT_THAT(result.messages[0].message, HasSubstr("\"foo\""));
} }
TEST(Torque, StructNamingConventionLintError) { TEST(Torque, StructNamingConventionLintError) {
...@@ -56,8 +56,8 @@ TEST(Torque, StructNamingConventionLintError) { ...@@ -56,8 +56,8 @@ TEST(Torque, StructNamingConventionLintError) {
const TorqueCompilerResult result = TestCompileTorque(source); const TorqueCompilerResult result = TestCompileTorque(source);
ASSERT_EQ(result.lint_errors.size(), static_cast<size_t>(1)); ASSERT_EQ(result.messages.size(), static_cast<size_t>(1));
EXPECT_THAT(result.lint_errors[0].message, HasSubstr("\"foo\"")); EXPECT_THAT(result.messages[0].message, HasSubstr("\"foo\""));
} }
} // namespace torque } // namespace torque
......
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