2024-01-02 10:51:57 +00:00
|
|
|
|
|
|
|
# Tix
|
|
|
|
|
|
|
|
Test your Nix is only ticks.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Make a test file:
|
|
|
|
|
|
|
|
```mytest.nix
|
2024-01-02 13:55:51 +00:00
|
|
|
{ describe, it, ... }:
|
|
|
|
describe "what I'm testing" [
|
2024-01-02 10:51:57 +00:00
|
|
|
(it "can add numbers" {
|
|
|
|
actual = 2 + 2;
|
|
|
|
expected = 4;
|
|
|
|
})
|
|
|
|
(it "loves big brother" {
|
|
|
|
actual = 2 + 2;
|
|
|
|
expected = 5;
|
|
|
|
})
|
2024-01-02 11:13:47 +00:00
|
|
|
(it "throws a party" {
|
|
|
|
actual = throw "a party";
|
|
|
|
throws = true;
|
|
|
|
})
|
2024-01-02 10:51:57 +00:00
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
Add tix as an input to your flake, and use it to build a test output.
|
|
|
|
|
|
|
|
```flake.nix
|
|
|
|
{
|
|
|
|
description = "My test driven flake";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
tix.url = "git+https://git.tristans.cloud/tristan/tix";
|
|
|
|
};
|
|
|
|
|
|
|
|
outpts = {self, tix, ...}: {
|
|
|
|
packages.x86_64-linux.test = tix.run [
|
|
|
|
./mytest.nix
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Then run the generated package.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
nix run .#test --show-trace
|
|
|
|
```
|
|
|
|
|