numtide / nix-filter

a small self-contained source filtering lib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add runnable tests

zimbatm opened this issue · comments

The ./tests folder currently doesn't test anything. It just allows a user to easily manually test all the use-cases.

I think a simple bash script that compares the output with an expected list of files is probably enough.

$ nix-instantiate --eval --json --strict tests/
trace: unmatched path=/home/zimbatm/go/src/github.com/numtide/nix-filter/tests/fixture1/README.md type=regular
trace: unmatched path=/home/zimbatm/go/src/github.com/numtide/nix-filter/tests/fixture1/package.json type=regular
trace: unmatched path=/home/zimbatm/go/src/github.com/numtide/nix-filter/tests/fixture1/src type=directory
{"all":"/nix/store/rgjgr6sz431l4ihw3dsqmx2p2s0nyf4c-source","combiners":"/nix/store/pf6i1czhnjjqiwv5hzc63i4gaizd75sm-source","trace":"/nix/store/0ccnxa25whszw7mgbgyzdm4nqc0zwnm8-source","with-inDirectory":"/nix/store/shkhc9pys5hpqxas1pvmghaard0lz1jw-source","with-inDirectory2":"/nix/store/kg31s34xq2cl2mgzai0409izqhdr6hyf-source","with-matchExt":"/nix/store/d4y4y9js500qh8cpq3y0wf6gds66hc2z-source","with-matchExt2":"/nix/store/gfjb5mhq3jscwap4imxhcdyk5f4wccl3-source","without-readme":"/nix/store/zs42mv8ks2sfrnh3l99fk04a3xnphjyq-source"}

This gives all the attributes and store paths.

Funny story, I was already writing this one O.o