1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Test that all output formats do product output

This commit is contained in:
Timothy Clem 2017-02-28 14:55:57 -08:00
parent dcfdcf78d3
commit a478b10593
5 changed files with 50 additions and 2 deletions

View File

@ -150,6 +150,7 @@ test-suite test
, TermSpec
, TOCSpec
, IntegrationSpec
, DiffCommandSpec
, SemanticDiffSpec
, Test.Hspec.LeanCheck
build-depends: aeson

View File

@ -1,5 +1,5 @@
{-# OPTIONS_GHC -funbox-strict-fields #-}
module Arguments (Arguments(..), CmdLineOptions(..), DiffMode(..), ExtraArg(..), RunMode(..), programArguments, args) where
module Arguments (Arguments(..), CmdLineOptions(..), DiffMode(..), ExtraArg(..), RunMode(..), programArguments, args, args') where
import Data.Functor.Both
import Data.Maybe
@ -108,6 +108,20 @@ args gitDir sha1 sha2 filePaths format = Arguments
, developmentMode = False
}
args' :: FilePath -> Both FilePath -> R.Format -> Arguments
args' gitDir paths format = Arguments
{ gitDir = gitDir
, alternateObjectDirs = []
, format = format
, timeoutInMicroseconds = defaultTimeout
, output = Nothing
, diffMode = PathDiff paths
, runMode = Diff
, shaRange = both Nothing Nothing
, filePaths = []
, developmentMode = False
}
-- | 7 seconds
defaultTimeout :: Int
defaultTimeout = 7 * 1000000

View File

@ -5,6 +5,7 @@ import Data.Aeson.Encoding (encodingToLazyByteString)
import Data.Functor.Both
import Data.Map as Map hiding (null)
import Data.Text as T (intercalate)
import Data.Functor.Listable
import Prologue
import Source (SourceBlob)
import Syntax
@ -71,3 +72,11 @@ toText (SplitOutput text) = text
toText (PatchOutput text) = text
toText (SExpressionOutput text) = text
toText _ = mempty
instance Listable Format where
tiers = cons0 Split
\/ cons0 Patch
\/ cons0 JSON
\/ cons0 Summary
\/ cons0 SExpression
\/ cons0 TOC

22
test/DiffCommandSpec.hs Normal file
View File

@ -0,0 +1,22 @@
module DiffCommandSpec where
import Prologue
import Data.Functor.Both
import Test.Hspec hiding (shouldBe, shouldNotBe, shouldThrow, errorCall)
import Test.Hspec.Expectations.Pretty
import Test.Hspec.LeanCheck
import Arguments
import DiffCommand
spec :: Spec
spec = parallel $ do
context "diff" $ do
prop "all formats should produce output for file paths" $
\format -> do
output <- diff $ args' "" (both "test/fixtures/ruby/and-or.A.rb" "test/fixtures/ruby/and-or.B.rb") format
output `shouldNotBe` ""
prop "all formats should produce output for commit range" $
\format -> do
output <- diff $ args "test/fixtures/git/examples/all-languages.git" "dfac8fd681b0749af137aebf3203e77a06fbafc2" "2e4144eb8c44f007463ec34cb66353f0041161fe" ["methods.rb"] format
output `shouldNotBe` ""

View File

@ -13,6 +13,7 @@ import qualified Source.Spec
import qualified TermSpec
import qualified TOCSpec
import qualified SemanticDiffSpec
import qualified DiffCommandSpec
import qualified IntegrationSpec
import Test.Hspec
@ -29,5 +30,6 @@ main = hspec . parallel $ do
describe "Source" Source.Spec.spec
describe "Term" TermSpec.spec
describe "TOC" TOCSpec.spec
describe "SemanticDiffSpec" SemanticDiffSpec.spec
describe "DiffCommand" DiffCommandSpec.spec
describe "SemanticDiff" SemanticDiffSpec.spec
describe "Integration" IntegrationSpec.spec