Created
June 26, 2019 18:42
-
-
Save jakubgs/94d6d823b802691fb7a80afb29b450ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This file is an example of the syntax required to call a Nix function | |
| # and serves to test mkFilter.nix. | |
| # | |
| # nix-instantiate --strict --json --eval ./mkFilter_test.nix | |
| # [ | |
| # { | |
| # "expected": true, | |
| # "path": "/home/pedro/src/github.com/status-im/status-react/android/1", | |
| # "result": true | |
| # }, | |
| # { | |
| # "expected": true, | |
| # "path": "/home/pedro/src/github.com/status-im/status-react/ios", | |
| # "result": false | |
| # } | |
| # ] | |
| let | |
| pkgs = import <nixpkgs> { }; | |
| lib = pkgs.stdenv.lib; | |
| mkFilter = pkgs.callPackage ./mkFilter.nix { inherit lib; }; | |
| absPath = "/ABS/PROJECT/PATH"; | |
| filter = mkFilter { | |
| dirRootsToInclude = [ "android" ]; | |
| # dirsToExclude ? [], # Base names of directories to exclude | |
| # filesToInclude ? [], # Relative path of files to include | |
| # filesToExclude ? [], # Relative path of files to exclude | |
| root = absPath; | |
| }; | |
| tests = [ | |
| { | |
| a = { path = "${absPath}/android/1"; type = "directory"; }; | |
| e = true; | |
| } | |
| { | |
| a = { path = "${absPath}/ios"; type = "directory"; }; | |
| e = false; | |
| } | |
| ]; | |
| boolToString = b: if b then "true" else "false"; | |
| in builtins.map ( | |
| t: let | |
| rval = (filter t.a.path t.a.type); | |
| in { | |
| path = t.a.path; | |
| pass = t.e == rval; | |
| } | |
| ) tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment