Skip to content

Commit

Permalink
Enable tests in CI (#7)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #7

from #6

Reviewed By: ChrisKuklewicz

Differential Revision: D25196223

fbshipit-source-id: 105933fe84296e465db6be72c50909ec881b52c9
  • Loading branch information
Simon Marlow authored and facebook-github-bot committed Dec 1, 2020
1 parent ecd48a5 commit 6cb3f38
Show file tree
Hide file tree
Showing 15 changed files with 285 additions and 156 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
with:
path: /usr/local/
key: ${{ runner.os }}-${{ steps.get-tag.outputs.tag }}
restore-keys: |
${{ runner.os }}-${{ steps.get-tag.outputs.tag }}
- name: Install folly, fizz, wangle, rsocket-cpp, fbthrift
if: steps.cache-fb-packages.outputs.cache-hit != 'true'
run: ./install_deps.sh
Expand All @@ -36,13 +38,12 @@ jobs:
- name: Generate C++ code from thrift files
run: make thrift-cpp
- name: Build everything up to thrift-compiler
run: cabal build exe:thrift-compiler
run: cabal build --project-file=ci.cabal.project exe:thrift-compiler
- name: Generate Haskell code from thrift files
run: make thrift-hs
- name: Build all packages
run: cabal build all
# - name: Build all packages and their testsuites
# run: cabal build --enable-tests all
# - name: Run testsuites
# shell: bash {0}
# run: ./run_tests.sh
run: cabal build --project-file=ci.cabal.project all
- name: Run testsuites
run: cabal test --project-file=ci.cabal.project mangle fb-util thrift-compiler thrift-lib thrift-server --keep-going
# --keep-going is necessary to avoid stopping at the first failing
# testsuite('s package?)
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ util::

thrift:: thrift-cpp thrift-hs

THRIFT_COMPILE = $(CABAL) new-run exe:thrift-compiler --
THRIFT_COMPILE = $(CABAL) run exe:thrift-compiler --

thrift-hs::
$(THRIFT_COMPILE) --hs \
Expand All @@ -25,13 +25,15 @@ thrift-hs::
$(THRIFT_COMPILE) --hs \
lib/if/ApplicationException.thrift \
-o lib
$(THRIFT_COMPILE) --hs \
$(THRIFT_COMPILE) --hs --use-int \
lib/test/if/math.thrift \
-o lib/test
$(THRIFT_COMPILE) --hs \
$(THRIFT_COMPILE) --hs --use-int \
lib/test/if/echoer.thrift \
-o lib/test

$(THRIFT_COMPILE) --hs \
server/test/if/hash_map.thrift \
-o server/test

thrift-cpp::
cd lib && thrift1 -I . --gen mstch_cpp2 \
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ packages:
server/thrift-server.cabal
compiler/thrift-compiler.cabal
util/thrift-util.cabal

tests: true
17 changes: 17 additions & 0 deletions ci.cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
packages:
common/util/fb-util.cabal
common/mangle/mangle.cabal
lib/thrift-lib.cabal
server/thrift-server.cabal
compiler/thrift-compiler.cabal
util/thrift-util.cabal

tests: true

-- IPV6 is disabled in the Github Actions environment,
-- so we make sure the appropriate tests in those packages
-- turn to IPV4.
package thrift-lib
flags: +tests_use_ipv4
package thrift-server
flags: +tests_use_ipv4
3 changes: 2 additions & 1 deletion common/mangle/mangle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ test-suite mangle-test
default-language: Haskell2010
default-extensions: LambdaCase
main-is: Test.hs
other-modules: TestRunner
build-depends: base, HUnit, hspec, hspec-contrib, mangle
ghc-options: -threaded
ghc-options: -threaded -main-is Test
198 changes: 149 additions & 49 deletions common/util/fb-util.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ library
cpp/HsStruct.cpp
cpp/IOBuf.cpp
cpp/EventBaseDataplane.cpp
-- Util/GFlags.cpp

-- necessary because of the use of 'is_trivially_destructible_v' and friends?
cxx-options: -std=c++17
Expand Down Expand Up @@ -190,60 +191,18 @@ library
pkgconfig-depends: libfolly, libglog
extra-libraries: double-conversion, gflags

test-suite fb-util-tests
import: fb-haskell
type: exitcode-stdio-1.0
hs-source-dirs: tests
main-is: Main.hs
common test-common
extra-libraries: stdc++
cxx-options: -std=c++17
ghc-options: -threaded
other-modules:
Facebook.Init
SpecRunner
TestRunner

-- async
StreamTest

-- datastruct
MovingAverageRateLimiterTest
RateLimiterMapTest

-- util
IOBufTest
AllocLimitTest
UnitTests
RWVarTest
THTest
FilePathTest
OptParseTest
LensTest
ToExpTest
LogTest
-- GFlagsTest
AesonTest
EncodingLib
BufferTest
ExceptionTest
ControlExceptionTest
JSONPrettyTest
IOTest
TimeSecTest
ListTest
EncodingTest
LogTest.OverloadedStrings
LogTest.Explicit
LogTest.MonadStack
ConcurrentTest
MD5Test
Control.MonadTest
StringQuasiTest

hs-source-dirs: tests, tests/github
other-modules: SpecRunner, TestRunner, Facebook.Init
build-depends: base,
aeson,
async,
binary,
bytestring,
containers,
directory,
fb-util,
filepath,
Expand All @@ -267,5 +226,146 @@ test-suite fb-util-tests
vector,
vector-fftw

c-sources: tests/IOBufTest.cpp
tests/GFlagsTest.cpp
test-suite stream
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: StreamTest.hs
ghc-options: -main-is StreamTest
test-suite movavgrl
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: MovingAverageRateLimiterTest.hs
ghc-options: -main-is MovingAverageRateLimiterTest
test-suite rlmap
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: RateLimiterMapTest.hs
ghc-options: -main-is RateLimiterMapTest
test-suite iobuf
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: IOBufTest.hs
ghc-options: -main-is IOBufTest
cxx-sources: tests/IOBufTest.cpp
test-suite alloc-limit
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: AllocLimitTest.hs
ghc-options: -main-is AllocLimitTest
test-suite unit-tests
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: UnitTests.hs
ghc-options: -main-is UnitTests
test-suite rwvar
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: RWVarTest.hs
ghc-options: -main-is RWVarTest
test-suite th
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: THTest.hs
ghc-options: -main-is THTest
test-suite filepath
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: FilePathTest.hs
ghc-options: -main-is FilePathTest
test-suite optparse
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: OptParseTest.hs
ghc-options: -main-is OptParseTest
test-suite lens
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: LensTest.hs
ghc-options: -main-is LensTest
test-suite toexp
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: ToExpTest.hs
ghc-options: -main-is ToExpTest
test-suite aeson
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: AesonTest.hs
ghc-options: -main-is AesonTest
test-suite buffer
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: BufferTest.hs
ghc-options: -main-is BufferTest
test-suite exception
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: ExceptionTest.hs
ghc-options: -main-is ExceptionTest
test-suite control-exception
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: ControlExceptionTest.hs
ghc-options: -main-is ControlExceptionTest
test-suite json-pretty
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: JSONPrettyTest.hs
ghc-options: -main-is JSONPrettyTest
test-suite io
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: IOTest.hs
ghc-options: -main-is IOTest
test-suite time-sec
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: TimeSecTest.hs
ghc-options: -main-is TimeSecTest
test-suite list
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: ListTest.hs
ghc-options: -main-is ListTest
test-suite concurrent
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: ConcurrentTest.hs
ghc-options: -main-is ConcurrentTest
test-suite md5
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: MD5Test.hs
ghc-options: -main-is MD5Test
test-suite control-monad
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: Control/MonadTest.hs
ghc-options: -main-is Control.MonadTest
test-suite string-quasi
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: StringQuasiTest.hs
ghc-options: -main-is StringQuasiTest
test-suite dynamic
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: DynamicTest.hs
cxx-sources: tests/DynamicHelper.cpp
cxx-options: -std=c++17
ghc-options: -main-is DynamicTest
test-suite hs-struct
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: HsStructTest.hs
cxx-sources: tests/HsStructHelper.cpp
cxx-options: -std=c++17
ghc-options: -main-is HsStructTest

-- TODO: commented out because of a linker problem
-- test-suite gflags
-- import: fb-haskell, test-common
-- type: exitcode-stdio-1.0
-- main-is: GFlagsTest.hs
-- ghc-options: -main-is GFlagsTest
-- cxx-sources: tests/GFlagsTest.cpp
10 changes: 6 additions & 4 deletions common/util/tests/github/TestRunner.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module TestRunner where
module TestRunner (module TestRunner) where

import Test.Hspec
import Test.Hspec.Contrib.HUnit (fromHUnitTest)
import Control.Monad
import System.Exit
import Test.HUnit

testRunner :: Test -> IO ()
testRunner t = hspec (fromHUnitTest t)
testRunner t = do
Counts{..} <- runTestTT t
when (errors + failures > 0) $ exitWith (ExitFailure 1)
10 changes: 6 additions & 4 deletions compiler/test/github/TestRunner.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module TestRunner where
module TestRunner (module TestRunner) where

import Test.Hspec
import Test.Hspec.Contrib.HUnit (fromHUnitTest)
import Control.Monad
import System.Exit
import Test.HUnit

testRunner :: Test -> IO ()
testRunner t = hspec (fromHUnitTest t)
testRunner t = do
Counts{..} <- runTestTT t
when (errors + failures > 0) $ exitWith (ExitFailure 1)
4 changes: 2 additions & 2 deletions compiler/test/github/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ withFixtureOptions f = do
let fbcode = fst $ breakOnEnd "fbcode" dir
compilerDir <-
if null fbcode
then -- running from FB source tree
then -- running from github repo
findCompilerDir
else -- running from github repo
else -- running from FB source tree
return (fbcode </> "common" </> "hs" </> "thrift" </> "compiler")
let outPath = "compiler/test/fixtures"
thriftTestsDir = compilerDir </> ".." </> "tests"
Expand Down
9 changes: 4 additions & 5 deletions compiler/thrift-compiler.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ executable thrift-compiler
test-suite thrift-compiler-tests
import: fb-haskell
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
ghc-options: -threaded
other-modules: TestFixtures
TestRunner
hs-source-dirs: test, test/github
main-is: TestFixtures.hs
ghc-options: -threaded -main-is TestFixtures
other-modules: TestRunner
Util
build-depends: aeson-pretty,
base,
Expand Down
2 changes: 1 addition & 1 deletion haxl/thrift-haxl.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.1
cabal-version: 3.6

name: thrift-haxl
version: 0.1.0.0
Expand Down
10 changes: 6 additions & 4 deletions lib/test/github/TestRunner.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module TestRunner where
module TestRunner (module TestRunner) where

import Test.Hspec
import Test.Hspec.Contrib.HUnit (fromHUnitTest)
import Control.Monad
import System.Exit
import Test.HUnit

testRunner :: Test -> IO ()
testRunner t = hspec (fromHUnitTest t)
testRunner t = do
Counts{..} <- runTestTT t
when (errors + failures > 0) $ exitWith (ExitFailure 1)
Loading

0 comments on commit 6cb3f38

Please sign in to comment.