on master help sign in
Merge pull request #3556 from jfdm/fix-testpkg-for-windows

Fix package testing for windows. Fixes #3541

commit9022afb6ae7aaff554901c891c2028962f7d66a6 authorJan de Muijnck-Hughes <jfdm@users.noreply.github.com> dateWed 7 Dec 2016, 09:32 (10 years ago) parent463421003f3980
7 files changed+66−3
src/Idris/Package.hs+3−2 test/TestData.hs+2−1 test/pkg008/expected+13 test/pkg008/maths.ipkg+9 test/pkg008/run+9 test/pkg008/src/NumOps.idr+9 test/pkg008/src/Test.idr+21
src/Idris/Package.hs+3−2
@@ -145,7 +145,7 @@ replPkg copts fp = do
145145 case mergeOptions copts (idris_opts pkgdesc) of
146146 Left emsg -> ifail emsg
147147 Right opts -> do
148−
148+
149149 putIState orig
150150 dir <- runIO getCurrentDirectory
151151 runIO $ setCurrentDirectory $ dir </> sourcedir pkgdesc
@@ -266,7 +266,8 @@ testPkg copts fp = do
266266 exitWith (ExitFailure 1)
267267 Right opts -> do
268268 m_ist <- idris opts
269− exitCode <- rawSystem tmpn' []
269+ let texe = if isWindows then addExtension tmpn' ".exe" else tmpn'
270+ exitCode <- rawSystem texe []
270271 return (m_ist, exitCode)
271272 case m_ist of
272273 Nothing -> exitWith (ExitFailure 1)
test/TestData.hs+2−1
@@ -178,7 +178,8 @@ testFamiliesData = [
178178 ( 4, ANY ),
179179 ( 5, ANY ),
180180 ( 6, ANY ),
181− ( 7, ANY )]),
181+ ( 7, ANY ),
182+ ( 8, ANY )]),
182183 ("prelude", "Prelude",
183184 [ ( 1, ANY )]),
184185 ("primitives", "Primitive types",
test/pkg008/expectednew file+13
@@ -0,0 +1,13 @@
1+Entering directory `./src'
2+Type checking ./NumOps.idr
3+Type checking ./Test.idr
4+Leaving directory `./src'
5+Test Passed
6+Test Passed
7+Entering directory `./src'
8+Leaving directory `./src'
9+Entering directory `./src'
10+Removed: NumOps.ibc
11+Removed: Test.ibc
12+Removed: 00maths-idx.ibc
13+Leaving directory `./src'
test/pkg008/maths.ipkgnew file+9
@@ -0,0 +1,9 @@
1+package maths
2+
3+sourcedir = src
4+
5+modules = NumOps
6+ , Test
7+
8+tests = Test.testDouble
9+ , Test.testTriple
test/pkg008/runnew file+9
@@ -0,0 +1,9 @@
1+#!/usr/bin/env bash
2+
3+${IDRIS:-idris} $@ --build maths.ipkg
4+${IDRIS:-idris} $@ --testpkg maths.ipkg | grep -v -e "idris"
5+
6+# Idris only appears in the randomly generated name of test so we grep
7+# to remove it to make output consistent.
8+
9+${IDRIS:-idris} $@ --clean maths.ipkg
test/pkg008/src/NumOps.idrnew file+9
@@ -0,0 +1,9 @@
1+module NumOps
2+
3+%access export -- to make functions under test visible
4+
5+double : Num a => a -> a
6+double a = a + a
7+
8+triple : Num a => a -> a
9+triple a = a + double a
test/pkg008/src/Test.idrnew file+21
@@ -0,0 +1,21 @@
1+module Test
2+
3+import NumOps
4+
5+%access export -- to make the test functions visible
6+
7+assertEq : Eq a => (given : a) -> (expected : a) -> IO ()
8+assertEq g e = if g == e
9+ then putStrLn "Test Passed"
10+ else putStrLn "Test Failed"
11+
12+assertNotEq : Eq a => (given : a) -> (expected : a) -> IO ()
13+assertNotEq g e = if not (g == e)
14+ then putStrLn "Test Passed"
15+ else putStrLn "Test Failed"
16+
17+testDouble : IO ()
18+testDouble = assertEq (double 2) 4
19+
20+testTriple : IO ()
21+testTriple = assertNotEq (triple 2) 5