Library Infrastructure code on Windows

Graham Klyne gk at ninebynine.org
Tue Jan 20 15:41:46 EST 2004


More feedback...  basically, it works!

I get one batch of warnings when compiling:

[[
Compiling Distribution.Package ( ../Distribution/Package.hs, 
../Distribution/Pac
kage.o )

../Distribution/Package.hs:317:
     Warning: Pattern match(es) are non-exhaustive
              In a record-update construct:
                  Patterns not matched:
                      NoVersion
                      NumberedVersion _ _ _

../Distribution/Package.hs:319:
     Warning: Pattern match(es) are non-exhaustive
              In a record-update construct:
                  Patterns not matched:
                      NoVersion
                      NumberedVersion _ _ _

../Distribution/Package.hs:321:
     Warning: Pattern match(es) are non-exhaustive
              In a record-update construct:
                  Patterns not matched:
                      NoVersion
                      NumberedVersion _ _ _

../Distribution/Package.hs:324:
     Warning: Pattern match(es) are non-exhaustive
              In a record-update construct:
                  Patterns not matched:
                      NoVersion
                      DateVersion _ _ _

../Distribution/Package.hs:326:
     Warning: Pattern match(es) are non-exhaustive
              In a record-update construct:
                  Patterns not matched:
                      NoVersion
                      DateVersion _ _ _

../Distribution/Package.hs:328:
     Warning: Pattern match(es) are non-exhaustive
              In a record-update construct:
                  Patterns not matched:
                      NoVersion
                      DateVersion _ _ _
Compiling Main             ( Test.hs, Test.o )
Linking ...
]]

...

I get one failure from the unit test:
[[
C:\DEV\Haskell\lib\LibInfrastructure\Distribution>testDist
Cases: 9  Tried: 9  Errors: 0  Failures: 0
Cases: 28  Tried: 28  Errors: 0  Failures: 0
'diff' is not recognized as an internal or external command,
operable program or batch file.
### Failure in: 1:package diff:'diff /tmp/xmlTest /tmp/xmlTestOut' failed
expected: ExitFailure 1
but got: ExitSuccess
Cases: 2  Tried: 2  Errors: 0  Failures: 1
]]

...

This looks like a unix-specific command.  I was able to get the test suite 
to run successfully by changing test.hs thus:
[[
hUnitTests :: [Test]
hUnitTests = Distribution.Package.hunitTests
              ++ Distribution.Version.hunitTests

testFilename1 :: String
testFilename1 = "testDist\\xmlTest.tmp"

testFilename2 :: String
testFilename2 = "testDist\\xmlTestOut.tmp"

diffCmd :: String
diffCmd = "fc " ++ testFilename1 ++ " " ++ testFilename2
]]

Giving:
[[
C:\DEV\Haskell\lib\LIBINF~1\DISTRI~1>testDist
Cases: 9  Tried: 9  Errors: 0  Failures: 0
Cases: 28  Tried: 28  Errors: 0  Failures: 0
Comparing files TESTDIST\xmlTest.tmp and TESTDIST\XMLTESTOUT.TMP
FC: no differences encountered

Cases: 2  Tried: 2  Errors: 0  Failures: 0
]]

Rather than depending on an external file compare utility, would it not be 
easier to use a test something like:
    readFile(testFilename1) == readFile(testFilename2)
?

For example:
[[
testFilename1 :: String
testFilename1 = "testDist/xmlTest.tmp"

testFilename2 :: String
testFilename2 = "testDist/xmlTestOut.tmp"

main :: IO ()
main = do runTestTT $ test Distribution.Package.hunitTests
           runTestTT $ test Distribution.Version.hunitTests
           writeXml testFilename1 testPackage2
           e <- (readXml testFilename1::IO PackageConfig)
           writeXml testFilename2 e
           f1 <- readFile(testFilename1)
           f2 <- readFile(testFilename2)
           runTestTT $ test ["write and read" ~: "failed"
                             ~: show e ~=? show testPackage2,
                             "file compare" ~: f1 ~=? f2 ]
           return ()
]]

gives:
[[
C:\DEV\Haskell\lib\LIBINF~1\DISTRI~1>testDist
Cases: 9  Tried: 9  Errors: 0  Failures: 0
Cases: 28  Tried: 28  Errors: 0  Failures: 0
Cases: 2  Tried: 2  Errors: 0  Failures: 0
]]

...

The Windows batch file I used to build this is this:
[[
set WARNINGS=-Wall
set PACKAGES=-package HaXml -package data
set HUNIT=C:\DEV\Haskell\lib\HUnit\
set GHC=C:\DEV\ghc\ghc-6.2\bin\ghc

if "%1"=="clean" goto clean

:all
     mkdir testDist
     %GHC% -fglasgow-exts %WARNINGS% -i%HUNIT%;.;.. -package HaXml --make 
Test.hs -o testDist

         goto exit

:clean
     DEL *.hi
     DEL *.o
     DEL /Q testDist\*.*

:exit
]]

...

See my separate message about building HaXml on windows.

#g
--


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Libraries mailing list