Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbecich committed Apr 3, 2023
1 parent 5676489 commit 49d8559
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 275 deletions.
36 changes: 16 additions & 20 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,22 @@ on:

jobs:
linux:

runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
versions:
- ghc: '8.6.5'
cabal: '3.6'
- ghc: '8.8.4'
cabal: '3.6'
- ghc: '8.10.4'
cabal: '3.6'
- ghc: '9.0.2'
cabal: '3.6'
- ghc: '9.2.4'
cabal: '3.6'
ghc: ['9.4.4', '9.2.7', '9.0.2']
cabal: ['3.10.1.0']
os: [ubuntu-latest]
name: Cabal with GHC ${{ matrix.ghc }}
steps:
- uses: actions/checkout@v2

# need to install older cabal/ghc versions from ppa repository
- uses: actions/checkout@v3

- name: Install recent cabal/ghc
uses: haskell/actions/setup@v1
- name: Setup Haskell
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.versions.ghc }}
cabal-version: ${{ matrix.versions.cabal }}
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}

# declare/restore cached things
# caching doesn't work for scheduled runs yet
Expand Down Expand Up @@ -65,6 +55,12 @@ jobs:
- name: Build
run: |
cabal build all --enable-tests --disable-optimization 2>&1 | tee build.log
- uses: actions/setup-node@v2
with:
node-version: "14.x"
- uses: purescript-contrib/setup-purescript@main

- name: Test
run: |
cabal test all --disable-optimization
26 changes: 23 additions & 3 deletions purescript-bridge.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,10 @@ library
-- Base language which the package is written in.
default-language: Haskell2010


Test-Suite tests
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules: TestData
, RoundTrip.Spec
, RoundTrip.Types
build-depends: aeson
, bytestring
, HUnit
Expand All @@ -114,3 +111,26 @@ Test-Suite tests

hs-source-dirs: test
default-language: Haskell2010

Test-Suite roundTrip
type: exitcode-stdio-1.0
main-is: RoundTrip/Spec.hs
other-modules: RoundTrip.Types
build-depends: aeson
, bytestring
, HUnit
, base
, containers
, directory
, hspec
, hspec-expectations-pretty-diff
, process
, purescript-bridge
, QuickCheck
, text
, utf8-string
, wl-pprint-text

hs-source-dirs: test
default-language: Haskell2010

7 changes: 5 additions & 2 deletions src/Language/PureScript/Bridge/Printer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ lensImports settings
]
| otherwise = mempty


argonautCodecsImports :: Switches.Settings -> [ImportLine]
argonautCodecsImports settings
| Switches.generateArgonautCodecs settings =
Expand Down Expand Up @@ -258,7 +257,7 @@ sumTypeToText settings st =
additionalCode =
if Switches.generateLenses settings then lenses else mempty
lenses :: Text
lenses = "\n" <> sep <> "\n" <> T.pack (show (sumTypeToOptics st)) <> sep
lenses = "\n" <> sep <> "\n" <> T.pack (show (sumTypeToOptics st)) <> "\n" <> sep
sep = T.replicate 80 "-"

qualifiedImportToText :: Text -> Text -> Doc
Expand Down Expand Up @@ -303,6 +302,10 @@ typeInfoToDoc :: PSType -> Doc
typeInfoToDoc t@(TypeInfo _ _ _ params) =
(if null params then id else parens) $ typeInfoToDecl t

-- TODO
-- fix extra whitespace after data/newtype declaration, i.e.
-- "data Foo = "
-- There is an extra whitespace character following `textStrict n`
constructorToDoc :: DataConstructor 'PureScript -> Doc
constructorToDoc (DataConstructor n args) =
hsep $
Expand Down
7 changes: 5 additions & 2 deletions test/RoundTrip/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module RoundTrip.Spec where
module Main where

import Control.Exception (bracket)
import Data.Aeson (FromJSON, ToJSON (toJSON), eitherDecode, encode,
Expand Down Expand Up @@ -32,7 +32,7 @@ import System.Process (CreateProcess (std_err, std_in, std_out),
getProcessExitCode, proc,
readProcessWithExitCode, terminateProcess,
waitForProcess)
import Test.Hspec (Spec, around, aroundAll_, around_, describe, it)
import Test.Hspec (Spec, around, aroundAll_, around_, describe, hspec, it)
import Test.Hspec.Expectations.Pretty (shouldBe)
import Test.Hspec.QuickCheck (prop)
import Test.HUnit (assertBool, assertEqual)
Expand All @@ -57,6 +57,9 @@ myTypes =
, equal . genericShow . order . argonaut $ mkSumType @MyUnit
]

main :: IO ()
main = hspec roundtripSpec

roundtripSpec :: Spec
roundtripSpec = do
aroundAll_ withProject $
Expand Down
2 changes: 1 addition & 1 deletion test/RoundTrip/app/src/RoundTrip/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Data.Either (Either)
import Data.Enum (class Enum)
import Data.Enum.Generic (genericPred, genericSucc)
import Data.Generic.Rep (class Generic)
import Data.Lens (Iso', Lens', Prism', iso, prism')
import Data.Lens (Iso', Lens', Prism', iso, lens, prism')
import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Record (prop)
import Data.Maybe (Maybe(..))
Expand Down
Loading

0 comments on commit 49d8559

Please sign in to comment.