1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

YAML: Enable the YAMLParser tests.

This commit enables the tests located in test/YAMLParser directory.
Those tests were never actually enabled, as llvm-lit didn't pick up the
files with the 'data' extension. The commit renames those test files to files
with the 'test' extension so that llvm-lit would find them.

This commit also modifies yaml-bench so that it returns an error status
if an error occurred during parsing. It also adds the '-use-color'
command line option to yaml-bench (to make sure that file check matches
the error messages in the output stream).

This commit modifies some of the renamed tests so that they wouldn't
fail. It gets rid of XFAILs and uses the 'not' command instead for
some of the tests that have to fail during parsing. This commit
also adds some 'FIXME' comments to a couple of tests that are
supposed to fail but currently pass because of various bugs
in the implementation of the yaml parser.

Reviewers: Justin Bogner

Differential Revision: http://reviews.llvm.org/D9448

llvm-svn: 236754
This commit is contained in:
Alex Lorenz 2015-05-07 18:08:46 +00:00
parent bcf1246376
commit b9bff22c5a
180 changed files with 104 additions and 92 deletions

View File

@ -76,9 +76,9 @@ std::string escape(StringRef Input);
class Stream { class Stream {
public: public:
/// \brief This keeps a reference to the string referenced by \p Input. /// \brief This keeps a reference to the string referenced by \p Input.
Stream(StringRef Input, SourceMgr &); Stream(StringRef Input, SourceMgr &, bool ShowColors = true);
Stream(MemoryBufferRef InputBuffer, SourceMgr &); Stream(MemoryBufferRef InputBuffer, SourceMgr &, bool ShowColors = true);
~Stream(); ~Stream();
document_iterator begin(); document_iterator begin();

View File

@ -260,8 +260,8 @@ namespace yaml {
/// @brief Scans YAML tokens from a MemoryBuffer. /// @brief Scans YAML tokens from a MemoryBuffer.
class Scanner { class Scanner {
public: public:
Scanner(StringRef Input, SourceMgr &SM); Scanner(StringRef Input, SourceMgr &SM, bool ShowColors = true);
Scanner(MemoryBufferRef Buffer, SourceMgr &SM_); Scanner(MemoryBufferRef Buffer, SourceMgr &SM_, bool ShowColors = true);
/// @brief Parse the next token and return it without popping it. /// @brief Parse the next token and return it without popping it.
Token &peekNext(); Token &peekNext();
@ -271,7 +271,7 @@ public:
void printError(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Message, void printError(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Message,
ArrayRef<SMRange> Ranges = None) { ArrayRef<SMRange> Ranges = None) {
SM.PrintMessage(Loc, Kind, Message, Ranges); SM.PrintMessage(Loc, Kind, Message, Ranges, /* FixIts= */ None, ShowColors);
} }
void setError(const Twine &Message, StringRef::iterator Position) { void setError(const Twine &Message, StringRef::iterator Position) {
@ -505,6 +505,9 @@ private:
/// @brief True if an error has occurred. /// @brief True if an error has occurred.
bool Failed; bool Failed;
/// @brief Should colors be used when printing out the diagnostic messages?
bool ShowColors;
/// @brief Queue of tokens. This is required to queue up tokens while looking /// @brief Queue of tokens. This is required to queue up tokens while looking
/// for the end of a simple key. And for cases where a single character /// for the end of a simple key. And for cases where a single character
/// can produce multiple tokens (e.g. BlockEnd). /// can produce multiple tokens (e.g. BlockEnd).
@ -706,11 +709,13 @@ std::string yaml::escape(StringRef Input) {
return EscapedInput; return EscapedInput;
} }
Scanner::Scanner(StringRef Input, SourceMgr &sm) : SM(sm) { Scanner::Scanner(StringRef Input, SourceMgr &sm, bool ShowColors)
: SM(sm), ShowColors(ShowColors) {
init(MemoryBufferRef(Input, "YAML")); init(MemoryBufferRef(Input, "YAML"));
} }
Scanner::Scanner(MemoryBufferRef Buffer, SourceMgr &SM_) : SM(SM_) { Scanner::Scanner(MemoryBufferRef Buffer, SourceMgr &SM_, bool ShowColors)
: SM(SM_), ShowColors(ShowColors) {
init(Buffer); init(Buffer);
} }
@ -1525,11 +1530,11 @@ bool Scanner::fetchMoreTokens() {
return false; return false;
} }
Stream::Stream(StringRef Input, SourceMgr &SM) Stream::Stream(StringRef Input, SourceMgr &SM, bool ShowColors)
: scanner(new Scanner(Input, SM)), CurrentDoc() {} : scanner(new Scanner(Input, SM, ShowColors)), CurrentDoc() {}
Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM) Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM, bool ShowColors)
: scanner(new Scanner(InputBuffer, SM)), CurrentDoc() {} : scanner(new Scanner(InputBuffer, SM, ShowColors)), CurrentDoc() {}
Stream::~Stream() {} Stream::~Stream() {}

View File

@ -1,4 +1,4 @@
# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s # RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
# Invalid use of BOM # Invalid use of BOM
# inside a # inside a

View File

@ -1,4 +1,4 @@
# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s # RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
commercial-at: @text commercial-at: @text
grave-accent: `text grave-accent: `text

View File

@ -1,7 +1,8 @@
# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s # RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
# #
# FIXME: This test should actually fail. Yaml-bench should report an error
# that a tab is being used to indent a plain scalar at line 15.
# We don't currently reject tabs as indentation. # We don't currently reject tabs as indentation.
# XFAIL: *
# Tabs do's and don'ts: # Tabs do's and don'ts:
# comment: # comment:
@ -13,4 +14,5 @@ block: |
elsewhere: # separation elsewhere: # separation
indentation, in plain scalar indentation, in plain scalar
# CHECK: error
# CHECK: !!str "Quoted\t\t"

View File

@ -1,7 +0,0 @@
# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
Bad escapes:
"\c
\xq-"
# CHECK: error

View File

@ -0,0 +1,7 @@
# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
Bad escapes:
"\c
\xq-"
# CHECK: error

View File

@ -1,7 +0,0 @@
# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
%YAML 1.1
%YAML 1.1
foo
# CHECK: error

View File

@ -0,0 +1,7 @@
# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
%YAML 1.1
%YAML 1.1
foo
# CHECK: error

View File

@ -1,10 +0,0 @@
# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
#
# We don't currently parse TAG directives.
# XFAIL: *
%TAG ! !foo
%TAG ! !foo
bar
# CHECK: error

View File

@ -0,0 +1,8 @@
# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
#
# We don't currently parse TAG directives.
# CHECK: error: Unexpected token
%TAG ! !foo
%TAG ! !foo
bar

Some files were not shown because too many files have changed in this diff Show More