Module CPM.Diff.Behavior

This module contains functions that compare the behavior of two versions of a package.

For this purpose, copies of these packages and a main "comparison" module (with name "Compare") are generated in the temporary directory /tmp/CPM/bdiff and then CurryCheck is executed on Compare.

Summary of exported operations:

getBaseTemp :: IO String  Deterministic 
Get temporary directory for the behavior diff.
diffBehavior :: Config -> Repository -> GlobalCache -> ComparisonInfo -> Bool -> Bool -> Maybe [String] -> ErrorLogger ()  Deterministic 
Compare the behavior of two package versions using CurryCheck.
genCurryCheckProgram :: Config -> Repository -> GlobalCache -> [(Bool,CFuncDecl)] -> ComparisonInfo -> Bool -> ACYCache -> [String] -> ErrorLogger ()  Deterministic 
Generates a program containing CurryCheck tests that will compare the behavior of the given functions.
findFunctionsToCompare :: Config -> Repository -> GlobalCache -> String -> String -> Bool -> Maybe [String] -> ErrorLogger (ACYCache,[String],[(Bool,CFuncDecl)],[(CFuncDecl,FilterReason)])  Deterministic 
Finds a list of functions that can be compared.
preparePackages :: Config -> Repository -> GlobalCache -> String -> (Int,Int,Int,Maybe String) -> String -> (Int,Int,Int,Maybe String) -> ErrorLogger ComparisonInfo  Deterministic 
Prepares two packages from the global package cache in two versions for comparison by copying them to the temporary directory and building renamed versions.
preparePackageAndDir :: Config -> Repository -> GlobalCache -> String -> String -> (Int,Int,Int,Maybe String) -> ErrorLogger ComparisonInfo  Deterministic 
Prepares two package, one from a directory and one from the global package cache.
preparePackageDirs :: Config -> Repository -> GlobalCache -> String -> String -> ErrorLogger ComparisonInfo  Deterministic 
Prepares two packages from two directories for comparison.

Exported datatypes:


ComparisonInfo

Contains information from the package preparation (moving to temp directory and renaming).

Constructors:

  • ComparisonInfo :: Package -> Package -> String -> String -> String -> String -> String -> String -> [(String,String)] -> [(String,String)] -> ComparisonInfo

    Fields:

    • infPackageA :: Package
    • infPackageB :: Package
    • infDirA :: String
    • infDirB :: String
    • infSourceDirA :: String
    • infSourceDirB :: String
    • infPrefixA :: String
    • infPrefixB :: String
    • infModMapA :: [(String,String)]
    • infModMapB :: [(String,String)]

Exported operations:

getBaseTemp :: IO String  Deterministic 

Get temporary directory for the behavior diff.

diffBehavior :: Config -> Repository -> GlobalCache -> ComparisonInfo -> Bool -> Bool -> Maybe [String] -> ErrorLogger ()  Deterministic 

Compare the behavior of two package versions using CurryCheck.

Example call:
(diffBehavior cfg repo gc info groundequiv useanalysis mods)
Parameters:
  • cfg : the CPM configuration
  • repo : the central package index
  • gc : the global package cache
  • info : the comparison info obtained from preparePackageDirs
  • groundequiv : test ground equivalence only?
  • useanalysis : use program analysis to filter non-term. operations?
  • mods : a list of modules to compare

genCurryCheckProgram :: Config -> Repository -> GlobalCache -> [(Bool,CFuncDecl)] -> ComparisonInfo -> Bool -> ACYCache -> [String] -> ErrorLogger ()  Deterministic 

Generates a program containing CurryCheck tests that will compare the behavior of the given functions. The program will be written to the Compare.curry file in the behavior diff temp directory.

findFunctionsToCompare :: Config -> Repository -> GlobalCache -> String -> String -> Bool -> Maybe [String] -> ErrorLogger (ACYCache,[String],[(Bool,CFuncDecl)],[(CFuncDecl,FilterReason)])  Deterministic 

Finds a list of functions that can be compared. At the moment, this uses the functionality from CPM.Diff.API to compare the public interfaces of both module versions and find the functions that have not changed between versions.

Example call:
(findFunctionsToCompare cfg repo gc dirA dirB useanalysis mods)
Parameters:
  • cfg : the CPM configuration
  • repo : the current repository
  • gc : the global package cache
  • dirA : the directory of the A version of the package
  • dirB : the directory of the B version of the package
  • useanalysis : use program analysis to filter non-term. operations?
  • mods : the modules to compare (if Nothing, compare exported modules)
Returns:
a tuple consisting of an ACYCache, a list of functions to be compared (with a flag which is true if they are productive, might be non-terminating but can be compared level-wise), and a list of non-comparable functions with a reason

preparePackages :: Config -> Repository -> GlobalCache -> String -> (Int,Int,Int,Maybe String) -> String -> (Int,Int,Int,Maybe String) -> ErrorLogger ComparisonInfo  Deterministic 

Prepares two packages from the global package cache in two versions for comparison by copying them to the temporary directory and building renamed versions.

Example call:
(preparePackages cfg repo gc nameA verA nameB verB)
Parameters:
  • cfg : the CPM configuration
  • repo : the package repository
  • gc : the global package cache
  • nameA : the name of the first package
  • verA : the version of the first package
  • nameB : the name of the second package
  • verB : the version of the second package

preparePackageAndDir :: Config -> Repository -> GlobalCache -> String -> String -> (Int,Int,Int,Maybe String) -> ErrorLogger ComparisonInfo  Deterministic 

Prepares two package, one from a directory and one from the global package cache. Copies them to a temporary directory and builds renamed versions of the packages and all dependencies.

Example call:
(preparePackageAndDir cfg repo gc dirA nameB verB)
Parameters:
  • cfg : the CPM configuration
  • repo : the package repository
  • gc : the global package cache
  • dirA : the directory for the first package
  • nameB : the name of the second package
  • verB : the version of the second package

preparePackageDirs :: Config -> Repository -> GlobalCache -> String -> String -> ErrorLogger ComparisonInfo  Deterministic 

Prepares two packages from two directories for comparison. Copies the package files to a temporary directory and creates renamed version of the packages and their dependencies.

Example call:
(preparePackageDirs cfg repo gc dirA dirB)
Parameters:
  • cfg : the CPM configuration
  • repo : the package repository
  • gc : the global package cache
  • dirA : the directory containing the first package
  • dirB : the directory containing the second package