Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

jetbrains: add and improve tests

+141 -31
+1
nixos/tests/all-tests.nix
··· 672 672 jellyfin = handleTest ./jellyfin.nix { }; 673 673 jenkins = handleTest ./jenkins.nix { }; 674 674 jenkins-cli = handleTest ./jenkins-cli.nix { }; 675 + jetbrains = import ./jetbrains/default.nix { inherit runTest; }; 675 676 jibri = handleTest ./jibri.nix { }; 676 677 jirafeau = handleTest ./jirafeau.nix { }; 677 678 jitsi-meet = handleTest ./jitsi-meet.nix { };
+8
nixos/tests/jetbrains/default.nix
··· 1 + { 2 + runTest, 3 + }: 4 + { 5 + plugins-available = runTest { 6 + imports = [ ./plugins-available.nix ]; 7 + }; 8 + }
+41
nixos/tests/jetbrains/plugins-available.nix
··· 1 + { pkgs, ... }: 2 + 3 + # This test builds IDEA Community with some plugins and checks that they can be discovered by the IDE. 4 + let 5 + idea = ( 6 + pkgs.jetbrains.plugins.addPlugins pkgs.jetbrains.idea-community-src [ 7 + # This is a "normal plugin", it's output must be linked into /idea-community/plugins. 8 + "ideavim" 9 + # This is a plugin where the output contains a single JAR file. This JAR file needs to be linked directly in /idea-community/plugins. 10 + "wakatime" 11 + ] 12 + ); 13 + in 14 + { 15 + name = "jetbrains_build-ide-with-plugins"; 16 + meta.maintainers = pkgs.lib.teams.jetbrains.members; 17 + 18 + nodes = { 19 + server = 20 + { config, pkgs, ... }: 21 + { 22 + environment.systemPackages = [ 23 + idea 24 + ]; 25 + }; 26 + }; 27 + 28 + testScript = 29 + { ... }: 30 + '' 31 + with subtest("ensure normal plugin is available"): 32 + machine.succeed("find -L ${idea.out}/idea-community/plugins -type f -iname 'IdeaVIM-*.jar' | grep .") 33 + 34 + with subtest("ensure single JAR file plugin is available"): 35 + machine.succeed(""" 36 + PATH_TO_LINK=$(find ${idea.out}/idea-community/plugins -maxdepth 1 -type l -iname '*wakatime.jar' | grep .) 37 + test -f $(readlink $PATH_TO_LINK) 38 + """) 39 + ''; 40 + 41 + }
+2 -1
pkgs/applications/editors/jetbrains/bin/darwin.nix
··· 15 15 plugins ? [ ], 16 16 buildNumber, 17 17 ... 18 - }: 18 + }@args: 19 19 20 20 let 21 21 loname = lib.toLower productShort; ··· 29 29 ; 30 30 passthru.buildNumber = buildNumber; 31 31 passthru.product = product; 32 + passthru.tests = args.passthru.tests; 32 33 meta = meta // { 33 34 mainProgram = loname; 34 35 };
+2
pkgs/applications/editors/jetbrains/bin/linux.nix
··· 35 35 extraLdPath ? [ ], 36 36 extraWrapperArgs ? [ ], 37 37 extraBuildInputs ? [ ], 38 + ... 38 39 }@args: 39 40 40 41 let ··· 48 49 rec { 49 50 inherit pname version src; 50 51 passthru.buildNumber = buildNumber; 52 + passthru.tests = args.passthru.tests; 51 53 meta = args.meta // { 52 54 mainProgram = pname; 53 55 };
+8
pkgs/applications/editors/jetbrains/default.nix
··· 10 10 stdenv, 11 11 callPackage, 12 12 fetchurl, 13 + nixosTests, 13 14 14 15 jdk, 15 16 zlib, ··· 77 78 extraWrapperArgs ? [ ], 78 79 extraLdPath ? [ ], 79 80 extraBuildInputs ? [ ], 81 + extraTests ? [ ], 80 82 }: 81 83 mkJetBrainsProductCore { 82 84 inherit ··· 100 102 inherit (ideInfo."${pname}") wmClass product; 101 103 productShort = ideInfo."${pname}".productShort or ideInfo."${pname}".product; 102 104 meta = mkMeta ideInfo."${pname}".meta fromSource; 105 + passthru.tests = extraTests // { 106 + plugins = callPackage ./plugins/tests.nix { ideName = pname; }; 107 + }; 103 108 libdbm = 104 109 if ideInfo."${pname}".meta.isOpenSource then 105 110 communitySources."${pname}".libdbm ··· 273 278 pname = "idea-community"; 274 279 extraBuildInputs = [ stdenv.cc.cc ]; 275 280 fromSource = true; 281 + extraTests = { 282 + nixos-plugins-available = nixosTests.jetbrains.plugins-available; 283 + }; 276 284 }; 277 285 278 286 idea-community =
+70 -28
pkgs/applications/editors/jetbrains/plugins/tests.nix
··· 1 - { jetbrains, writeText }: 1 + { 2 + jetbrains, 3 + symlinkJoin, 4 + lib, 5 + # If not set, all IDEs are tested. 6 + ideName ? null, 7 + }: 8 + 9 + let 10 + 11 + # Known broken plugins, PLEASE remove entries here whenever possible. 12 + brokenPlugins = [ 13 + "github-copilot" # GitHub Copilot: https://github.com/NixOS/nixpkgs/issues/400317 14 + ]; 2 15 16 + ideNames = 17 + if ideName == null then 18 + with jetbrains; 19 + [ 20 + clion 21 + datagrip 22 + dataspell 23 + goland 24 + idea-community 25 + idea-ultimate 26 + mps 27 + phpstorm 28 + pycharm-community 29 + pycharm-professional 30 + rider 31 + ruby-mine 32 + rust-rover 33 + webstorm 34 + ] 35 + else 36 + [ (jetbrains.${ideName}) ]; 37 + in 3 38 { 4 39 # Check to see if the process for adding plugins is breaking anything, instead of the plugins themselves 5 - default = 40 + empty = 6 41 let 7 42 modify-ide = ide: jetbrains.plugins.addPlugins ide [ ]; 8 - ides = 9 - with jetbrains; 10 - map modify-ide [ 11 - clion 12 - datagrip 13 - dataspell 14 - goland 15 - idea-community 16 - idea-ultimate 17 - mps 18 - phpstorm 19 - pycharm-community 20 - pycharm-professional 21 - rider 22 - ruby-mine 23 - rust-rover 24 - webstorm 25 - ]; 26 - paths = builtins.concatStringsSep " " ides; 27 43 in 28 - writeText "jb-ides" paths; 44 + symlinkJoin { 45 + name = "jetbrains-test-plugins-empty"; 46 + paths = (map modify-ide ideNames); 47 + }; 29 48 30 - idea-ce-with-plugins = jetbrains.plugins.addPlugins jetbrains.idea-community [ 31 - "ideavim" 32 - "nixidea" 33 - # test JAR plugins 34 - "wakatime" 35 - ]; 49 + # Test all plugins. This will only build plugins compatible with the IDE and version. It will fail if the plugin is marked 50 + # as compatible, but the build version is somehow not in the "builds" map (as that would indicate that something with update_plugins.py went wrong). 51 + all = 52 + let 53 + pluginsJson = builtins.fromJSON (builtins.readFile ./plugins.json); 54 + pluginsFor = 55 + with lib.asserts; 56 + ide: 57 + builtins.map (plugin: plugin.name) ( 58 + builtins.filter ( 59 + plugin: 60 + ( 61 + # Plugin has to not be broken 62 + (!builtins.elem plugin.name brokenPlugins) 63 + # IDE has to be compatible 64 + && (builtins.elem ide.pname plugin.compatible) 65 + # Assert: The build number needs to be included (if marked compatible) 66 + && (assertMsg (builtins.elem ide.buildNumber (builtins.attrNames plugin.builds)) "For plugin ${plugin.name} no entry for IDE build ${ide.buildNumber} is defined, even though ${ide.pname} is on that build.") 67 + # The plugin has to exist for the build 68 + && (plugin.builds.${ide.buildNumber} != null) 69 + ) 70 + ) (builtins.attrValues pluginsJson.plugins) 71 + ); 72 + modify-ide = ide: jetbrains.plugins.addPlugins ide (pluginsFor ide); 73 + in 74 + symlinkJoin { 75 + name = "jetbrains-test-plugins-all"; 76 + paths = (map modify-ide ideNames); 77 + }; 36 78 }
+9 -2
pkgs/applications/editors/jetbrains/readme.md
··· 1 1 This directory contains the build expressions needed to build any of the jetbrains IDEs. 2 2 The jdk is in `pkgs/development/compilers/jetbrains-jdk`. 3 - To test the build process of every IDE (as well as the process for adding plugins), build `jetbrains.plugins.tests.default`. 3 + 4 + ## Tests: 5 + - To test the build process of every IDE (as well as the process for adding plugins), build `jetbrains.plugins.tests.empty`. 6 + - To test the build process with all plugins* supported by all IDEs, build `jetbrains.plugins.tests.all`. 7 + - To test only plugins for a specific IDE*, build `jetbrains.ide-name.tests.plugins.all`. 8 + - To test that plugins are correctly stored in the plugins directory run the NixOS test `nixosTests.jetbrains.plugins-available`. 9 + 10 + *: Plugins marked as broken in nixpkgs are skipped: When updating/fixing plugins, please check the `brokenPlugins` in `plugins/tests.nix` and update it if needed. 4 11 5 12 ## How to use plugins: 6 13 - Get the ide you want and call `jetbrains.plugins.addPlugins` with a list of plugins you want to add. 7 14 - The list of plugins can be a list of ids or names (as in `plugins/plugins.json`) 8 15 - Example: `jetbrains.plugins.addPlugins jetbrains.pycharm-professional [ "nixidea" ]` 9 - - The list can also contain a drv giving a `.jar` or `.zip` (this is how you use a plugin not added to nixpkgs) 16 + - The list can also contain drvs giving the directory contents of the plugin (this is how you use a plugin not added to nixpkgs) or a single `.jar` (executable). For an example, look at the implementation of `fetchPluginSrc` in `plugins/default.nix`. 10 17 11 18 ### How to add a new plugin to nixpkgs 12 19 - Find the page for the plugin on https://plugins.jetbrains.com