Commit df969340 authored by Michael Hanus 's avatar Michael Hanus

Command check added, code refactored

parent 59162a3c
......@@ -456,13 +456,22 @@ package and prints out the results. The result is either a list of all package
versions chosen or a description of the conflict encountered during dependency
resolution.
\item[\fbox{\code{check}}]
Checks the current package with CurryCheck.
If the package specifies a list of exported modules
(field \code{exportedModules} of the package specification),
these modules are checked, otherwise all modules in the top-level
directory \code{src} are checked.
Using the option \code{--modules}, one can also specify a comma-separated
list of module names to be checked.
\item[\fbox{\code{diff $version$}}]
Compares the API and behavior of the current package to another
version of the same package.
If the options \code{--api-only} or \code{--behavior-only} are added,
the only the API or the behavior are compared, respectively.
Using the option \code{--modules}, one can also specify a comma-separated
list of modules names to be compared.
list of module names to be compared.
\item[\fbox{\code{exec $command$}}] Executes an arbitrary command with the
\verb|CURRYPATH| environment variable set to the paths of all dependencies of
......
......@@ -5,7 +5,8 @@
--------------------------------------------------------------------------------
module CPM.Config
(Config (Config, packageInstallDir, repositoryDir, packageIndexRepository)
( cpmBanner
, Config (Config, packageInstallDir, repositoryDir, packageIndexRepository)
, readConfiguration, defaultConfig) where
import Char (isSpace)
......@@ -24,6 +25,14 @@ packageIndexURI = "https://git.ps.informatik.uni-kiel.de/curry/cpm-index.git"
-- if you have an ssh access to git.ps:
-- "ssh://git@git.ps.informatik.uni-kiel.de:55055/curry/cpm-index.git"
-- Banner of this tool:
cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of 03/02/2017)"
bannerLine = take (length bannerText) (repeat '-')
--- Data type containing the main configuration of CPM.
data Config = Config {
--- The directory where locally installed packages are stored
......
......@@ -54,7 +54,8 @@ getBaseTemp = getTemporaryDirectory >>=
compareModulesFromPackages :: Config -> Repository -> GC.GlobalCache -> String
-> Version -> String -> Version -> Maybe [String]
-> IO (ErrorLogger [(String, Differences)])
compareModulesFromPackages cfg repo gc nameA verA nameB verB onlyMods = getBaseTemp |>=
compareModulesFromPackages cfg repo gc nameA verA nameB verB onlyMods =
getBaseTemp |>=
\baseTmp -> GC.tryFindPackage gc nameA verA |>=
\pkgA -> GC.tryFindPackage gc nameB verB |>=
\pkgB -> GC.copyPackage cfg pkgA baseTmp |>
......
......@@ -132,10 +132,10 @@ getBaseTemp = getTemporaryDirectory >>=
--- This message is printed before CurryCheck is executed.
infoText :: String
infoText = pPrint $ text ("Now running behavior diff. " ++
"The raw output of CurryCheck is shown. " ++
"The test functions are named after the functions they compare. " ++
"If a test fails, the implementations differ.")
infoText = unlines
[ "Now running behavior diff where the raw output of CurryCheck is shown."
, "The test functions are named after the functions they compare."
, "If a test fails, their implementations differ." ]
--- Compare the behavior of two package versions using CurryCheck.
---
......@@ -158,9 +158,9 @@ diffBehavior cfg repo gc info mods = getBaseTemp |>=
filteredFuncs = filter ((`elem` mods) . fst . funcName) funcs
in case funcs of
[] -> printRemoved removed >> succeedIO ()
_ -> genCurryCheckProgram cfg repo gc filteredFuncs info acyCache |>
_ -> putStrLn infoText >>
genCurryCheckProgram cfg repo gc filteredFuncs info acyCache |>
(printRemoved removed >> succeedIO ()) |>
(putStrLn infoText >> putStrLn "" >> succeedIO ()) |>
callCurryCheck info baseTmp filteredFuncs
where
printRemoved removed =
......
module CPM.FileUtil
( copyDirectory
( joinSearchPath
, copyDirectory
, createSymlink
, removeSymlink
, isSymlink
......@@ -12,13 +13,17 @@ module CPM.FileUtil
, recreateDirectory
) where
import Directory (doesFileExist, getCurrentDirectory, setCurrentDirectory
import Directory ( doesFileExist, getCurrentDirectory, setCurrentDirectory
, getTemporaryDirectory, doesDirectoryExist, createDirectory
, createDirectoryIfMissing)
import System (system, getEnviron)
import IOExts (evalCmd)
import FilePath (replaceFileName, (</>))
import List (splitOn)
import System (system, getEnviron)
import IOExts (evalCmd)
import FilePath (FilePath, replaceFileName, (</>), searchPathSeparator)
import List (intercalate, splitOn)
--- Joins a list of directories into a search path.
joinSearchPath :: [FilePath] -> String
joinSearchPath dirs = intercalate [searchPathSeparator] dirs
--- Recursively copies a directory structure.
copyDirectory :: String -> String -> IO ()
......@@ -96,12 +101,10 @@ inDirectory dir b = do
setCurrentDirectory previous
return b'
--- Recreates a directory.
--- Recreates a directory. Deletes its contents if it already exists.
recreateDirectory :: String -> IO ()
recreateDirectory dir = do
exists <- doesDirectoryExist dir
if exists
then system ("rm -Rf " ++ (quote dir)) >> return ()
else return ()
when exists $ system ("rm -Rf " ++ quote dir) >> done
createDirectoryIfMissing True dir
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment