add some tests

This commit is contained in:
Michael Zhang 2021-09-05 04:47:34 -05:00
parent c26c135c55
commit dc68851233
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
4 changed files with 26 additions and 3 deletions

View file

@ -7,3 +7,6 @@ trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4
[*.nix]
indent_size = 2

View file

@ -8,7 +8,7 @@
let
pkgs = nixpkgs.legacyPackages.${system};
garbageProj = import ./Cargo.nix { inherit pkgs; };
garbage; = pkgs.lib.recursiveUpdate garbageProj.rootCrate.build {
garbage = pkgs.lib.recursiveUpdate garbageProj.rootCrate.build {
meta = {
description = "CLI tool to interact with the FreeDesktop trash API.";
mainProgram = "garbage";
@ -16,12 +16,12 @@
};
flakePkgs = {
inherit garbage;
tests = pkgs.callPackage ./tests { inherit garbage; };
};
in
rec {
packages = flake-utils.lib.flattenTree flakePkgs;
checks = { tests = packages.tests; };
defaultPackage = flakePkgs.garbage;
});
}
# vim: set ts=2 sw=2 :

14
tests/default.nix Normal file
View file

@ -0,0 +1,14 @@
{ stdenv, garbage }:
stdenv.mkDerivation {
name = "garbage-tests";
src = ./.;
installPhase = "mkdir -p $out";
doCheck = true;
garbage = "${garbage}/bin/garbage";
checkPhase = ''
find . -executable -name "*.sh" | xargs bash
'';
}

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
filename=$'\377'$'\017'$'\224'$'\353'\`$'\001'
touch $filename
$garbage put $filename