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 charset = utf-8
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
[*.nix]
indent_size = 2

View file

@ -8,7 +8,7 @@
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
garbageProj = import ./Cargo.nix { inherit pkgs; }; garbageProj = import ./Cargo.nix { inherit pkgs; };
garbage; = pkgs.lib.recursiveUpdate garbageProj.rootCrate.build { garbage = pkgs.lib.recursiveUpdate garbageProj.rootCrate.build {
meta = { meta = {
description = "CLI tool to interact with the FreeDesktop trash API."; description = "CLI tool to interact with the FreeDesktop trash API.";
mainProgram = "garbage"; mainProgram = "garbage";
@ -16,12 +16,12 @@
}; };
flakePkgs = { flakePkgs = {
inherit garbage; inherit garbage;
tests = pkgs.callPackage ./tests { inherit garbage; };
}; };
in in
rec { rec {
packages = flake-utils.lib.flattenTree flakePkgs; packages = flake-utils.lib.flattenTree flakePkgs;
checks = { tests = packages.tests; };
defaultPackage = flakePkgs.garbage; 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