2020-07-28 05:19:58 +03:00
|
|
|
{ pkgs, lib, haskellLib }:
|
2019-01-30 08:26:54 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
emptyConfig = {
|
|
|
|
components = {
|
|
|
|
benchmarks = { };
|
|
|
|
exes = { };
|
|
|
|
foreignlibs = { };
|
|
|
|
library = "library";
|
|
|
|
sublibs = { };
|
|
|
|
tests = { };
|
|
|
|
};
|
|
|
|
package.identifier.name = "empty";
|
|
|
|
};
|
|
|
|
|
|
|
|
componentsConfig = {
|
|
|
|
components = {
|
|
|
|
benchmarks = { bbb = "bbb"; };
|
|
|
|
exes = { eee = "eee"; };
|
|
|
|
foreignlibs = { fff = "fff"; };
|
|
|
|
library = "library";
|
|
|
|
sublibs = { };
|
|
|
|
tests = { ttt = "ttt"; };
|
|
|
|
};
|
|
|
|
package.identifier.name = "nnn";
|
|
|
|
};
|
|
|
|
|
2020-07-28 05:19:58 +03:00
|
|
|
testRepo = pkgs.fetchgit {
|
|
|
|
url = "https://github.com/input-output-hk/haskell.nix.git";
|
|
|
|
rev = "487eea1c249537d34c27f6143dff2b9d5586c657";
|
|
|
|
sha256 = "077j5j3j86qy1wnabjlrg4dmqy1fv037dyq3xb8ch4ickpxxs123";
|
|
|
|
};
|
2019-01-30 08:26:54 +03:00
|
|
|
in
|
|
|
|
lib.runTests {
|
|
|
|
# identity function for applyComponents
|
|
|
|
test-applyComponents-id = {
|
|
|
|
expr = haskellLib.applyComponents (componentId: component: component) emptyConfig;
|
|
|
|
expected = emptyConfig.components;
|
|
|
|
};
|
|
|
|
|
|
|
|
# map a component to its component name and check these are correct
|
|
|
|
test-applyComponents-library = {
|
|
|
|
expr = haskellLib.applyComponents (componentId: component: componentId.cname) emptyConfig;
|
2020-07-28 05:19:58 +03:00
|
|
|
expected = emptyConfig.components // { library = "empty"; };
|
2019-01-30 08:26:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
test-applyComponents-components = {
|
|
|
|
expr = haskellLib.applyComponents (componentId: component: component) componentsConfig;
|
|
|
|
expected = componentsConfig.components;
|
|
|
|
};
|
|
|
|
|
|
|
|
# testing that the tests work
|
|
|
|
testId = {
|
|
|
|
expr = lib.id 1;
|
|
|
|
expected = 1;
|
|
|
|
};
|
2020-07-28 05:19:58 +03:00
|
|
|
|
|
|
|
testParseBlock1 = {
|
|
|
|
expr = __toJSON (haskellLib.parseBlock "cabal.project" (_: null) ''
|
|
|
|
type: git
|
|
|
|
location: https://github.com/input-output-hk/haskell.nix.git
|
|
|
|
tag: 487eea1c249537d34c27f6143dff2b9d5586c657
|
|
|
|
--sha256: 077j5j3j86qy1wnabjlrg4dmqy1fv037dyq3xb8ch4ickpxxs123
|
|
|
|
-- end of block
|
|
|
|
'');
|
|
|
|
expected = __toJSON {
|
|
|
|
otherText = "-- end of block\n";
|
|
|
|
sourceRepo = [testRepo];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testParseBlock2 = {
|
|
|
|
expr = __toJSON (haskellLib.parseBlock "cabal.project" (_: null) ''
|
|
|
|
type: git
|
|
|
|
location: https://github.com/input-output-hk/haskell.nix.git
|
|
|
|
tag: 487eea1c249537d34c27f6143dff2b9d5586c657
|
|
|
|
--sha256: 077j5j3j86qy1wnabjlrg4dmqy1fv037dyq3xb8ch4ickpxxs123
|
|
|
|
subdir: dir
|
|
|
|
-- end of block
|
|
|
|
'');
|
|
|
|
expected = __toJSON {
|
|
|
|
otherText = "-- end of block\n";
|
|
|
|
sourceRepo = [(testRepo + "/dir")];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testParseBlock3 = {
|
|
|
|
expr = __toJSON (haskellLib.parseBlock "cabal.project" (_: null) ''
|
|
|
|
type: git
|
|
|
|
location: https://github.com/input-output-hk/haskell.nix.git
|
|
|
|
tag: 487eea1c249537d34c27f6143dff2b9d5586c657
|
|
|
|
--sha256: 077j5j3j86qy1wnabjlrg4dmqy1fv037dyq3xb8ch4ickpxxs123
|
|
|
|
subdir: dir1 dir2
|
|
|
|
-- end of block
|
|
|
|
'');
|
|
|
|
expected = __toJSON {
|
|
|
|
otherText = "-- end of block\n";
|
|
|
|
sourceRepo = [(testRepo + "/dir1") (testRepo + "/dir2")];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testParseBlock4 = {
|
|
|
|
expr = __toJSON (haskellLib.parseBlock "cabal.project" (_: null) ''
|
|
|
|
type: git
|
|
|
|
location: https://github.com/input-output-hk/haskell.nix.git
|
|
|
|
tag: 487eea1c249537d34c27f6143dff2b9d5586c657
|
|
|
|
--sha256: 077j5j3j86qy1wnabjlrg4dmqy1fv037dyq3xb8ch4ickpxxs123
|
|
|
|
subdir:
|
|
|
|
dir1
|
|
|
|
dir2
|
|
|
|
-- end of block
|
|
|
|
'');
|
|
|
|
expected = __toJSON {
|
|
|
|
otherText = "-- end of block\n";
|
|
|
|
sourceRepo = [(testRepo + "/dir1") (testRepo + "/dir2")];
|
|
|
|
};
|
|
|
|
};
|
2019-01-30 08:26:54 +03:00
|
|
|
}
|