diff options
author | Will Dietz <w@wdtz.org> | 2018-02-25T22·33-0600 |
---|---|---|
committer | Will Dietz <w@wdtz.org> | 2018-02-25T22·40-0600 |
commit | 8282c60d742dc6725723370249a341a944575d6c (patch) | |
tree | f11fb131600454175a219677d1ce19221bd63bca /tests/search.sh | |
parent | 9432f3fb7d3614bf121399cdd83c82065efedbb2 (diff) |
tests: test nix search behavior
Diffstat (limited to 'tests/search.sh')
-rw-r--r-- | tests/search.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/search.sh b/tests/search.sh new file mode 100644 index 000000000000..53a69a0bb01c --- /dev/null +++ b/tests/search.sh @@ -0,0 +1,42 @@ +source common.sh + +clearStore +clearCache + +# No packages +(( $(NIX_PATH= nix search -u|wc -l) == 0 )) + +# Haven't updated cache, still nothing +(( $(nix search -f search.nix hello|wc -l) == 0 )) +(( $(nix search -f search.nix |wc -l) == 0 )) + +# Update cache, search should work +(( $(nix search -f search.nix -u hello|wc -l) > 0 )) + +# Use cache +(( $(nix search -f search.nix foo|wc -l) > 0 )) +(( $(nix search foo|wc -l) > 0 )) + +# Test --no-cache works +# No results from cache +(( $(nix search --no-cache foo |wc -l) == 0 )) +# Does find results from file pointed at +(( $(nix search -f search.nix --no-cache foo |wc -l) > 0 )) + +# Check descriptions are searched +(( $(nix search broken | wc -l) > 0 )) + +# Check search that matches nothing +(( $(nix search nosuchpackageexists | wc -l) == 0 )) + + +## Search expressions + +# Check that empty search string matches all +EMPTY=$(nix search) +BOL=$(nix search "^") +ALL=$(nix search ".*") + +diff <(printf "%s" $EMPTY) <(printf "%s" $BOL) +# "ALL" highlights differently, not sure preferred behavior +# diff <(printf "%s" $EMPTY) <(printf "%s" $ALL) |