From 9885036eec80305fcd44b51a1878e7118282db78 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Dec 2019 21:52:59 +0000 Subject: chore(yants): Move tests into subfolder & add to CI builds --- ci-builds.nix | 2 +- nix/yants/.skip-subtree | 1 - nix/yants/README.md | 2 - nix/yants/tests.nix | 92 -------------------------------------------- nix/yants/tests/default.nix | 94 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 96 deletions(-) delete mode 100644 nix/yants/.skip-subtree delete mode 100644 nix/yants/tests.nix create mode 100644 nix/yants/tests/default.nix diff --git a/ci-builds.nix b/ci-builds.nix index 46480c41a1..5f3ae9bcf1 100644 --- a/ci-builds.nix +++ b/ci-builds.nix @@ -7,12 +7,12 @@ let pkgs = import ./default.nix {}; in with pkgs; [ + nix.yants.tests ops.journaldriver ops.kms_pass ops.sync-gcsr tools.blog_cli tools.emacs web.cgit-taz - # web.tazblog # TODO(tazjin): Happstack build failure in nixos-unstable ] diff --git a/nix/yants/.skip-subtree b/nix/yants/.skip-subtree deleted file mode 100644 index 51a8e01d4e..0000000000 --- a/nix/yants/.skip-subtree +++ /dev/null @@ -1 +0,0 @@ -Yants subtree contains no further derivations. diff --git a/nix/yants/README.md b/nix/yants/README.md index 54e3e4a6a4..5d551e5a49 100644 --- a/nix/yants/README.md +++ b/nix/yants/README.md @@ -1,8 +1,6 @@ yants ===== -[![Build Status](https://travis-ci.org/tazjin/yants.svg?branch=master)](https://travis-ci.org/tazjin/yants) - This is a tiny type-checker for data in Nix, written in Nix. # Features diff --git a/nix/yants/tests.nix b/nix/yants/tests.nix deleted file mode 100644 index 6863ced066..0000000000 --- a/nix/yants/tests.nix +++ /dev/null @@ -1,92 +0,0 @@ -with builtins; -with (import ./default.nix {}); - -# Note: Derivations are not included in the tests below as they cause -# issues with deepSeq. - -deepSeq rec { - # Test that all primitive types match - primitives = [ - (int 15) - (bool false) - (float 13.37) - (string "Hello!") - (function (x: x * 2)) - (path /nix) - ]; - - # Test that polymorphic types work as intended - poly = [ - (option int null) - (list string [ "foo" "bar" ]) - (either int float 42) - ]; - - # Test that structures work as planned. - person = struct "person" { - name = string; - age = int; - - contact = option (struct { - email = string; - phone = option string; - }); - }; - - testPerson = person { - name = "Brynhjulf"; - age = 42; - contact.email = "brynhjulf@yants.nix"; - }; - - # Test enum definitions & matching - colour = enum "colour" [ "red" "blue" "green" ]; - testMatch = colour.match "red" { - red = "It is in fact red!"; - blue = throw "It should not be blue!"; - green = throw "It should not be green!"; - }; - - # Test sum type definitions - creature = sum "creature" { - human = struct { - name = string; - age = option int; - }; - - pet = enum "pet" [ "dog" "lizard" "cat" ]; - }; - - testSum = creature { - human = { - name = "Brynhjulf"; - age = 42; - }; - }; - - testSumMatch = creature.match testSum { - human = v: "It's a human named ${v.name}"; - pet = v: throw "It's not supposed to be a pet!"; - }; - - # Test curried function definitions - func = defun [ string int string ] - (name: age: "${name} is ${toString age} years old"); - - testFunc = func "Brynhjulf" 42; - - # Test that all types are types. - testTypes = map type [ - any bool drv float int string path - - (attrs int) - (eitherN [ int string bool ]) - (either int string) - (enum [ "foo" "bar" ]) - (list string) - (option int) - (option (list string)) - (struct { a = int; b = option string; }) - (sum { a = int; b = option string; }) - ]; -} "All tests passed!\n" diff --git a/nix/yants/tests/default.nix b/nix/yants/tests/default.nix new file mode 100644 index 0000000000..ae144db45a --- /dev/null +++ b/nix/yants/tests/default.nix @@ -0,0 +1,94 @@ +{ pkgs, ... }: + +with builtins; +with pkgs.nix.yants; + +# Note: Derivations are not included in the tests below as they cause +# issues with deepSeq. + +deepSeq rec { + # Test that all primitive types match + primitives = [ + (int 15) + (bool false) + (float 13.37) + (string "Hello!") + (function (x: x * 2)) + (path /nix) + ]; + + # Test that polymorphic types work as intended + poly = [ + (option int null) + (list string [ "foo" "bar" ]) + (either int float 42) + ]; + + # Test that structures work as planned. + person = struct "person" { + name = string; + age = int; + + contact = option (struct { + email = string; + phone = option string; + }); + }; + + testPerson = person { + name = "Brynhjulf"; + age = 42; + contact.email = "brynhjulf@yants.nix"; + }; + + # Test enum definitions & matching + colour = enum "colour" [ "red" "blue" "green" ]; + testMatch = colour.match "red" { + red = "It is in fact red!"; + blue = throw "It should not be blue!"; + green = throw "It should not be green!"; + }; + + # Test sum type definitions + creature = sum "creature" { + human = struct { + name = string; + age = option int; + }; + + pet = enum "pet" [ "dog" "lizard" "cat" ]; + }; + + testSum = creature { + human = { + name = "Brynhjulf"; + age = 42; + }; + }; + + testSumMatch = creature.match testSum { + human = v: "It's a human named ${v.name}"; + pet = v: throw "It's not supposed to be a pet!"; + }; + + # Test curried function definitions + func = defun [ string int string ] + (name: age: "${name} is ${toString age} years old"); + + testFunc = func "Brynhjulf" 42; + + # Test that all types are types. + testTypes = map type [ + any bool drv float int string path + + (attrs int) + (eitherN [ int string bool ]) + (either int string) + (enum [ "foo" "bar" ]) + (list string) + (option int) + (option (list string)) + (struct { a = int; b = option string; }) + (sum { a = int; b = option string; }) + ]; +} (pkgs.writeText "yants-tests" "All tests passed!") -- cgit 1.4.1