Skip to content

Commit

Permalink
make the tests buildable and runnable with cabal and run said testsui…
Browse files Browse the repository at this point in the history
…tes in CI
  • Loading branch information
alpmestan committed Nov 23, 2020
1 parent cbed9ad commit e741af7
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 136 deletions.
11 changes: 6 additions & 5 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 @@ -41,8 +43,7 @@ jobs:
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
- name: Run testsuites
run: cabal test 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?)
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ thrift-hs::
$(THRIFT_COMPILE) --hs \
lib/test/if/echoer.thrift \
-o lib/test
$(THRIFT_COMPILE) --hs \
server/test/if/hash_map.thrift \
-o server/test


thrift-cpp::
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
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
221 changes: 172 additions & 49 deletions common/util/fb-util.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ library
Util.PrettyPrint
Util.RWVar
Util.Reader
-- Util.Regex
-- seems to be missing?
Util.STM
Util.Show
Util.String
Expand All @@ -123,6 +125,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 +193,17 @@ 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++
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 +227,168 @@ 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 log
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: LogTest.hs
ghc-options: -main-is LogTest
other-modules: LogTest.Explicit,
LogTest.MonadStack,
LogTest.OverloadedStrings
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 encoding
import: fb-haskell, test-common
type: exitcode-stdio-1.0
main-is: EncodingTest.hs
ghc-options: -main-is EncodingTest
other-modules: EncodingLib
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 Util.Regex, the module that this is supposed to
-- test, is currently missing.
-- test-suite regex
-- import: fb-haskell, test-common
-- type: exitcode-stdio-1.0
-- main-is: RegexTest.hs
-- ghc-options: -main-is RegexTest

-- 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
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
3 changes: 2 additions & 1 deletion lib/test/ClientTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Control.Monad
import Control.Monad.Trans.Class
import Control.Monad.Trans.Reader
import Data.IORef
import Data.Int
import Data.Proxy
import TestRunner
import Test.HUnit hiding (State)
Expand Down Expand Up @@ -96,7 +97,7 @@ runCalculatorServer proxy ch = do
runServer proxy ch $ processCommand state

-- Server Implementation
type State = IORef Int
type State = IORef Int64

initServerState :: IO State
initServerState = newIORef 0
Expand Down
Loading

0 comments on commit e741af7

Please sign in to comment.