From 2b133101cf67b523c2503ef715dfb9ebfa732da2 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius Date: Mon, 18 Sep 2017 21:06:55 +0300 Subject: win: vim_FullName(): force backslashes #7287 - Replace obvious cases of '/' literal with PATHSEP. (There are still some remaining cases that need closer inspection.) - Fixup tests: ui/screen_basic closes #7117 ref https://github.com/neovim/neovim/issues/2471#issuecomment-271193714 --- test/functional/core/path_spec.lua | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/functional/core/path_spec.lua (limited to 'test/functional/core/path_spec.lua') diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua new file mode 100644 index 0000000000..44e69fff7b --- /dev/null +++ b/test/functional/core/path_spec.lua @@ -0,0 +1,61 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local eq = helpers.eq +local eval = helpers.eval +local get_pathsep = helpers.get_pathsep +local command = helpers.command + +describe("'%:p' expanding", function() + local pathsep + local targetdir + local expected_path + + local function get_full_path() + return eval('expand("%:p")') + end + + local function join_path(...) + return table.concat({...}, pathsep) + end + + before_each(function() + clear() + pathsep = get_pathsep() + targetdir = join_path('test', 'functional', 'fixtures') + clear(join_path(targetdir, 'tty-test.c')) + expected_path = get_full_path() + end) + + it('given a relative path with current directory in the middle #7117', function() + clear(join_path(targetdir, '.', 'tty-test.c')) + eq(expected_path, get_full_path()) + end) + + it('given a relative path with current directory #7117', function() + clear(join_path('.', targetdir, 'tty-test.c')) + eq(expected_path, get_full_path()) + end) + + it('given a relative path with current directory to a file when changing directory #7117', function() + clear(join_path('.', targetdir, 'tty-test.c')) + command('cd test') + eq(expected_path, get_full_path()) + end) + + it('given a relative path with directory up the tree to a file #7117', function() + clear(join_path(targetdir, '..', 'fixtures', 'tty-test.c')) + eq(expected_path, get_full_path()) + end) + + it('given a different starting directory and a relative path with directory up the tree #7117', function() + command('cd test') + command('e ' .. join_path('..', targetdir, 'tty-test.c')) + eq(expected_path, get_full_path()) + end) + + it('given a different starting directory and a relative path with current directory and up the tree #7117', function() + command('cd test') + command('e ' .. join_path('.', '..', targetdir, 'tty-test.c')) + eq(expected_path, get_full_path()) + end) +end) -- cgit From 6f7754dfa0c6a9ec2a1e7db3685ffd41b207b882 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Oct 2017 00:24:19 +0200 Subject: test: avoid extra clear() calls also: various other cleanup --- test/functional/core/path_spec.lua | 53 +++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 29 deletions(-) (limited to 'test/functional/core/path_spec.lua') diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua index 44e69fff7b..669bc99136 100644 --- a/test/functional/core/path_spec.lua +++ b/test/functional/core/path_spec.lua @@ -2,60 +2,55 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local eq = helpers.eq local eval = helpers.eval -local get_pathsep = helpers.get_pathsep local command = helpers.command +local iswin = helpers.iswin -describe("'%:p' expanding", function() - local pathsep +describe('path collapse', function() local targetdir local expected_path - local function get_full_path() - return eval('expand("%:p")') - end - local function join_path(...) + local pathsep = (iswin() and '\\' or '/') return table.concat({...}, pathsep) end before_each(function() - clear() - pathsep = get_pathsep() targetdir = join_path('test', 'functional', 'fixtures') - clear(join_path(targetdir, 'tty-test.c')) - expected_path = get_full_path() + clear() + command('edit '..join_path(targetdir, 'tty-test.c')) + expected_path = eval('expand("%:p")') end) - it('given a relative path with current directory in the middle #7117', function() - clear(join_path(targetdir, '.', 'tty-test.c')) - eq(expected_path, get_full_path()) + it('with /./ segment #7117', function() + command('edit '..join_path(targetdir, '.', 'tty-test.c')) + eq(expected_path, eval('expand("%:p")')) end) - it('given a relative path with current directory #7117', function() - clear(join_path('.', targetdir, 'tty-test.c')) - eq(expected_path, get_full_path()) + it('with ./ prefix #7117', function() + command('edit '..join_path('.', targetdir, 'tty-test.c')) + eq(expected_path, eval('expand("%:p")')) end) - it('given a relative path with current directory to a file when changing directory #7117', function() - clear(join_path('.', targetdir, 'tty-test.c')) + it('with ./ prefix, after directory change #7117', function() + command('edit '..join_path('.', targetdir, 'tty-test.c')) command('cd test') - eq(expected_path, get_full_path()) + eq(expected_path, eval('expand("%:p")')) end) - it('given a relative path with directory up the tree to a file #7117', function() - clear(join_path(targetdir, '..', 'fixtures', 'tty-test.c')) - eq(expected_path, get_full_path()) + it('with /../ segment #7117', function() + command('edit '..join_path(targetdir, '..', 'fixtures', 'tty-test.c')) + eq(expected_path, eval('expand("%:p")')) end) - it('given a different starting directory and a relative path with directory up the tree #7117', function() + it('with ../ and different starting directory #7117', function() command('cd test') - command('e ' .. join_path('..', targetdir, 'tty-test.c')) - eq(expected_path, get_full_path()) + command('edit '..join_path('..', targetdir, 'tty-test.c')) + eq(expected_path, eval('expand("%:p")')) end) - it('given a different starting directory and a relative path with current directory and up the tree #7117', function() + it('with ./../ and different starting directory #7117', function() command('cd test') - command('e ' .. join_path('.', '..', targetdir, 'tty-test.c')) - eq(expected_path, get_full_path()) + command('edit '..join_path('.', '..', targetdir, 'tty-test.c')) + eq(expected_path, eval('expand("%:p")')) end) end) -- cgit