]> granicus.if.org Git - llvm/commitdiff
YAML: Enable the YAMLParser tests.
authorAlex Lorenz <arphaman@gmail.com>
Thu, 7 May 2015 18:08:46 +0000 (18:08 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 7 May 2015 18:08:46 +0000 (18:08 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236754 91177308-0d34-0410-b5e6-96231b3b80d8

180 files changed:
include/llvm/Support/YAMLParser.h
lib/Support/YAMLParser.cpp
test/YAMLParser/bool.test [moved from test/YAMLParser/bool.data with 100% similarity]
test/YAMLParser/construct-bool.test [moved from test/YAMLParser/construct-bool.data with 100% similarity]
test/YAMLParser/construct-custom.test [moved from test/YAMLParser/construct-custom.data with 100% similarity]
test/YAMLParser/construct-float.test [moved from test/YAMLParser/construct-float.data with 100% similarity]
test/YAMLParser/construct-int.test [moved from test/YAMLParser/construct-int.data with 100% similarity]
test/YAMLParser/construct-map.test [moved from test/YAMLParser/construct-map.data with 100% similarity]
test/YAMLParser/construct-merge.test [moved from test/YAMLParser/construct-merge.data with 100% similarity]
test/YAMLParser/construct-null.test [moved from test/YAMLParser/construct-null.data with 100% similarity]
test/YAMLParser/construct-omap.test [moved from test/YAMLParser/construct-omap.data with 100% similarity]
test/YAMLParser/construct-pairs.test [moved from test/YAMLParser/construct-pairs.data with 100% similarity]
test/YAMLParser/construct-seq.test [moved from test/YAMLParser/construct-seq.data with 100% similarity]
test/YAMLParser/construct-set.test [moved from test/YAMLParser/construct-set.data with 100% similarity]
test/YAMLParser/construct-str-ascii.test [moved from test/YAMLParser/construct-str-ascii.data with 100% similarity]
test/YAMLParser/construct-str.test [moved from test/YAMLParser/construct-str.data with 100% similarity]
test/YAMLParser/construct-timestamp.test [moved from test/YAMLParser/construct-timestamp.data with 100% similarity]
test/YAMLParser/construct-value.test [moved from test/YAMLParser/construct-value.data with 100% similarity]
test/YAMLParser/duplicate-key.former-loader-error.test [moved from test/YAMLParser/duplicate-key.former-loader-error.data with 100% similarity]
test/YAMLParser/duplicate-mapping-key.former-loader-error.test [moved from test/YAMLParser/duplicate-mapping-key.former-loader-error.data with 100% similarity]
test/YAMLParser/duplicate-merge-key.former-loader-error.test [moved from test/YAMLParser/duplicate-merge-key.former-loader-error.data with 100% similarity]
test/YAMLParser/duplicate-value-key.former-loader-error.test [moved from test/YAMLParser/duplicate-value-key.former-loader-error.data with 100% similarity]
test/YAMLParser/emit-block-scalar-in-simple-key-context-bug.test [moved from test/YAMLParser/emit-block-scalar-in-simple-key-context-bug.data with 100% similarity]
test/YAMLParser/empty-document-bug.test [moved from test/YAMLParser/empty-document-bug.data with 100% similarity]
test/YAMLParser/float.test [moved from test/YAMLParser/float.data with 100% similarity]
test/YAMLParser/int.test [moved from test/YAMLParser/int.data with 100% similarity]
test/YAMLParser/invalid-single-quote-bug.test [moved from test/YAMLParser/invalid-single-quote-bug.data with 100% similarity]
test/YAMLParser/merge.test [moved from test/YAMLParser/merge.data with 100% similarity]
test/YAMLParser/more-floats.test [moved from test/YAMLParser/more-floats.data with 100% similarity]
test/YAMLParser/negative-float-bug.test [moved from test/YAMLParser/negative-float-bug.data with 100% similarity]
test/YAMLParser/null.test [moved from test/YAMLParser/null.data with 100% similarity]
test/YAMLParser/resolver.test [moved from test/YAMLParser/resolver.data with 100% similarity]
test/YAMLParser/run-parser-crash-bug.test [moved from test/YAMLParser/run-parser-crash-bug.data with 100% similarity]
test/YAMLParser/scan-document-end-bug.test [moved from test/YAMLParser/scan-document-end-bug.data with 100% similarity]
test/YAMLParser/scan-line-break-bug.test [moved from test/YAMLParser/scan-line-break-bug.data with 100% similarity]
test/YAMLParser/single-dot-is-not-float-bug.test [moved from test/YAMLParser/single-dot-is-not-float-bug.data with 100% similarity]
test/YAMLParser/sloppy-indentation.test [moved from test/YAMLParser/sloppy-indentation.data with 100% similarity]
test/YAMLParser/spec-02-01.test [moved from test/YAMLParser/spec-02-01.data with 100% similarity]
test/YAMLParser/spec-02-02.test [moved from test/YAMLParser/spec-02-02.data with 100% similarity]
test/YAMLParser/spec-02-03.test [moved from test/YAMLParser/spec-02-03.data with 100% similarity]
test/YAMLParser/spec-02-04.test [moved from test/YAMLParser/spec-02-04.data with 100% similarity]
test/YAMLParser/spec-02-05.test [moved from test/YAMLParser/spec-02-05.data with 100% similarity]
test/YAMLParser/spec-02-06.test [moved from test/YAMLParser/spec-02-06.data with 100% similarity]
test/YAMLParser/spec-02-07.test [moved from test/YAMLParser/spec-02-07.data with 100% similarity]
test/YAMLParser/spec-02-08.test [moved from test/YAMLParser/spec-02-08.data with 100% similarity]
test/YAMLParser/spec-02-09.test [moved from test/YAMLParser/spec-02-09.data with 100% similarity]
test/YAMLParser/spec-02-10.test [moved from test/YAMLParser/spec-02-10.data with 100% similarity]
test/YAMLParser/spec-02-11.test [moved from test/YAMLParser/spec-02-11.data with 100% similarity]
test/YAMLParser/spec-02-12.test [moved from test/YAMLParser/spec-02-12.data with 100% similarity]
test/YAMLParser/spec-02-13.test [moved from test/YAMLParser/spec-02-13.data with 100% similarity]
test/YAMLParser/spec-02-14.test [moved from test/YAMLParser/spec-02-14.data with 100% similarity]
test/YAMLParser/spec-02-15.test [moved from test/YAMLParser/spec-02-15.data with 100% similarity]
test/YAMLParser/spec-02-16.test [moved from test/YAMLParser/spec-02-16.data with 100% similarity]
test/YAMLParser/spec-02-17.test [moved from test/YAMLParser/spec-02-17.data with 100% similarity]
test/YAMLParser/spec-02-18.test [moved from test/YAMLParser/spec-02-18.data with 100% similarity]
test/YAMLParser/spec-02-19.test [moved from test/YAMLParser/spec-02-19.data with 100% similarity]
test/YAMLParser/spec-02-20.test [moved from test/YAMLParser/spec-02-20.data with 100% similarity]
test/YAMLParser/spec-02-21.test [moved from test/YAMLParser/spec-02-21.data with 100% similarity]
test/YAMLParser/spec-02-22.test [moved from test/YAMLParser/spec-02-22.data with 100% similarity]
test/YAMLParser/spec-02-23.test [moved from test/YAMLParser/spec-02-23.data with 100% similarity]
test/YAMLParser/spec-02-24.test [moved from test/YAMLParser/spec-02-24.data with 100% similarity]
test/YAMLParser/spec-02-25.test [moved from test/YAMLParser/spec-02-25.data with 100% similarity]
test/YAMLParser/spec-02-26.test [moved from test/YAMLParser/spec-02-26.data with 100% similarity]
test/YAMLParser/spec-02-27.test [moved from test/YAMLParser/spec-02-27.data with 100% similarity]
test/YAMLParser/spec-02-28.test [moved from test/YAMLParser/spec-02-28.data with 100% similarity]
test/YAMLParser/spec-05-01-utf8.test [moved from test/YAMLParser/spec-05-01-utf8.data with 100% similarity]
test/YAMLParser/spec-05-02-utf8.test [moved from test/YAMLParser/spec-05-02-utf8.data with 53% similarity]
test/YAMLParser/spec-05-03.test [moved from test/YAMLParser/spec-05-03.data with 100% similarity]
test/YAMLParser/spec-05-04.test [moved from test/YAMLParser/spec-05-04.data with 100% similarity]
test/YAMLParser/spec-05-05.test [moved from test/YAMLParser/spec-05-05.data with 100% similarity]
test/YAMLParser/spec-05-06.test [moved from test/YAMLParser/spec-05-06.data with 100% similarity]
test/YAMLParser/spec-05-07.test [moved from test/YAMLParser/spec-05-07.data with 100% similarity]
test/YAMLParser/spec-05-08.test [moved from test/YAMLParser/spec-05-08.data with 100% similarity]
test/YAMLParser/spec-05-09.test [moved from test/YAMLParser/spec-05-09.data with 100% similarity]
test/YAMLParser/spec-05-10.test [moved from test/YAMLParser/spec-05-10.data with 50% similarity]
test/YAMLParser/spec-05-11.test [moved from test/YAMLParser/spec-05-11.data with 100% similarity]
test/YAMLParser/spec-05-12.test [moved from test/YAMLParser/spec-05-12.data with 61% similarity]
test/YAMLParser/spec-05-13.test [moved from test/YAMLParser/spec-05-13.data with 100% similarity]
test/YAMLParser/spec-05-14.test [moved from test/YAMLParser/spec-05-14.data with 100% similarity]
test/YAMLParser/spec-05-15.data [deleted file]
test/YAMLParser/spec-05-15.test [new file with mode: 0644]
test/YAMLParser/spec-06-01.test [moved from test/YAMLParser/spec-06-01.data with 100% similarity]
test/YAMLParser/spec-06-02.test [moved from test/YAMLParser/spec-06-02.data with 100% similarity]
test/YAMLParser/spec-06-03.test [moved from test/YAMLParser/spec-06-03.data with 100% similarity]
test/YAMLParser/spec-06-04.test [moved from test/YAMLParser/spec-06-04.data with 100% similarity]
test/YAMLParser/spec-06-05.test [moved from test/YAMLParser/spec-06-05.data with 100% similarity]
test/YAMLParser/spec-06-06.test [moved from test/YAMLParser/spec-06-06.data with 100% similarity]
test/YAMLParser/spec-06-07.test [moved from test/YAMLParser/spec-06-07.data with 100% similarity]
test/YAMLParser/spec-06-08.test [moved from test/YAMLParser/spec-06-08.data with 100% similarity]
test/YAMLParser/spec-07-01.test [moved from test/YAMLParser/spec-07-01.data with 100% similarity]
test/YAMLParser/spec-07-02.test [moved from test/YAMLParser/spec-07-02.data with 100% similarity]
test/YAMLParser/spec-07-03.data [deleted file]
test/YAMLParser/spec-07-03.test [new file with mode: 0644]
test/YAMLParser/spec-07-04.test [moved from test/YAMLParser/spec-07-04.data with 100% similarity]
test/YAMLParser/spec-07-05.data [deleted file]
test/YAMLParser/spec-07-05.test [new file with mode: 0644]
test/YAMLParser/spec-07-06.test [moved from test/YAMLParser/spec-07-06.data with 100% similarity]
test/YAMLParser/spec-07-07a.test [moved from test/YAMLParser/spec-07-07a.data with 100% similarity]
test/YAMLParser/spec-07-07b.test [moved from test/YAMLParser/spec-07-07b.data with 100% similarity]
test/YAMLParser/spec-07-08.test [moved from test/YAMLParser/spec-07-08.data with 100% similarity]
test/YAMLParser/spec-07-09.test [moved from test/YAMLParser/spec-07-09.data with 100% similarity]
test/YAMLParser/spec-07-10.test [moved from test/YAMLParser/spec-07-10.data with 100% similarity]
test/YAMLParser/spec-07-11.test [moved from test/YAMLParser/spec-07-11.data with 100% similarity]
test/YAMLParser/spec-07-12a.test [moved from test/YAMLParser/spec-07-12a.data with 100% similarity]
test/YAMLParser/spec-07-12b.test [moved from test/YAMLParser/spec-07-12b.data with 100% similarity]
test/YAMLParser/spec-07-13.test [moved from test/YAMLParser/spec-07-13.data with 100% similarity]
test/YAMLParser/spec-08-01.test [moved from test/YAMLParser/spec-08-01.data with 100% similarity]
test/YAMLParser/spec-08-02.test [moved from test/YAMLParser/spec-08-02.data with 100% similarity]
test/YAMLParser/spec-08-03.test [moved from test/YAMLParser/spec-08-03.data with 100% similarity]
test/YAMLParser/spec-08-04.data [deleted file]
test/YAMLParser/spec-08-04.test [new file with mode: 0644]
test/YAMLParser/spec-08-05.test [moved from test/YAMLParser/spec-08-05.data with 100% similarity]
test/YAMLParser/spec-08-06.test [moved from test/YAMLParser/spec-08-06.data with 55% similarity]
test/YAMLParser/spec-08-07.test [moved from test/YAMLParser/spec-08-07.data with 100% similarity]
test/YAMLParser/spec-08-08.test [moved from test/YAMLParser/spec-08-08.data with 100% similarity]
test/YAMLParser/spec-08-09.test [moved from test/YAMLParser/spec-08-09.data with 100% similarity]
test/YAMLParser/spec-08-10.test [moved from test/YAMLParser/spec-08-10.data with 100% similarity]
test/YAMLParser/spec-08-11.test [moved from test/YAMLParser/spec-08-11.data with 100% similarity]
test/YAMLParser/spec-08-12.test [moved from test/YAMLParser/spec-08-12.data with 100% similarity]
test/YAMLParser/spec-08-13.test [moved from test/YAMLParser/spec-08-13.data with 100% similarity]
test/YAMLParser/spec-08-14.test [moved from test/YAMLParser/spec-08-14.data with 100% similarity]
test/YAMLParser/spec-08-15.test [moved from test/YAMLParser/spec-08-15.data with 100% similarity]
test/YAMLParser/spec-09-01.test [moved from test/YAMLParser/spec-09-01.data with 100% similarity]
test/YAMLParser/spec-09-02.data [deleted file]
test/YAMLParser/spec-09-02.test [new file with mode: 0644]
test/YAMLParser/spec-09-03.test [moved from test/YAMLParser/spec-09-03.data with 100% similarity]
test/YAMLParser/spec-09-04.test [moved from test/YAMLParser/spec-09-04.data with 100% similarity]
test/YAMLParser/spec-09-05.test [moved from test/YAMLParser/spec-09-05.data with 100% similarity]
test/YAMLParser/spec-09-06.test [moved from test/YAMLParser/spec-09-06.data with 100% similarity]
test/YAMLParser/spec-09-07.test [moved from test/YAMLParser/spec-09-07.data with 100% similarity]
test/YAMLParser/spec-09-08.test [moved from test/YAMLParser/spec-09-08.data with 100% similarity]
test/YAMLParser/spec-09-09.test [moved from test/YAMLParser/spec-09-09.data with 100% similarity]
test/YAMLParser/spec-09-10.test [moved from test/YAMLParser/spec-09-10.data with 100% similarity]
test/YAMLParser/spec-09-11.test [moved from test/YAMLParser/spec-09-11.data with 100% similarity]
test/YAMLParser/spec-09-12.test [moved from test/YAMLParser/spec-09-12.data with 100% similarity]
test/YAMLParser/spec-09-13.test [moved from test/YAMLParser/spec-09-13.data with 100% similarity]
test/YAMLParser/spec-09-14.data [deleted file]
test/YAMLParser/spec-09-14.test [new file with mode: 0644]
test/YAMLParser/spec-09-15.test [moved from test/YAMLParser/spec-09-15.data with 100% similarity]
test/YAMLParser/spec-09-16.test [moved from test/YAMLParser/spec-09-16.data with 100% similarity]
test/YAMLParser/spec-09-17.test [moved from test/YAMLParser/spec-09-17.data with 100% similarity]
test/YAMLParser/spec-09-18.test [moved from test/YAMLParser/spec-09-18.data with 100% similarity]
test/YAMLParser/spec-09-19.test [moved from test/YAMLParser/spec-09-19.data with 100% similarity]
test/YAMLParser/spec-09-20.test [moved from test/YAMLParser/spec-09-20.data with 100% similarity]
test/YAMLParser/spec-09-21.test [moved from test/YAMLParser/spec-09-21.data with 50% similarity]
test/YAMLParser/spec-09-22.test [moved from test/YAMLParser/spec-09-22.data with 100% similarity]
test/YAMLParser/spec-09-23.test [moved from test/YAMLParser/spec-09-23.data with 100% similarity]
test/YAMLParser/spec-09-24.test [moved from test/YAMLParser/spec-09-24.data with 100% similarity]
test/YAMLParser/spec-09-25.test [moved from test/YAMLParser/spec-09-25.data with 100% similarity]
test/YAMLParser/spec-09-26.test [moved from test/YAMLParser/spec-09-26.data with 100% similarity]
test/YAMLParser/spec-09-27.test [moved from test/YAMLParser/spec-09-27.data with 100% similarity]
test/YAMLParser/spec-09-28.test [moved from test/YAMLParser/spec-09-28.data with 100% similarity]
test/YAMLParser/spec-09-29.test [moved from test/YAMLParser/spec-09-29.data with 100% similarity]
test/YAMLParser/spec-09-30.test [moved from test/YAMLParser/spec-09-30.data with 100% similarity]
test/YAMLParser/spec-09-31.test [moved from test/YAMLParser/spec-09-31.data with 100% similarity]
test/YAMLParser/spec-09-32.test [moved from test/YAMLParser/spec-09-32.data with 100% similarity]
test/YAMLParser/spec-09-33.test [moved from test/YAMLParser/spec-09-33.data with 100% similarity]
test/YAMLParser/spec-10-01.test [moved from test/YAMLParser/spec-10-01.data with 100% similarity]
test/YAMLParser/spec-10-02.test [moved from test/YAMLParser/spec-10-02.data with 100% similarity]
test/YAMLParser/spec-10-03.test [moved from test/YAMLParser/spec-10-03.data with 100% similarity]
test/YAMLParser/spec-10-04.test [moved from test/YAMLParser/spec-10-04.data with 100% similarity]
test/YAMLParser/spec-10-05.test [moved from test/YAMLParser/spec-10-05.data with 100% similarity]
test/YAMLParser/spec-10-06.test [moved from test/YAMLParser/spec-10-06.data with 100% similarity]
test/YAMLParser/spec-10-07.test [moved from test/YAMLParser/spec-10-07.data with 100% similarity]
test/YAMLParser/spec-10-08.test [moved from test/YAMLParser/spec-10-08.data with 91% similarity]
test/YAMLParser/spec-10-09.test [moved from test/YAMLParser/spec-10-09.data with 100% similarity]
test/YAMLParser/spec-10-10.test [moved from test/YAMLParser/spec-10-10.data with 100% similarity]
test/YAMLParser/spec-10-11.test [moved from test/YAMLParser/spec-10-11.data with 100% similarity]
test/YAMLParser/spec-10-12.test [moved from test/YAMLParser/spec-10-12.data with 100% similarity]
test/YAMLParser/spec-10-13.test [moved from test/YAMLParser/spec-10-13.data with 100% similarity]
test/YAMLParser/spec-10-14.test [moved from test/YAMLParser/spec-10-14.data with 100% similarity]
test/YAMLParser/spec-10-15.test [moved from test/YAMLParser/spec-10-15.data with 100% similarity]
test/YAMLParser/str.test [moved from test/YAMLParser/str.data with 100% similarity]
test/YAMLParser/timestamp-bugs.test [moved from test/YAMLParser/timestamp-bugs.data with 100% similarity]
test/YAMLParser/timestamp.test [moved from test/YAMLParser/timestamp.data with 100% similarity]
test/YAMLParser/utf8-implicit.test [moved from test/YAMLParser/utf8-implicit.data with 100% similarity]
test/YAMLParser/utf8.test [moved from test/YAMLParser/utf8.data with 100% similarity]
test/YAMLParser/value.test [moved from test/YAMLParser/value.data with 100% similarity]
test/YAMLParser/yaml.test [moved from test/YAMLParser/yaml.data with 100% similarity]
utils/yaml-bench/YAMLBench.cpp

index db888b816cfec69480a2d756c916cdf1203b9678..37becaa7b6d35c51ca060ebb8cbc222e5302a75a 100644 (file)
@@ -76,9 +76,9 @@ std::string escape(StringRef Input);
 class Stream {
 public:
   /// \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();
 
   document_iterator begin();
index cb21eb58e942b84822bb222c6a0e156eeea293c9..83c96510846f2394d75b59eb83b34cbc50bf9941 100644 (file)
@@ -260,8 +260,8 @@ namespace yaml {
 /// @brief Scans YAML tokens from a MemoryBuffer.
 class Scanner {
 public:
-  Scanner(StringRef Input, SourceMgr &SM);
-  Scanner(MemoryBufferRef Buffer, SourceMgr &SM_);
+  Scanner(StringRef Input, SourceMgr &SM, bool ShowColors = true);
+  Scanner(MemoryBufferRef Buffer, SourceMgr &SM_, bool ShowColors = true);
 
   /// @brief Parse the next token and return it without popping it.
   Token &peekNext();
@@ -271,7 +271,7 @@ public:
 
   void printError(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Message,
                   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) {
@@ -505,6 +505,9 @@ private:
   /// @brief True if an error has occurred.
   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
   ///        for the end of a simple key. And for cases where a single character
   ///        can produce multiple tokens (e.g. BlockEnd).
@@ -706,11 +709,13 @@ std::string yaml::escape(StringRef Input) {
   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"));
 }
 
-Scanner::Scanner(MemoryBufferRef Buffer, SourceMgr &SM_) : SM(SM_) {
+Scanner::Scanner(MemoryBufferRef Buffer, SourceMgr &SM_, bool ShowColors)
+    : SM(SM_), ShowColors(ShowColors) {
   init(Buffer);
 }
 
@@ -1525,11 +1530,11 @@ bool Scanner::fetchMoreTokens() {
   return false;
 }
 
-Stream::Stream(StringRef Input, SourceMgr &SM)
-    : scanner(new Scanner(Input, SM)), CurrentDoc() {}
+Stream::Stream(StringRef Input, SourceMgr &SM, bool ShowColors)
+    : scanner(new Scanner(Input, SM, ShowColors)), CurrentDoc() {}
 
-Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM)
-    : scanner(new Scanner(InputBuffer, SM)), CurrentDoc() {}
+Stream::Stream(MemoryBufferRef InputBuffer, SourceMgr &SM, bool ShowColors)
+    : scanner(new Scanner(InputBuffer, SM, ShowColors)), CurrentDoc() {}
 
 Stream::~Stream() {}
 
similarity index 53%
rename from test/YAMLParser/spec-05-02-utf8.data
rename to test/YAMLParser/spec-05-02-utf8.test
index 028f41bb557c2a11cf4cdd30bf9bcf9c08132cb6..3666f990e47f0ed0ab8d504f8bcca2d901b8a7a7 100644 (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
 ï»¿# inside a
similarity index 50%
rename from test/YAMLParser/spec-05-10.data
rename to test/YAMLParser/spec-05-10.test
index bab2c1b89ca3794913806080f6e61d0ff009a270..14112c1eed502a6164223403e400bb5b008ecd13 100644 (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
 grave-accent: `text
similarity index 61%
rename from test/YAMLParser/spec-05-12.data
rename to test/YAMLParser/spec-05-12.test
index eedfc08cf38ac236ae8605289c64fc0b3c90707d..7ecc36dee8bf76c4e79df0027b828a99d19cc3c0 100644 (file)
@@ -1,7 +1,8 @@
 # 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.
-# XFAIL: *
 
 # Tabs do's and don'ts:
 # comment:
@@ -13,4 +14,5 @@ block: |
 elsewhere:     # separation
        indentation, in plain scalar
 
-# CHECK: error
+
+# CHECK: !!str "Quoted\t\t"
diff --git a/test/YAMLParser/spec-05-15.data b/test/YAMLParser/spec-05-15.data
deleted file mode 100644 (file)
index 27dbd83..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
-
-Bad escapes:
-  "\c
-  \xq-"
-
-# CHECK: error
diff --git a/test/YAMLParser/spec-05-15.test b/test/YAMLParser/spec-05-15.test
new file mode 100644 (file)
index 0000000..46228ba
--- /dev/null
@@ -0,0 +1,7 @@
+# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
+
+Bad escapes:
+  "\c
+  \xq-"
+
+# CHECK: error
diff --git a/test/YAMLParser/spec-07-03.data b/test/YAMLParser/spec-07-03.data
deleted file mode 100644 (file)
index c4a5299..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
-
-%YAML 1.1
-%YAML 1.1
-foo
-
-# CHECK: error
diff --git a/test/YAMLParser/spec-07-03.test b/test/YAMLParser/spec-07-03.test
new file mode 100644 (file)
index 0000000..76266b8
--- /dev/null
@@ -0,0 +1,7 @@
+# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
+
+%YAML 1.1
+%YAML 1.1
+foo
+
+# CHECK: error
diff --git a/test/YAMLParser/spec-07-05.data b/test/YAMLParser/spec-07-05.data
deleted file mode 100644 (file)
index f7cff3a..0000000
+++ /dev/null
@@ -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
diff --git a/test/YAMLParser/spec-07-05.test b/test/YAMLParser/spec-07-05.test
new file mode 100644 (file)
index 0000000..447cba8
--- /dev/null
@@ -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
diff --git a/test/YAMLParser/spec-08-04.data b/test/YAMLParser/spec-08-04.data
deleted file mode 100644 (file)
index 73c493d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
-#
-# We don't currently look at the content of literal tags.
-# XFAIL: *
-
-- !<!> foo
-- !<$:?> bar
-
-# CHECK: error
diff --git a/test/YAMLParser/spec-08-04.test b/test/YAMLParser/spec-08-04.test
new file mode 100644 (file)
index 0000000..5b502ae
--- /dev/null
@@ -0,0 +1,7 @@
+# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
+#
+# We don't currently look at the content of literal tags.
+# CHECK: error: Unknown tag handle
+
+- !<!> foo
+- !<$:?> bar
similarity index 55%
rename from test/YAMLParser/spec-08-06.data
rename to test/YAMLParser/spec-08-06.test
index 9844f53a4ef38eb774dbb35f4debe095d25cf4c5..b457d59b569e83157aca51bd0d237577f91ae883 100644 (file)
@@ -1,7 +1,7 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
+# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
 #
 # We don't currently validate tags.
-# XFAIL: *
+# CHECK: error: Unknown tag handle
 
 %TAG !o! tag:ben-kiki.org,2000:
 ---
@@ -9,4 +9,3 @@
 - !o! bar
 - !h!type baz
 
-# CHECK: error
diff --git a/test/YAMLParser/spec-09-02.data b/test/YAMLParser/spec-09-02.data
deleted file mode 100644 (file)
index 9d8a58c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
-#
-# Indent trimming is not yet implemented.
-# XFAIL: *
-
- "as space
- trimmed
-
- specific
-
- escaped       \
- none"
-
-# CHECK: !!str "as space trimmed\nspecific\nescaped\tnone"
diff --git a/test/YAMLParser/spec-09-02.test b/test/YAMLParser/spec-09-02.test
new file mode 100644 (file)
index 0000000..3f8e49a
--- /dev/null
@@ -0,0 +1,14 @@
+# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
+
+ "as space
+ trimmed
+
+ specific
+
+ escaped       \
+ none"
+
+# FIXME: The string below should actually be
+#   "as space trimmed\nspecific\nescaped\tnone", but the parser currently has
+#   a bug when parsing multiline quoted strings.
+# CHECK: !!str "as space\n trimmed\n specific\n escaped\t none"
diff --git a/test/YAMLParser/spec-09-14.data b/test/YAMLParser/spec-09-14.data
deleted file mode 100644 (file)
index a83fcd4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
-#
-# Not quite sure why this doesn't fail.
-# XFAIL: *
-
----
---- ||| : foo
-... >>>: bar
----
-[
----
-,
-... ,
-{
---- :
-... # Nested
-}
-]
-...
-
-# CHECK: error
diff --git a/test/YAMLParser/spec-09-14.test b/test/YAMLParser/spec-09-14.test
new file mode 100644 (file)
index 0000000..55d881d
--- /dev/null
@@ -0,0 +1,21 @@
+# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
+#
+# FIXME: This test should actually fail. Yaml bench should report an error that
+# says that the '---' and '...' document start/end markers must not be specified
+# as the first content line of a non-indented plain scalar.
+# CHECK: !!str
+
+---
+--- ||| : foo
+... >>>: bar
+---
+[
+---
+,
+... ,
+{
+--- :
+... # Nested
+}
+]
+...
similarity index 50%
rename from test/YAMLParser/spec-09-21.data
rename to test/YAMLParser/spec-09-21.test
index 6eb7917a97e368fd6163ede5a43a2c8ddd0160b9..76bc7d6bd31ada967f02680206448a5dde9d4304 100644 (file)
@@ -1,4 +1,4 @@
-# RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
+# RUN: not yaml-bench -canonical %s 2>&1 | FileCheck %s
 
 - |
 
similarity index 91%
rename from test/YAMLParser/spec-10-08.data
rename to test/YAMLParser/spec-10-08.test
index 53faeb9e001b244783bbc13fbf1a02cf23da6704..c4cb8e65ef293d2a17752a4e54c45f668e869a31 100644 (file)
@@ -1,8 +1,8 @@
 # RUN: yaml-bench -canonical %s 2>&1 | FileCheck %s
 #
-# This fails because even without a key token, some contexts (in this case flow
-# maps) allow implicit null keys, which mix with this in weird ways.
-# XFAIL: *
+# FIXME: This test should fail. Yaml bench should report an error that a simple
+# key spans across multiple lines and that another simple key is longer than
+# 1024 characters.
 
 {
 multi-line
@@ -10,4 +10,4 @@ multi-line
 very long ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................(>1KB)................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... key: value
 }
 
-# CHECK: error
+# CHECK: ? !!str "very long
index 0fb31387fc2e7a01b9d2262ef8f77de8050f0667..bd5aa152dffdd20aa762252a70afcb73445e7741 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/Timer.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/YAMLParser.h"
 #include "llvm/Support/raw_ostream.h"
 #include <system_error>
@@ -52,6 +53,10 @@ static cl::opt<unsigned>
                   "Do not use more megabytes of memory"),
                 cl::init(1000));
 
+cl::opt<cl::boolOrDefault>
+    UseColor("use-color", cl::desc("Emit colored output (default=autodetect)"),
+             cl::init(cl::BOU_UNSET));
+
 struct indent {
   unsigned distance;
   indent(unsigned d) : distance(d) {}
@@ -187,6 +192,9 @@ static std::string createJSONText(size_t MemoryMB, unsigned ValueSize) {
 
 int main(int argc, char **argv) {
   llvm::cl::ParseCommandLineOptions(argc, argv);
+  bool ShowColors = UseColor == cl::BOU_UNSET
+                        ? sys::Process::StandardOutHasColors()
+                        : UseColor == cl::BOU_TRUE;
   if (Input.getNumOccurrences()) {
     ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
         MemoryBuffer::getFileOrSTDIN(Input);
@@ -200,8 +208,10 @@ int main(int argc, char **argv) {
     }
 
     if (DumpCanonical) {
-      yaml::Stream stream(Buf.getBuffer(), sm);
+      yaml::Stream stream(Buf.getBuffer(), sm, ShowColors);
       dumpStream(stream);
+      if (stream.failed())
+        return 1;
     }
   }