@@ -1768,13 +1768,38 @@ pub fn generate(contents: &str, opts: ParserOpts) -> Result<Output, (Output, Str
17681768
17691769#[ cfg( test) ]
17701770mod test {
1771- use std:: { fs:: File , io:: Write } ;
1771+ use std:: { fs:: File , io:: Write , process :: Command } ;
17721772
17731773 use pretty_assertions:: assert_eq;
17741774
17751775 use super :: * ;
17761776 use crate :: test_harness:: { exec_busted, exec_lua} ;
17771777
1778+ fn ensure_plenary_downloaded ( ) {
1779+ static DOWNLOADED : std:: sync:: Once = std:: sync:: Once :: new ( ) ;
1780+ // Download and install Plenary if needed
1781+ DOWNLOADED . call_once ( || {
1782+ let path = std:: env:: var ( "HOME" ) . expect ( "to have a home var" )
1783+ + "/.local/share/nvim/site/pack/vendor/start/plenary.nvim" ;
1784+
1785+ if Path :: new ( & path) . exists ( ) {
1786+ return ;
1787+ }
1788+
1789+ // Download git repo
1790+ let status = Command :: new ( "git" )
1791+ . arg ( "clone" )
1792+ . arg ( "--depth" )
1793+ . arg ( "1" )
1794+ . arg ( "https://github.com/nvim-lua/plenary.nvim" )
1795+ . arg ( path)
1796+ . status ( )
1797+ . expect ( "failed to execute git command" ) ;
1798+
1799+ assert ! ( status. success( ) ) ;
1800+ } ) ;
1801+ }
1802+
17781803 macro_rules! snapshot {
17791804 ( $name: tt, $path: tt) => {
17801805 #[ test]
@@ -1802,6 +1827,8 @@ mod test {
18021827 ( $name: tt, $path: tt) => {
18031828 #[ test]
18041829 fn $name( ) {
1830+ ensure_plenary_downloaded( ) ;
1831+
18051832 let vim_contents = include_str!( $path) ;
18061833 let lua_contents = generate(
18071834 vim_contents,
0 commit comments