Add devshell and initial bats tests
This commit is contained in:
parent
af8fae68fe
commit
d3b3862040
4 changed files with 102 additions and 4 deletions
40
default.nix
40
default.nix
|
|
@ -1,28 +1,60 @@
|
|||
{
|
||||
stdenv,
|
||||
lib,
|
||||
bats,
|
||||
python3,
|
||||
python3Packages,
|
||||
shellcheck-minimal,
|
||||
shfmt,
|
||||
}:
|
||||
|
||||
let
|
||||
fs = lib.fileset;
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "mechanicaldiff";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./bin;
|
||||
src = fs.toSource {
|
||||
root = ./.;
|
||||
fileset = fs.unions [
|
||||
./.editorconfig
|
||||
./bin
|
||||
./test
|
||||
];
|
||||
};
|
||||
|
||||
buildInputs = [ python3 ];
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs .
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
|
||||
nativeCheckInputs = [ python3Packages.flake8 ];
|
||||
nativeCheckInputs = [
|
||||
(bats.withLibraries (p: [
|
||||
p.bats-assert
|
||||
p.bats-support
|
||||
p.bats-file
|
||||
]))
|
||||
python3Packages.flake8
|
||||
shellcheck-minimal
|
||||
shfmt
|
||||
];
|
||||
|
||||
checkPhase = ''
|
||||
flake8 mechanicaldiff.py
|
||||
runHook preCheck
|
||||
flake8 bin/mechanicaldiff.py
|
||||
shellcheck test/mechanicaldiff.bats
|
||||
shfmt -d test/mechanicaldiff.bats
|
||||
bats test
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp mechanicaldiff.py $out/bin/mechanicaldiff
|
||||
cp $src/bin/mechanicaldiff.py $out/bin/mechanicaldiff
|
||||
chmod +x $out/bin/mechanicaldiff
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue