Skip to content

Only install handlers when HAVE_SIGNAL_H #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,46 @@ jobs:
- name: Haddock
if: matrix.ghc != '8.0'
run: cabal haddock all

build-wasi:
runs-on: ubuntu-latest
env:
GHC_WASM_META_REV: 5ad5e045f52609eab12c7e09ed9b110980807957
FLAVOUR: '9.6'
steps:
- name: setup-ghc-wasm32-wasi
run: |
cd $(mktemp -d)
curl -L https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/$GHC_WASM_META_REV/ghc-wasm-meta-master.tar.gz | tar xz --strip-components=1
./setup.sh
~/.ghc-wasm/add_to_github_path.sh
- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: |
~/.ghc-wasm/.cabal/store
dist-newstyle
key: build-wasi-${{ runner.os }}-wasm-meta-${{ env.GHC_WASM_META_REV }}-flavour-${{ env.FLAVOUR }}-${{ github.sha }}
restore-keys: |
build-wasi-${{ runner.os }}-wasm-meta-${{ env.GHC_WASM_META_REV }}-flavour-${{ env.FLAVOUR }}-

- name: Build
run: |
wasm32-wasi-cabal build all

TEST_WRAPPERS=$(mktemp -d)
echo $TEST_WRAPPERS >> $GITHUB_PATH
wasm32-wasi-cabal install ./core-tests
for test in tasty-core-tests exit-status-test resource-release-test failing-pattern-test; do
echo '#!/usr/bin/env bash' > $TEST_WRAPPERS/$test
echo "wasmtime --mapdir /::/ --env PWD=\"\$PWD\" ~/.ghc-wasm/.cabal/bin/$test.wasm -- \"\$@\"" \
>> $TEST_WRAPPERS/$test
chmod +x $TEST_WRAPPERS/$test
done

- name: Test
run: |
(cd core-tests && tasty-core-tests)
core-tests/exit-status-tests.sh
core-tests/failing-pattern-test.sh
9 changes: 9 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ packages:
quickcheck
smallcheck

if os(wasi)
-- https://github.com/haskellari/splitmix/pull/73
source-repository-package
type: git
location: https://github.com/amesgen/splitmix
tag: 9c307e1bb4a84ef838b90e739990a616411e2d81
package splitmix
tests: False
benchmarks: False
27 changes: 15 additions & 12 deletions core-tests/core-tests.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
-- Initial core-tests.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/

cabal-version: 2.2
name: core-tests
version: 0.1
synopsis: Tests for tasty
Expand All @@ -13,37 +11,42 @@ maintainer: roma@ro-che.info
category: Testing
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10

common commons
default-language: Haskell2010
if !os(wasi)
-- WASM backend does not yet support the threaded runtime
ghc-options: -threaded -with-rtsopts=-N

executable tasty-core-tests
import: commons
main-is: test.hs
other-modules: Resources, Timeouts, Utils, AWK, Dependencies
-- other-extensions:
build-depends: base >= 4.9 && <= 5, tasty, tasty-hunit, tasty-golden, tasty-quickcheck, containers, stm, mtl,
filepath, bytestring, optparse-applicative
-- hs-source-dirs:
default-language: Haskell2010
default-extensions: CPP, NumDecimals
ghc-options: -Wall -fno-warn-type-defaults -threaded -fno-warn-name-shadowing -fno-warn-incomplete-uni-patterns
ghc-options: -Wall -fno-warn-type-defaults -fno-warn-name-shadowing -fno-warn-incomplete-uni-patterns

executable exit-status-test
import: commons
main-is: exit-status-test.hs
build-depends: base <= 5, tasty, tasty-hunit,
random, random-shuffle
default-language: Haskell2010
default-extensions: CPP
ghc-options: -Wall -fno-warn-type-defaults -threaded -with-rtsopts=-N
ghc-options: -Wall -fno-warn-type-defaults

executable resource-release-test
import: commons
main-is: resource-release-test.hs
build-depends: base <= 5, tasty, tasty-hunit
default-language: Haskell2010
default-extensions: CPP
ghc-options: -Wall -fno-warn-type-defaults -threaded -with-rtsopts=-N
ghc-options: -Wall -fno-warn-type-defaults

executable failing-pattern-test
import: commons
main-is: failing-pattern-test.hs
build-depends: base <= 5, tasty, tasty-hunit, random >= 1.2, mtl
default-language: Haskell2010
default-extensions: ScopedTypeVariables
ghc-options: -Wall -fno-warn-type-defaults -threaded -with-rtsopts=-N
ghc-options: -Wall -fno-warn-type-defaults
9 changes: 6 additions & 3 deletions core/Test/Tasty/Runners/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ import GHC.Clock (getMonotonicTime)
import Data.Time.Clock.POSIX (getPOSIXTime)
#endif

-- Install handlers only on UNIX
#ifdef VERSION_unix
#include "HsUnixConfig.h"
#ifdef HAVE_SIGNAL_H
#define INSTALL_HANDLERS 1
#else
#define INSTALL_HANDLERS 0
#endif
#else
#define INSTALL_HANDLERS 0
#endif

#if INSTALL_HANDLERS
import System.Posix.Signals
Expand Down Expand Up @@ -69,8 +73,7 @@ forceElements = foldr seq ()
-- functions. You only need to call it explicitly if you call
-- 'Test.Tasty.Runners.tryIngredients' yourself.
--
-- This function does nothing on non-UNIX systems or when compiled with GHC
-- older than 7.6.
-- This function does nothing when POSIX signals are not supported.
--
-- @since 1.2.1
installSignalHandlers :: IO ()
Expand Down