Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ of the wrapper (if any) and ensure that the tests are only run on the required p
let
inherit (tlib)
fileContains
fileNotContains
isDirectory
isFile
notIsFile
Expand All @@ -202,7 +203,7 @@ test { wrapper = "direnv"; } { # <-- Specify the name of the wrapper here (*)
in
[
"[[ -d ${wrapper} ]]" # <-- a simple condition to be asserted
{
{
cond = "[[ -d ${wrapper} ]]";
msg = "No directory found for wrapper."; # <-- you can also specify a custom error message
}
Expand All @@ -214,7 +215,7 @@ test { wrapper = "direnv"; } { # <-- Specify the name of the wrapper here (*)
wrapper = self.wrappers.direnv.wrap {
inherit pkgs;
};
in
in
'' # <-- no need to provide a list if there is only one assertion
"${wrapper}/bin/direnv" --version |
grep -q "${wrapper.version}"
Expand Down Expand Up @@ -253,6 +254,7 @@ except you don't provide a wrapper but a name:
let
inherit (tlib)
fileContains
fileNotContains
isDirectory
isFile
notIsFile
Expand Down
22 changes: 22 additions & 0 deletions ci/test-lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,28 @@ in
msg = "Pattern '${pattern}' not found in ${file}";
};

/**
Returns an `Assertion` that checks whether `file` does not contain a line matching `pattern`.

The check is performed with `! grep -Eq`, so `pattern` is treated as an extended regular expression.

# Type
```
fileNotContains :: String -> String -> Assertion
```

# Arguments
file
: Path to the file to search.

pattern
: Extended regular expression to search for.
*/
fileNotContains = file: pattern: {
cond = ''! grep -Eq -- '${pattern}' "${file}"'';
msg = "Pattern '${pattern}' found in ${file}";
};

/**
Returns an `Assertion` that checks whether `expected` and `actual` are equal.

Expand Down
Loading