beets{,-unstable}: use pytestCheckHook; small reformattings

This commit is contained in:
Doron Behar 2023-10-26 23:25:39 +03:00
parent 377a39f0a2
commit fa95aced90

View File

@ -93,24 +93,6 @@ python3Packages.buildPythonApplication {
cp extra/_beet $out/share/zsh/site-functions/ cp extra/_beet $out/share/zsh/site-functions/
''; '';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
tmphome="$(mktemp -d)"
EDITOR="${writeScript "beetconfig.sh" ''
#!${runtimeShell}
cat > "$1" <<CFG
plugins: ${lib.concatStringsSep " " (attrNames enabledPlugins)}
CFG
''}" HOME="$tmphome" "$out/bin/beet" config -e
EDITOR=true HOME="$tmphome" "$out/bin/beet" config -e
runHook postInstallCheck
'';
makeWrapperArgs = [ makeWrapperArgs = [
"--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\"" "--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\""
"--set GST_PLUGIN_SYSTEM_PATH_1_0 \"$GST_PLUGIN_SYSTEM_PATH_1_0\"" "--set GST_PLUGIN_SYSTEM_PATH_1_0 \"$GST_PLUGIN_SYSTEM_PATH_1_0\""
@ -118,7 +100,7 @@ python3Packages.buildPythonApplication {
]; ];
nativeCheckInputs = with python3Packages; [ nativeCheckInputs = with python3Packages; [
pytest pytestCheckHook
mock mock
rarfile rarfile
responses responses
@ -126,9 +108,8 @@ python3Packages.buildPythonApplication {
disabledTestPaths = lib.flatten (attrValues (lib.mapAttrs (n: v: v.testPaths ++ [ "test/test_${n}.py" ]) disabledPlugins)); disabledTestPaths = lib.flatten (attrValues (lib.mapAttrs (n: v: v.testPaths ++ [ "test/test_${n}.py" ]) disabledPlugins));
checkPhase = '' # Perform extra "sanity checks", before running pytest tests.
runHook preCheck preCheck = ''
# Check for undefined plugins # Check for undefined plugins
find beetsplug -mindepth 1 \ find beetsplug -mindepth 1 \
\! -path 'beetsplug/__init__.py' -a \ \! -path 'beetsplug/__init__.py' -a \
@ -140,19 +121,13 @@ python3Packages.buildPythonApplication {
export BEETS_TEST_SHELL="${bashInteractive}/bin/bash --norc" export BEETS_TEST_SHELL="${bashInteractive}/bin/bash --norc"
export HOME="$(mktemp -d)" export HOME="$(mktemp -d)"
args=" -m pytest -r fEs" env EDITOR="${writeScript "beetconfig.sh" ''
eval "disabledTestPaths=($disabledTestPaths)" #!${runtimeShell}
for path in ''${disabledTestPaths[@]}; do cat > "$1" <<CFG
if [ -e "$path" ]; then plugins: ${lib.concatStringsSep " " (attrNames enabledPlugins)}
args+=" --ignore $path" CFG
else ''}" "$out/bin/beet" config -e
echo "Skipping non-existent test path '$path'" env EDITOR=true "$out/bin/beet" config -e
fi
done
python $args
runHook postCheck
''; '';
@ -160,19 +135,17 @@ python3Packages.buildPythonApplication {
passthru.tests.gstreamer = runCommand "beets-gstreamer-test" { passthru.tests.gstreamer = runCommand "beets-gstreamer-test" {
meta.timeout = 60; meta.timeout = 60;
} } ''
'' set -euo pipefail
set -euo pipefail export HOME=$(mktemp -d)
export HOME=$(mktemp -d) mkdir $out
mkdir $out
cat << EOF > $out/config.yaml cat << EOF > $out/config.yaml
replaygain: replaygain:
backend: gstreamer backend: gstreamer
EOF EOF
echo $out/config.yaml ${beets}/bin/beet -c $out/config.yaml > /dev/null
${beets}/bin/beet -c $out/config.yaml > /dev/null
''; '';
meta = with lib; { meta = with lib; {