From 086947ade5d4ad6d72ca5d2c1ef92c1b46ace1c5 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Thu, 20 Jun 2019 01:33:51 -0400 Subject: [PATCH 1/4] Add golden tests for `parse --proto-symbols` output. 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. --- test/Semantic/CLI/Spec.hs | 2 ++ test/fixtures/cli/diff-tree.toc.protobuf.bin | 5 +++++ test/fixtures/cli/parse-tree.symbols.protobuf.bin | 5 +++++ 3 files changed, 12 insertions(+) create mode 100644 test/fixtures/cli/diff-tree.toc.protobuf.bin create mode 100644 test/fixtures/cli/parse-tree.symbols.protobuf.bin diff --git a/test/Semantic/CLI/Spec.hs b/test/Semantic/CLI/Spec.hs index c65c93a692..a2d4ec3219 100644 --- a/test/Semantic/CLI/Spec.hs +++ b/test/Semantic/CLI/Spec.hs @@ -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] @@ -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" diff --git a/test/fixtures/cli/diff-tree.toc.protobuf.bin b/test/fixtures/cli/diff-tree.toc.protobuf.bin new file mode 100644 index 0000000000..d1aa72db94 --- /dev/null +++ b/test/fixtures/cli/diff-tree.toc.protobuf.bin @@ -0,0 +1,5 @@ + + +ftest/fixtures/ruby/corpus/method-declaration.A.rb -> test/fixtures/ruby/corpus/method-declaration.B.rbRuby +Methodbar +  \ No newline at end of file diff --git a/test/fixtures/cli/parse-tree.symbols.protobuf.bin b/test/fixtures/cli/parse-tree.symbols.protobuf.bin new file mode 100644 index 0000000000..75807b63d1 --- /dev/null +++ b/test/fixtures/cli/parse-tree.symbols.protobuf.bin @@ -0,0 +1,5 @@ + +_ +1test/fixtures/ruby/corpus/method-declaration.A.rbRuby$ +fooMethoddef foo" + \ No newline at end of file From ac8532d38e129b36487f39be2c68e244e71b1b30 Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Thu, 20 Jun 2019 01:37:58 -0400 Subject: [PATCH 2/4] The fixtures are binary files, don't diff them. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 102ed8bdbc..9d2f2cec44 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ test/fixtures linguist-vendored test/repos linguist-vendored vendor linguist-vendored +*.protobuf.bin binary From 669ee584dfedd6a846aa94aeeaa53f4f462717fe Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Thu, 20 Jun 2019 01:50:32 -0400 Subject: [PATCH 3/4] Quiesce the last few warnings from the tests. --- test/Data/Functor/Listable.hs | 4 ++-- test/Semantic/IO/Spec.hs | 1 - test/Semantic/Stat/Spec.hs | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/Data/Functor/Listable.hs b/test/Data/Functor/Listable.hs index 8f69b5926d..9c31ec66fd 100644 --- a/test/Data/Functor/Listable.hs +++ b/test/Data/Functor/Listable.hs @@ -107,8 +107,8 @@ liftCons4 tiers1 tiers2 tiers3 tiers4 f = mapT (uncurry4 f) (tiers1 >< tiers2 >< -- | Lifts a quinary constructor to a list of tiers, given lists of tiers for its arguments. -- -- Commonly used in the definition of 'Listable1' and 'Listable2' instances. -liftCons5 :: [Tier a] -> [Tier b] -> [Tier c] -> [Tier d] -> [Tier e] -> (a -> b -> c -> d -> e -> f) -> [Tier f] -liftCons5 tiers1 tiers2 tiers3 tiers4 tiers5 f = mapT (uncurry5 f) (tiers1 >< tiers2 >< tiers3 >< tiers4 >< tiers5) `addWeight` 1 +_liftCons5 :: [Tier a] -> [Tier b] -> [Tier c] -> [Tier d] -> [Tier e] -> (a -> b -> c -> d -> e -> f) -> [Tier f] +_liftCons5 tiers1 tiers2 tiers3 tiers4 tiers5 f = mapT (uncurry5 f) (tiers1 >< tiers2 >< tiers3 >< tiers4 >< tiers5) `addWeight` 1 where uncurry5 f (a, (b, (c, (d, e)))) = f a b c d e -- | Lifts a senary constructor to a list of tiers, given lists of tiers for its arguments. diff --git a/test/Semantic/IO/Spec.hs b/test/Semantic/IO/Spec.hs index 2f8fc3203a..80bea9b96b 100644 --- a/test/Semantic/IO/Spec.hs +++ b/test/Semantic/IO/Spec.hs @@ -5,7 +5,6 @@ import Prelude hiding (readFile) import Control.Monad.IO.Class import Data.List import System.Directory -import System.Exit (ExitCode (..)) import System.IO.Temp import Data.String diff --git a/test/Semantic/Stat/Spec.hs b/test/Semantic/Stat/Spec.hs index 74b607a963..63d813790c 100644 --- a/test/Semantic/Stat/Spec.hs +++ b/test/Semantic/Stat/Spec.hs @@ -11,7 +11,6 @@ import System.Environment import Test.Tasty import Test.Tasty.HUnit -import Test.Tasty.Runners withSocketPair :: ((Socket, Socket) -> IO c) -> IO c withSocketPair = bracket create release @@ -32,7 +31,7 @@ testTree = testCaseSteps "Semantic.Stat.Spec" $ \step -> do step "Handles stats addr with just hostname" case_handles_stats_addr_with_just_hostname step "takes dogstats host from environment" - case_takes_stats_addr_from_environment + case_takes_dogstats_host_from_environment step "rendering" case_render_counters *> case_render_tags step "stats deliver datagram" From a5a349ba23e50e4b0e7b64046b4c40e4e90a05eb Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Thu, 20 Jun 2019 12:59:40 -0400 Subject: [PATCH 4/4] Remove unused liftCons5 function. --- test/Data/Functor/Listable.hs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/Data/Functor/Listable.hs b/test/Data/Functor/Listable.hs index 9c31ec66fd..5d9dbf6a58 100644 --- a/test/Data/Functor/Listable.hs +++ b/test/Data/Functor/Listable.hs @@ -104,13 +104,6 @@ liftCons4 :: [Tier a] -> [Tier b] -> [Tier c] -> [Tier d] -> (a -> b -> c -> d - liftCons4 tiers1 tiers2 tiers3 tiers4 f = mapT (uncurry4 f) (tiers1 >< tiers2 >< tiers3 >< tiers4) `addWeight` 1 where uncurry4 f (a, (b, (c, d))) = f a b c d --- | Lifts a quinary constructor to a list of tiers, given lists of tiers for its arguments. --- --- Commonly used in the definition of 'Listable1' and 'Listable2' instances. -_liftCons5 :: [Tier a] -> [Tier b] -> [Tier c] -> [Tier d] -> [Tier e] -> (a -> b -> c -> d -> e -> f) -> [Tier f] -_liftCons5 tiers1 tiers2 tiers3 tiers4 tiers5 f = mapT (uncurry5 f) (tiers1 >< tiers2 >< tiers3 >< tiers4 >< tiers5) `addWeight` 1 - where uncurry5 f (a, (b, (c, (d, e)))) = f a b c d e - -- | Lifts a senary constructor to a list of tiers, given lists of tiers for its arguments. -- -- Commonly used in the definition of 'Listable1' and 'Listable2' instances.