mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
now 'runghc Setup.hs test' runs a simple extensible testsuite
This commit is contained in:
47
Setup.hs
47
Setup.hs
@@ -8,6 +8,7 @@ import Distribution.Simple.Setup
|
|||||||
import Distribution.PackageDescription
|
import Distribution.PackageDescription
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import System.IO
|
||||||
import System.Cmd
|
import System.Cmd
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import System.Directory
|
import System.Directory
|
||||||
@@ -115,12 +116,38 @@ sdistRGL pkg mb_lbi hooks flags = do
|
|||||||
else getRGLFiles path paths
|
else getRGLFiles path paths
|
||||||
|
|
||||||
testRGL args _ pkg lbi = do
|
testRGL args _ pkg lbi = do
|
||||||
let mode = getOptMode args
|
let paths = case args of
|
||||||
dir = getRGLBuildDir lbi mode
|
[] -> ["testsuite"]
|
||||||
ls = fromMaybe langsTest $ getOptLangs args
|
paths -> paths
|
||||||
createDirectoryIfMissing True dir
|
sequence_ [walk path | path <- paths]
|
||||||
gf (treeb "Lang" ls) [dir ++ "/Lang" ++ la ++ ".gfo" | (_,la) <- ls] pkg lbi
|
where
|
||||||
return ()
|
walk path = do
|
||||||
|
files <- getDirectoryContents path
|
||||||
|
sequence_ [walkFile (path </> file) | file <- files, file /= "." && file /= ".."]
|
||||||
|
|
||||||
|
walkFile fpath = do
|
||||||
|
exists <- doesFileExist fpath
|
||||||
|
if exists
|
||||||
|
then if takeExtension fpath == ".gfs"
|
||||||
|
then do let in_file = fpath
|
||||||
|
gold_file = addExtension fpath ".gold"
|
||||||
|
out_file = addExtension fpath ".out"
|
||||||
|
putStr (in_file++" ... ")
|
||||||
|
hFlush stdout
|
||||||
|
res <- runTest in_file out_file gold_file
|
||||||
|
putStrLn (if res then "OK" else "FAIL")
|
||||||
|
else return ()
|
||||||
|
else walk fpath
|
||||||
|
|
||||||
|
runTest in_file out_file gold_file = do
|
||||||
|
inp <- readFile in_file
|
||||||
|
out <- readProcess (default_gf pkg lbi) ["-run"] inp
|
||||||
|
writeFile out_file out
|
||||||
|
exists <- doesFileExist gold_file
|
||||||
|
if exists
|
||||||
|
then do gold <- readFile gold_file
|
||||||
|
return $! (out == gold)
|
||||||
|
else return False
|
||||||
|
|
||||||
|
|
||||||
rgl_dir = "next-lib" </> "src"
|
rgl_dir = "next-lib" </> "src"
|
||||||
@@ -160,9 +187,6 @@ langsLang = langs `except` ["Ara","Lat","Pol","Ron","Tur"]
|
|||||||
-- languages for which to compile Try
|
-- languages for which to compile Try
|
||||||
langsAPI = langsLang `except` ["Bul","Hin","Ina","Rus","Tha"]
|
langsAPI = langsLang `except` ["Bul","Hin","Ina","Rus","Tha"]
|
||||||
|
|
||||||
-- languages for which to run treebank test
|
|
||||||
langsTest = langsLang `except` ["Ara","Bul","Cat","Hin","Rus","Spa","Tha"]
|
|
||||||
|
|
||||||
-- languages for which to run demo test
|
-- languages for which to run demo test
|
||||||
langsDemo = langsLang `except` ["Ara","Hin","Ina","Tha"]
|
langsDemo = langsLang `except` ["Ara","Hin","Ina","Tha"]
|
||||||
|
|
||||||
@@ -170,7 +194,7 @@ langsDemo = langsLang `except` ["Ara","Hin","Ina","Tha"]
|
|||||||
langsParse = langs `only` ["Eng"]
|
langsParse = langs `only` ["Eng"]
|
||||||
|
|
||||||
-- languages for which langs.pgf is built
|
-- languages for which langs.pgf is built
|
||||||
langsPGF = langsTest `only` ["Eng","Fre","Swe"]
|
langsPGF = langsLang `only` ["Eng","Swe","Bul","Ger"]
|
||||||
|
|
||||||
-- languages for which Compatibility exists (to be extended)
|
-- languages for which Compatibility exists (to be extended)
|
||||||
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Spa","Swe"]
|
langsCompat = langsLang `only` ["Cat","Eng","Fin","Fre","Ita","Spa","Swe"]
|
||||||
@@ -196,9 +220,6 @@ gf comm files pkg lbi = do
|
|||||||
out <- readProcess gf ("-s":files) comm
|
out <- readProcess gf ("-s":files) comm
|
||||||
putStrLn out
|
putStrLn out
|
||||||
|
|
||||||
treeb abstr ls = "rf -lines -tree -file=" ++ treebankExx ++
|
|
||||||
" | l -treebank " ++ unlexer abstr ls ++ " | wf -file=" ++ treebankResults
|
|
||||||
|
|
||||||
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
|
demos abstr ls = "gr -number=100 | l -treebank " ++ unlexer abstr ls ++
|
||||||
" | ps -to_html | wf -file=resdemo.html"
|
" | ps -to_html | wf -file=resdemo.html"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user