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

llvm-svn: 236754

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

index db888b8..37becaa 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 cb21eb5..83c9651 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 llvm/test/YAMLParser/spec-05-02-utf8.data
rename to llvm/test/YAMLParser/spec-05-02-utf8.test
index 028f41b..3666f99 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 llvm/test/YAMLParser/spec-05-10.data
rename to llvm/test/YAMLParser/spec-05-10.test
index bab2c1b..14112c1 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 llvm/test/YAMLParser/spec-05-12.data
rename to llvm/test/YAMLParser/spec-05-12.test
index eedfc08..7ecc36d 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/llvm/test/YAMLParser/spec-05-15.data b/llvm/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/llvm/test/YAMLParser/spec-05-15.test b/llvm/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/llvm/test/YAMLParser/spec-07-03.data b/llvm/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/llvm/test/YAMLParser/spec-07-03.test b/llvm/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/llvm/test/YAMLParser/spec-07-05.data b/llvm/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/llvm/test/YAMLParser/spec-07-05.test b/llvm/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/llvm/test/YAMLParser/spec-08-04.data b/llvm/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/llvm/test/YAMLParser/spec-08-04.test b/llvm/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 llvm/test/YAMLParser/spec-08-06.data
rename to llvm/test/YAMLParser/spec-08-06.test
index 9844f53..b457d59 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/llvm/test/YAMLParser/spec-09-02.data b/llvm/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/llvm/test/YAMLParser/spec-09-02.test b/llvm/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/llvm/test/YAMLParser/spec-09-14.data b/llvm/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/llvm/test/YAMLParser/spec-09-14.test b/llvm/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 llvm/test/YAMLParser/spec-09-21.data
rename to llvm/test/YAMLParser/spec-09-21.test
index 6eb7917..76bc7d6 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 llvm/test/YAMLParser/spec-10-08.data
rename to llvm/test/YAMLParser/spec-10-08.test
index 53faeb9..c4cb8e6 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 0fb3138..bd5aa15 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;
     }
   }