Skip to content

Commit 18c4428

Browse files
committed
Use CPU in CI
1 parent 8abd908 commit 18c4428

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

test/Main.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Main where
44

55
import Control.Monad
66

7+
import Data.Maybe (isJust)
78
import Data.Proxy
89
import Spec (spec)
910
import Test.Hspec (hspec)
@@ -13,14 +14,19 @@ import Test.QuickCheck.Classes
1314
import qualified ArrayFire as A
1415
import ArrayFire (Array)
1516

17+
import System.Environment (lookupEnv)
1618
import System.IO.Unsafe
1719

1820
instance (A.AFType a, Arbitrary a) => Arbitrary (Array a) where
1921
arbitrary = pure $ unsafePerformIO (A.randu [2,2])
2022

2123
main :: IO ()
2224
main = do
23-
A.setBackend A.Default
25+
-- In CI there's often no GPU/OpenCL device available, which makes the
26+
-- default backend throw (e.g. cl::Error: clGetDeviceIDs). Fall back to
27+
-- the CPU backend when running in CI.
28+
inCI <- isJust <$> lookupEnv "CI"
29+
A.setBackend (if inCI then A.CPU else A.Default)
2430
A.info
2531
-- checks (Proxy :: Proxy (A.Array (A.Complex Float)))
2632
-- checks (Proxy :: Proxy (A.Array (A.Complex Double)))

0 commit comments

Comments
 (0)