beets: Run tests for external plugins

In order to run the tests for the external plugins of beets, we need to
have beets itself as a dependency. So in order to do that, we now pass
beets without plugins and tests to the nativeBuildInputs of the plugins
so that we can run them.

As soon as the plugins are built they become part of the final beets,
which also has tests enabled, so disabling the tests for beets
derivation that is used for external plugin tests is a non-issue here
because they're going to be executed anyway.

Enabling tests for the alternatives plugin is pretty straightforward,
but in order to run tests for the copyartifacts plugin, we need to bump
the source code to the latest Git master.

The reason for this is that the version that was in use until now
required to have the beets source directory alongside of the
copyartifacts source code, but we already have beets available as a
normal dependency.

Updating copyartifacts to latest master largely consists of unit test
changes and a few Python 3 compatibility changes. However, one change
has the biggest stat, which is
sbarakat/beets-copyartifacts@1a0c281da0be7251f414397960a83d60dc3a1520.

Fortunately, the last change is just moving the implementation to a
newer API from upstream beets and by the looks of the implementation it
seems to break support for moving files. However, reverting this commit
also reveals that moving files was already broken before, so it wouldn't
matter much whether we have this version bump or not.

Tested with the following command:

nix-build -E '(import ./. {}).beets.override {
enableAlternatives = true;
enableCopyArtifacts = true;
}'

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Cc: @domenkozar, @pjones, @Profpatsch, @michalrus

aszlig 40b76c88 bd2aeb48

+45 -20
+5 -1
pkgs/tools/audio/beets/alternatives-plugin.nix
··· 1 - { stdenv, fetchFromGitHub, pythonPackages }: 1 + { stdenv, fetchFromGitHub, beets, pythonPackages }: 2 2 3 3 pythonPackages.buildPythonApplication rec { 4 4 name = "beets-alternatives-${version}"; ··· 15 15 sed -i -e '/install_requires/,/\]/{/beets/d}' setup.py 16 16 sed -i -e '/test_suite/d' setup.py 17 17 ''; 18 + 19 + nativeBuildInputs = [ beets pythonPackages.nose ]; 20 + 21 + checkPhase = "nosetests"; 18 22 19 23 propagatedBuildInputs = with pythonPackages; [ futures ]; 20 24
+12 -3
pkgs/tools/audio/beets/copyartifacts-plugin.nix
··· 1 - { stdenv, fetchFromGitHub, pythonPackages }: 1 + { stdenv, fetchFromGitHub, beets, pythonPackages, glibcLocales }: 2 2 3 3 pythonPackages.buildPythonApplication rec { 4 4 name = "beets-copyartifacts"; ··· 6 6 src = fetchFromGitHub { 7 7 repo = "beets-copyartifacts"; 8 8 owner = "sbarakat"; 9 - rev = "dac4a1605111e24bb5b498aa84cead7c87480834"; 10 - sha256 = "0p5cskfgqinzh48a58hw56f96g9lar3k3g2p0ip1m9kawzf6axng"; 9 + rev = "4a5d347c858d25641c8a0eb7d8cb1a2cac10252a"; 10 + sha256 = "0bn6fci480ilghrdhpsjxxq29dxgni22sv1qalz770xy130g1zk3"; 11 11 }; 12 12 13 13 postPatch = '' 14 14 sed -i -e '/install_requires/,/\]/{/beets/d}' setup.py 15 15 sed -i -e '/namespace_packages/d' setup.py 16 16 printf 'from pkgutil import extend_path\n__path__ = extend_path(__path__, __name__)\n' >beetsplug/__init__.py 17 + 18 + # Skip test which is already failing upstream. 19 + sed -i -e '1i import unittest' \ 20 + -e 's/\(^ *\)# failing/\1@unittest.skip/' \ 21 + tests/test_reimport.py 17 22 ''; 23 + 24 + nativeBuildInputs = [ beets pythonPackages.nose glibcLocales ]; 25 + 26 + checkPhase = "LANG=en_US.UTF-8 nosetests"; 18 27 19 28 meta = { 20 29 description = "Beets plugin to move non-music files during the import process";
+28 -16
pkgs/tools/audio/beets/default.nix
··· 1 1 { stdenv, fetchFromGitHub, writeScript, glibcLocales, diffPlugins 2 2 , pythonPackages, imagemagick, gobjectIntrospection, gst_all_1 3 3 4 + # Attributes needed for tests of the external plugins 5 + , callPackage, beets 6 + 4 7 , enableAcousticbrainz ? true 5 8 , enableAcoustid ? true 6 9 , enableBadfiles ? true, flac ? null, mp3val ? null ··· 77 80 testShell = "${bashInteractive}/bin/bash --norc"; 78 81 completion = "${bash-completion}/share/bash-completion/bash_completion"; 79 82 83 + # This is a stripped down beets for testing of the external plugins. 84 + externalTestArgs.beets = (beets.override { 85 + enableAlternatives = false; 86 + enableCopyArtifacts = false; 87 + }).overrideAttrs (stdenv.lib.const { 88 + doInstallCheck = false; 89 + }); 90 + 91 + plugins = { 92 + alternatives = callPackage ./alternatives-plugin.nix externalTestArgs; 93 + copyartifacts = callPackage ./copyartifacts-plugin.nix externalTestArgs; 94 + }; 95 + 80 96 in pythonPackages.buildPythonApplication rec { 81 97 name = "beets-${version}"; 82 98 version = "1.4.5"; ··· 101 117 pythonPackages.gst-python 102 118 pythonPackages.pygobject3 103 119 gobjectIntrospection 104 - ] ++ optional enableAcoustid pythonPackages.pyacoustid 120 + ] ++ optional enableAcoustid pythonPackages.pyacoustid 105 121 ++ optional (enableFetchart 106 122 || enableEmbyupdate 107 123 || enableKodiupdate 108 124 || enableAcousticbrainz) 109 - pythonPackages.requests 110 - ++ optional enableConvert ffmpeg 111 - ++ optional enableDiscogs pythonPackages.discogs_client 112 - ++ optional enableGmusic pythonPackages.gmusicapi 113 - ++ optional enableKeyfinder keyfinder-cli 114 - ++ optional enableLastfm pythonPackages.pylast 115 - ++ optional enableMpd pythonPackages.mpd2 116 - ++ optional enableThumbnails pythonPackages.pyxdg 117 - ++ optional enableWeb pythonPackages.flask 118 - ++ optional enableAlternatives (import ./alternatives-plugin.nix { 119 - inherit stdenv pythonPackages fetchFromGitHub; 120 - }) 121 - ++ optional enableCopyArtifacts (import ./copyartifacts-plugin.nix { 122 - inherit stdenv pythonPackages fetchFromGitHub; 123 - }); 125 + pythonPackages.requests 126 + ++ optional enableConvert ffmpeg 127 + ++ optional enableDiscogs pythonPackages.discogs_client 128 + ++ optional enableGmusic pythonPackages.gmusicapi 129 + ++ optional enableKeyfinder keyfinder-cli 130 + ++ optional enableLastfm pythonPackages.pylast 131 + ++ optional enableMpd pythonPackages.mpd2 132 + ++ optional enableThumbnails pythonPackages.pyxdg 133 + ++ optional enableWeb pythonPackages.flask 134 + ++ optional enableAlternatives plugins.alternatives 135 + ++ optional enableCopyArtifacts plugins.copyartifacts; 124 136 125 137 buildInputs = with pythonPackages; [ 126 138 beautifulsoup4