summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2021-06-07 18:48:37 +0000
committerGitHub <noreply@github.com>2021-06-07 18:48:37 +0000
commit5b7fbb07b8827bcc279522fe5b8806ef59f433f3 (patch)
tree0b5722da489cdee4f48d9ca2e9843ff45248fea0 /pkgs/test
parentd3f2c41b267151a0ab819429d1ce7cfa7ff8a2fb (diff)
parent1593cddce5e125b2cf7d9043671e489f36e8ae4c (diff)
downloadnixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.tar
nixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.tar.gz
nixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.tar.bz2
nixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.tar.lz
nixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.tar.xz
nixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.tar.zst
nixpkgs-5b7fbb07b8827bcc279522fe5b8806ef59f433f3.zip
Merge staging-next into staging
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/vim/default.nix66
-rw-r--r--pkgs/test/vim/neovim-override.vim7
2 files changed, 67 insertions, 6 deletions
diff --git a/pkgs/test/vim/default.nix b/pkgs/test/vim/default.nix
index c809940fc4c..3bdc3234134 100644
--- a/pkgs/test/vim/default.nix
+++ b/pkgs/test/vim/default.nix
@@ -1,9 +1,12 @@
 { vimUtils, vim_configurable, writeText, neovim, vimPlugins
 , lib, fetchFromGitHub, neovimUtils, wrapNeovimUnstable
 , neovim-unwrapped
+, fetchFromGitLab
+, pkgs
 }:
 let
   inherit (vimUtils) buildVimPluginFrom2Nix;
+  inherit (neovimUtils) makeNeovimConfig;
 
   packages.myVimPackage.start = with vimPlugins; [ vim-nix ];
 
@@ -16,27 +19,55 @@ let
     }
   ];
 
-  nvimConfNix = neovimUtils.makeNeovimConfig {
+  nvimConfNix = makeNeovimConfig {
     inherit plugins;
     customRC = ''
       " just a comment
     '';
   };
 
-  wrapNeovim = suffix: config:
+  nvimConfDontWrap = makeNeovimConfig {
+    inherit plugins;
+    customRC = ''
+      " just a comment
+    '';
+  };
+
+  wrapNeovim2 = suffix: config:
     wrapNeovimUnstable neovim-unwrapped (config // {
       extraName = suffix;
-      wrapRc = true;
     });
+
+  nmt = fetchFromGitLab {
+    owner = "rycee";
+    repo = "nmt";
+    rev = "d2cc8c1042b1c2511f68f40e2790a8c0e29eeb42";
+    sha256 = "1ykcvyx82nhdq167kbnpgwkgjib8ii7c92y3427v986n2s5lsskc";
+  };
+
+  runTest = neovim-drv: buildCommand:
+    pkgs.runCommandLocal "test-${neovim-drv.name}" ({
+      nativeBuildInputs = [ ];
+      meta.platforms = neovim-drv.meta.platforms;
+    }) (''
+      source ${nmt}/bash-lib/assertions.sh
+      vimrc="${writeText "init.vim" neovim-drv.initRc}"
+      vimrcGeneric="$out/patched.vim"
+      mkdir $out
+      ${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc" > "$vimrcGeneric"
+    '' + buildCommand);
+
 in
-{
+  pkgs.recurseIntoAttrs (
+rec {
   vim_empty_config = vimUtils.vimrcFile { beforePlugins = ""; customRC = ""; };
 
   ### neovim tests
   ##################
-  nvim_with_plugins = wrapNeovim "-with-plugins" nvimConfNix;
+  nvim_with_plugins = wrapNeovim2 "-with-plugins" nvimConfNix;
 
   nvim_via_override = neovim.override {
+    extraName = "-via-override";
     configure = {
       packages.foo.start = [ vimPlugins.ale ];
       customRC = ''
@@ -45,6 +76,29 @@ in
     };
   };
 
+
+  # nixpkgs should detect that no wrapping is necessary
+  nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimConfNix;
+
+
+  # this will generate a neovimRc content but we disable wrapping
+  nvimDontWrap = wrapNeovim2 "-dont-wrap" (makeNeovimConfig {
+    wrapRc = false;
+    customRC = ''
+      " this shouldn't trigger the creation of an init.vim
+    '';
+  });
+
+  nvim_dontwrap-test = runTest nvimDontWrap ''
+      ! grep "-u" ${nvimDontWrap}/bin/nvim
+  '';
+
+  nvim_via_override-test = runTest nvim_via_override ''
+      assertFileContent \
+        "$vimrcGeneric" \
+        "${./neovim-override.vim}"
+  '';
+
   ### vim tests
   ##################
   vim_with_vim2nix = vim_configurable.customize {
@@ -107,4 +161,4 @@ in
   test_nvim_with_remote_plugin = neovim.override {
     configure.pathogen.pluginNames = with vimPlugins; [ deoplete-nvim ];
   };
-}
+})
diff --git a/pkgs/test/vim/neovim-override.vim b/pkgs/test/vim/neovim-override.vim
new file mode 100644
index 00000000000..34a1a8f1f43
--- /dev/null
+++ b/pkgs/test/vim/neovim-override.vim
@@ -0,0 +1,7 @@
+" configuration generated by NIX
+set nocompatible
+
+set packpath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir
+set runtimepath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir
+
+:help ale