Add vim-clipper to integration tests
authorGreg Hurrell <greg@hurrell.net>
Sun, 12 Jun 2016 22:31:02 +0000 (15:31 -0700)
committerGreg Hurrell <greg@hurrell.net>
Sun, 12 Jun 2016 22:31:02 +0000 (15:31 -0700)
bin/get
bin/put
tests/fixtures/integration/vim-clipper/golden/ast.golden [new file with mode: 0644]
tests/fixtures/integration/vim-clipper/golden/markdown.golden [new file with mode: 0644]
tests/fixtures/integration/vim-clipper/golden/plaintext.golden [new file with mode: 0644]
tests/fixtures/integration/vim-clipper/input/.gitignore [new file with mode: 0644]
tests/fixtures/integration/vim-clipper/input/LICENSE.txt [new file with mode: 0644]
tests/fixtures/integration/vim-clipper/input/README.txt [new symlink]
tests/fixtures/integration/vim-clipper/input/autoload/clipper/private.vim [new file with mode: 0644]
tests/fixtures/integration/vim-clipper/input/plugin/clipper.vim [new file with mode: 0644]

diff --git a/bin/get b/bin/get
index 8ed144736278c705f6dacf2581640280827875bb..bb5be75bfff9783ebf73cb5ea4c572fff05b87f7 100755 (executable)
--- a/bin/get
+++ b/bin/get
@@ -13,9 +13,10 @@ usage() {
   echo
   echo "  bin/get command-t   #"
   echo "  bin/get ferret      #"
-  echo "  bin/put pinnacle    # freshen a specific downstream"
-  echo "  bin/put scalpel     #"
+  echo "  bin/put pinnacle    #"
+  echo "  bin/put scalpel     # freshen a specific downstream"
   echo "  bin/put terminus    #"
+  echo "  bin/get vim-clipper #"
   echo "  bin/get vim-docvim  #"
   echo "  ---------------------------------------------------"
   echo "  bin/get all         # freshen all sources"
@@ -44,9 +45,10 @@ else
         update pinnacle
         update scalpel
         update terminus
+        update vim-clipper
         update vim-docvim
         ;;
-      command-t|ferret|pinnacle|scalpel|terminus|vim-docvim)
+      command-t|ferret|pinnacle|scalpel|terminus|vim-clipper|vim-docvim)
         update "$PROJECT"
         ;;
       *)
diff --git a/bin/put b/bin/put
index a819c03acdc142cdfc5df3448c93ae94078a5cac..399f009c44157d5fcd99850649b7d32cf0715888 100755 (executable)
--- a/bin/put
+++ b/bin/put
@@ -19,9 +19,10 @@ usage() {
   echo
   echo "  bin/put command-t   #"
   echo "  bin/put ferret      #"
-  echo "  bin/put pinnacle    # freshen a specific downstream"
-  echo "  bin/put scalpel     #"
+  echo "  bin/put pinnacle    #"
+  echo "  bin/put scalpel     # freshen a specific downstream"
   echo "  bin/put terminus    #"
+  echo "  bin/get vim-clipper #"
   echo "  bin/put vim-docvim  #"
   echo "  ---------------------------------------------------"
   echo "  bin/put all         # freshen all downstreams"
@@ -52,9 +53,10 @@ else
         update pinnacle
         update scalpel
         update terminus
+        update vim-clipper
         update vim-docvim
         ;;
-      command-t|ferret|pinnacle|scalpel|terminus|vim-docvim)
+      command-t|ferret|pinnacle|scalpel|terminus|vim-clipper|vim-docvim)
         update "$PROJECT"
         ;;
       *)
diff --git a/tests/fixtures/integration/vim-clipper/golden/ast.golden b/tests/fixtures/integration/vim-clipper/golden/ast.golden
new file mode 100644 (file)
index 0000000..a0f0d75
--- /dev/null
@@ -0,0 +1,57 @@
+Project
+  [ Project
+      [ Unit
+          [ FunctionDeclaration
+              { functionBang = True
+              , functionName = "clipper#private#clip"
+              , functionArguments = ArgumentList []
+              , functionAttributes = [ "abort" ]
+              , functionBody =
+                  [ GenericStatement "if executable('nc') == 1"
+                  , LetStatement
+                      { letLexpr = "l:address "
+                      , letValue = "get(g:, 'ClipperAddress', 'localhost')"
+                      }
+                  , LetStatement
+                      { letLexpr = "l:port "
+                      , letValue =
+                          "+(get(g:, 'ClipperPort', 8377)) \" Co-erce to number."
+                      }
+                  , GenericStatement "if l:port"
+                  , GenericStatement
+                      "call system('nc ' . l:address . ' ' . l:port, @0)"
+                  , GenericStatement "else"
+                  , GenericStatement "call system('nc -U ' . l:address, @0)"
+                  , GenericStatement "endif"
+                  , GenericStatement "else"
+                  , GenericStatement
+                      "echoerr 'Clipper: nc executable does not exist'"
+                  , GenericStatement "endif"
+                  ]
+              }
+          ]
+      , Unit
+          [ GenericStatement
+              "if exists('g:ClipperLoaded') || &compatible || v:version < 700"
+          , GenericStatement "finish"
+          , GenericStatement "endif"
+          , LetStatement { letLexpr = "g:ClipperLoaded" , letValue = "1" }
+          , LetStatement
+              { letLexpr = "s:cpoptions" , letValue = "&cpoptions" }
+          , GenericStatement "set cpoptions&vim"
+          , GenericStatement "command! Clip call clipper#private#clip()"
+          , LetStatement
+              { letLexpr = "s:map" , letValue = "get(g:, 'ClipperMap', 1)" }
+          , GenericStatement "if s:map"
+          , GenericStatement
+              "if !hasmapto('<Plug>(ClipperClip)') && maparg('<leader>y', 'n') ==# ''"
+          , GenericStatement "nmap <unique> <leader>y <Plug>(ClipperClip)"
+          , GenericStatement "endif"
+          , GenericStatement "endif"
+          , GenericStatement "nnoremap <Plug>(ClipperClip) :Clip<CR>"
+          , LetStatement
+              { letLexpr = "&cpoptions" , letValue = "s:cpoptions" }
+          , UnletStatement { unletBang = False , unletBody = "s:cpoptions" }
+          ]
+      ]
+  ]
diff --git a/tests/fixtures/integration/vim-clipper/golden/markdown.golden b/tests/fixtures/integration/vim-clipper/golden/markdown.golden
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/fixtures/integration/vim-clipper/golden/plaintext.golden b/tests/fixtures/integration/vim-clipper/golden/plaintext.golden
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/tests/fixtures/integration/vim-clipper/input/.gitignore b/tests/fixtures/integration/vim-clipper/input/.gitignore
new file mode 100644 (file)
index 0000000..20cb71e
--- /dev/null
@@ -0,0 +1 @@
+/*.zip
diff --git a/tests/fixtures/integration/vim-clipper/input/LICENSE.txt b/tests/fixtures/integration/vim-clipper/input/LICENSE.txt
new file mode 100644 (file)
index 0000000..3906829
--- /dev/null
@@ -0,0 +1,22 @@
+Copyright 2015-present Greg Hurrell. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+   this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/tests/fixtures/integration/vim-clipper/input/README.txt b/tests/fixtures/integration/vim-clipper/input/README.txt
new file mode 120000 (symlink)
index 0000000..ba6a2ea
--- /dev/null
@@ -0,0 +1 @@
+doc/clipper.txt
\ No newline at end of file
diff --git a/tests/fixtures/integration/vim-clipper/input/autoload/clipper/private.vim b/tests/fixtures/integration/vim-clipper/input/autoload/clipper/private.vim
new file mode 100644 (file)
index 0000000..bf6e395
--- /dev/null
@@ -0,0 +1,16 @@
+" Copyright 2015-present Greg Hurrell. All rights reserved.
+" Licensed under the terms of the BSD 2-clause license.
+
+function! clipper#private#clip() abort
+  if executable('nc') == 1
+    let l:address = get(g:, 'ClipperAddress', 'localhost')
+    let l:port = +(get(g:, 'ClipperPort', 8377)) " Co-erce to number.
+    if l:port
+      call system('nc ' . l:address . ' ' . l:port, @0)
+    else
+      call system('nc -U ' . l:address, @0)
+    endif
+  else
+    echoerr 'Clipper: nc executable does not exist'
+  endif
+endfunction
diff --git a/tests/fixtures/integration/vim-clipper/input/plugin/clipper.vim b/tests/fixtures/integration/vim-clipper/input/plugin/clipper.vim
new file mode 100644 (file)
index 0000000..e8bf0c5
--- /dev/null
@@ -0,0 +1,27 @@
+" Copyright 2015-present Greg Hurrell. All rights reserved.
+" Licensed under the terms of the BSD 2-clause license.
+
+" Provide users with means to prevent loading, as recommended in `:h
+" write-plugin`.
+if exists('g:ClipperLoaded') || &compatible || v:version < 700
+  finish
+endif
+let g:ClipperLoaded=1
+
+" Temporarily set 'cpoptions' to Vim default as per `:h use-cpo-save`.
+let s:cpoptions=&cpoptions
+set cpoptions&vim
+
+command! Clip call clipper#private#clip()
+
+let s:map=get(g:, 'ClipperMap', 1)
+if s:map
+  if !hasmapto('<Plug>(ClipperClip)') && maparg('<leader>y', 'n') ==# ''
+    nmap <unique> <leader>y <Plug>(ClipperClip)
+  endif
+endif
+nnoremap <Plug>(ClipperClip) :Clip<CR>
+
+" Restore 'cpoptions' to its former value.
+let &cpoptions=s:cpoptions
+unlet s:cpoptions