Skip to content

Commit

Permalink
Add golden tests for parse --proto-symbols output.
Browse files Browse the repository at this point in the history
This should help us ensure that we don't break CLI output, since our
CLI is an API.

This was made super-easy thanks to `tasty-golden`. I literally added
those two lines of code and it automatically created the reference
`.protobuf.bin` files. Slick as hell.
  • Loading branch information
patrickt committed Jun 20, 2019
1 parent b62277f commit 086947a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/Semantic/CLI/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ parseFixtures =
, ("json", parseTermBuilder TermJSONTree, path', prefix </> "parse-trees.json")
, ("json", parseTermBuilder TermJSONTree, [], prefix </> "parse-tree-empty.json")
, ("symbols", parseSymbolsBuilder Serializing.Format.JSON, path'', prefix </> "parse-tree.symbols.json")
, ("protobuf symbols", parseSymbolsBuilder Serializing.Format.Proto, path'', prefix </> "parse-tree.symbols.protobuf.bin")
]
where path = [File "test/fixtures/ruby/corpus/and-or.A.rb" Ruby]
path' = [File "test/fixtures/ruby/corpus/and-or.A.rb" Ruby, File "test/fixtures/ruby/corpus/and-or.B.rb" Ruby]
Expand All @@ -64,6 +65,7 @@ diffFixtures =
[ ("json diff", parseDiffBuilder DiffJSONTree, pathMode, prefix </> "diff-tree.json")
, ("s-expression diff", parseDiffBuilder DiffSExpression, pathMode, "test/fixtures/ruby/corpus/method-declaration.diffA-B.txt")
, ("toc summaries diff", diffSummaryBuilder Serializing.Format.JSON, pathMode, prefix </> "diff-tree.toc.json")
, ("protobuf diff", diffSummaryBuilder Serializing.Format.Proto, pathMode, prefix </> "diff-tree.toc.protobuf.bin")
]
where pathMode = [Both (File "test/fixtures/ruby/corpus/method-declaration.A.rb" Ruby) (File "test/fixtures/ruby/corpus/method-declaration.B.rb" Ruby)]
prefix = "test/fixtures/cli"
5 changes: 5 additions & 0 deletions test/fixtures/cli/diff-tree.toc.protobuf.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

�
ftest/fixtures/ruby/corpus/method-declaration.A.rb -> test/fixtures/ruby/corpus/method-declaration.B.rbRuby
Methodbar
 
5 changes: 5 additions & 0 deletions test/fixtures/cli/parse-tree.symbols.protobuf.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

_
1test/fixtures/ruby/corpus/method-declaration.A.rbRuby$
fooMethoddef foo"


0 comments on commit 086947a

Please sign in to comment.