1
1
mirror of https://github.com/github/semantic.git synced 2024-11-23 16:37:50 +03:00

Allow running integration tests only for one language

The --test-arguments can be passed like this:

stack build :integration-test --test-arguments "--language=ruby"

--language is naively parsed right now just to avoid getting in the way
of hspec's option parsing.
This commit is contained in:
Timothy Clem 2016-10-19 10:12:14 -07:00
parent 1280a96ac5
commit c213e85e9c
3 changed files with 28 additions and 9 deletions

View File

@ -193,6 +193,7 @@ test-suite integration-test
, hspec >= 2.1.10
, hspec-expectations-pretty-diff
, semantic-diff
, MissingH
ghc-options: -threaded -rtsopts -with-rtsopts=-N -j -pgml=script/g++
default-language: Haskell2010
default-extensions: DeriveGeneric, FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards

View File

@ -39,15 +39,18 @@ runTestsIn filePaths format matcher = do
Left err -> it ("An error occurred " <> err <> " (" <> filePath <> ")") $ True `shouldBe` False
Right testCases -> traverse_ (\testCase -> it (testCaseDescription testCase) $ assertDiffSummary testCase format matcher) testCases
spec :: Spec
spec = parallel $ do
diffSummaryFiles <- runIO $ testCaseFiles "test/corpus/diff-summaries"
diffSummaryToDoFiles <- runIO $ testCaseFiles "test/corpus/diff-summaries-todo"
diffSummaryCrasherFiles <- runIO $ testCaseFiles "test/corpus/diff-summary-crashers"
spec :: Maybe String -> Spec
spec maybeLanguage = parallel $ do
diffSummaryFiles <- runIO $ testCaseFiles maybeLanguage "test/corpus/diff-summaries"
diffSummaryToDoFiles <- runIO $ testCaseFiles maybeLanguage "test/corpus/diff-summaries-todo"
diffSummaryCrasherFiles <- runIO $ testCaseFiles maybeLanguage "test/corpus/diff-summary-crashers"
describe "diff summaries" $ runTestsIn diffSummaryFiles Summary shouldBe
describe "diff summaries todo" $ runTestsIn diffSummaryToDoFiles Summary shouldNotBe
describe "diff summaries crashers todo" $ runTestsIn diffSummaryCrasherFiles Summary shouldBe
where testCaseFiles :: String -> IO [FilePath]
testCaseFiles = globDir1 (compile "*/*.json")
where
testCaseFiles :: Maybe String -> String -> IO [FilePath]
testCaseFiles maybeLanguage dir = case maybeLanguage of
Just language -> globDir1 (compile (language <> "/*.json")) dir
Nothing -> globDir1 (compile "*/*.json") dir

View File

@ -1,9 +1,24 @@
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Prologue
import Prelude (String)
import Data.List
import Data.List.Utils
import qualified SemanticGitDiffSpec
import Test.Hspec
import System.Environment (withArgs)
main :: IO ()
main = hspec $ parallel $ do
describe "DiffSummaries" SemanticGitDiffSpec.spec
main = do
args <- getArgs
let (language, rest) = parseCustomArgs args
withArgs rest . hspec . parallel $ describe "DiffSummaries" (SemanticGitDiffSpec.spec language)
where
parseCustomArgs :: [String] -> (Maybe String, [String])
parseCustomArgs args = case partitioned of
(l:_, rest) -> (toLang l, rest)
_ -> (Nothing, args)
where
partitioned = partition (startswith "--language") args
toLang s = Just $ replace "--language=" "" s