diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-24 16:30:36 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-24 16:30:36 +0100 |
commit | 753885b6c5b9021184daa94d32fd8bf025f1b488 (patch) | |
tree | d0d9e106e111e6d1bf3f200ca83a4b0a3fad7ae0 /src/testdir/test_vim9_import.vim | |
parent | f5240b96f721b08d703340ff0b2e67b79fb8b821 (diff) |
patch 9.0.0253: a symlink to an autoload script results in two entriesv9.0.0253
Problem: A symlink to an autoload script results in two entries in the list
of scripts, items expected in one are actually in the other.
Solution: Have one script item refer to the actually sourced one.
(closes #10960)
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 4cc53b2c26..5c14b0527b 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -2906,5 +2906,50 @@ def Test_vim9_autoload_error() v9.CheckScriptFailure(lines, 'E461: Illegal variable name: foo#bar', 2) enddef +def Test_vim9_import_symlink() + if !has('unix') + CheckUnix + else + mkdir('Xto/plugin', 'p') + var lines =<< trim END + vim9script + import autoload 'bar.vim' + g:resultFunc = bar.Func() + g:resultValue = bar.value + END + writefile(lines, 'Xto/plugin/foo.vim') + + mkdir('Xto/autoload', 'p') + lines =<< trim END + vim9script + export def Func(): string + return 'func' + enddef + export var value = 'val' + END + writefile(lines, 'Xto/autoload/bar.vim') + + var save_rtp = &rtp + &rtp = getcwd() .. '/Xfrom' + system('ln -s ' .. getcwd() .. '/Xto Xfrom') + + source Xfrom/plugin/foo.vim + assert_equal('func', g:resultFunc) + assert_equal('val', g:resultValue) + + var infoTo = getscriptinfo()->filter((_, v) => v.name =~ 'Xto/autoload/bar') + var infoFrom = getscriptinfo()->filter((_, v) => v.name =~ 'Xfrom/autoload/bar') + assert_equal(1, len(infoTo)) + assert_equal(1, len(infoFrom)) + assert_equal(infoTo[0].sid, infoFrom[0].sourced) + + unlet g:resultFunc + unlet g:resultValue + &rtp = save_rtp + delete('Xto', 'rf') + delete('Xfrom', 'rf') + endif +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |