@@ -4,19 +4,23 @@ import TutorialD.Interpreter.Import.TutorialD
44import System.Exit
55import qualified Data.Text as T
66import System.IO.Temp
7+import System.FilePath
78import qualified Data.Map as M
89import System.IO
10+import System.Directory
911import qualified Data.ByteString as BS
1012import qualified Data.Text.Encoding as TE
11−import Text.URI
13+import Text.URI hiding (makeAbsolute)
1214
1315main :: IO ()
1416main = do
15− tcounts <- runTestTT $ TestList [testTutdFileImport, testTutdHTTPSImport]
17+ tcounts <- runTestTT $ TestList [testTutdFileImport
18+ ,testTutdHTTPSImport
19+ ]
1620 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
1721
1822testTutdFileImport :: Test
19−testTutdFileImport = TestCase $
23+testTutdFileImport = TestCase $
2024 withSystemTempFile "m.tutd" $ \tempPath handle -> do
2125 BS.hPut handle (TE.encodeUtf8 "x:=relation{tuple{a 5,b \"spam\"}}; y:=relation{tuple{b \"漢字\"}}")
2226 hClose handle
@@ -26,7 +30,9 @@ testTutdFileImport = TestCase $
2630 ("b", NakedAtomExpr $ TextAtom "spam")])]),
2731 Assign "y" (MakeRelationFromExprs Nothing
2832 $ TupleExprs () [TupleExpr (M.fromList [("b", NakedAtomExpr (TextAtom "漢字"))])])]
29− fileURI <- mkURI (T.pack ("file://" <> tempPath))
33+ --on Windows, the file URI should not include the drive letter "/c/Users..." -> "/Users"
34+ let uri = "file://" <> map (\c -> if c == '\\' then '/' else c) ( joinDrive "/" (dropDrive (tempPath)))
35+ fileURI <- mkURI (T.pack uri)
3036 imported <- importTutorialDFromFile fileURI Nothing
3137 assertEqual "import tutd" (Right expectedExpr) imported
3238