testing around with proot
This commit is contained in:
parent
dc68851233
commit
9b17ba5fee
6 changed files with 36 additions and 5 deletions
|
@ -8,5 +8,5 @@ charset = utf-8
|
|||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.nix]
|
||||
[*.{nix,sh}]
|
||||
indent_size = 2
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
garbageProj = import ./Cargo.nix { inherit pkgs; };
|
||||
garbageProjDebug = import ./Cargo.nix { inherit pkgs; release = false; };
|
||||
garbage = pkgs.lib.recursiveUpdate garbageProj.rootCrate.build {
|
||||
meta = {
|
||||
description = "CLI tool to interact with the FreeDesktop trash API.";
|
||||
|
@ -16,7 +17,7 @@
|
|||
};
|
||||
flakePkgs = {
|
||||
inherit garbage;
|
||||
tests = pkgs.callPackage ./tests { inherit garbage; };
|
||||
tests = pkgs.callPackage ./tests { garbage = garbageProjDebug.rootCrate.build; };
|
||||
};
|
||||
in
|
||||
rec {
|
||||
|
|
1
tests/.common.sh
Normal file
1
tests/.common.sh
Normal file
|
@ -0,0 +1 @@
|
|||
export RUST_BACKTRACE=1
|
|
@ -1,4 +1,4 @@
|
|||
{ stdenv, garbage }:
|
||||
{ stdenv, garbage, pkgs }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "garbage-tests";
|
||||
|
@ -7,7 +7,8 @@ stdenv.mkDerivation {
|
|||
installPhase = "mkdir -p $out";
|
||||
doCheck = true;
|
||||
|
||||
garbage = "${garbage}/bin/garbage";
|
||||
buildInputs = with pkgs; [ garbage proot mktemp mount which bash ];
|
||||
|
||||
checkPhase = ''
|
||||
find . -executable -name "*.sh" | xargs bash
|
||||
'';
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
source .common.sh
|
||||
|
||||
filename=$'\377'$'\017'$'\224'$'\353'\`$'\001'
|
||||
touch $filename
|
||||
|
||||
$garbage put $filename
|
||||
garbage put $filename
|
||||
|
|
27
tests/issue-4-restore-current-partition.sh
Executable file
27
tests/issue-4-restore-current-partition.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
source .common.sh
|
||||
|
||||
garbage=$(which garbage)
|
||||
tmproot=$(mktemp -d)
|
||||
mkdir -p $tmproot/{mnt,home}
|
||||
echo "delete" > $tmproot/mnt/mnt-delete
|
||||
echo "delete" > touch $tmproot/home/home-delete
|
||||
|
||||
cat > $tmproot/run.sh << EOF
|
||||
cd /mnt
|
||||
ls -al
|
||||
cat mnt-delete
|
||||
garbage put mnt-delete
|
||||
garbage list
|
||||
EOF
|
||||
chmod +x $tmproot/run.sh
|
||||
|
||||
proot \
|
||||
-0 \
|
||||
-r $tmproot \
|
||||
-b /bin \
|
||||
-b /nix \
|
||||
-w / \
|
||||
--kill-on-exit \
|
||||
"/run.sh"
|
||||
|
Loading…
Reference in a new issue