|
1 | 1 | local oil = require("oil") |
2 | 2 | local util = require("oil.util") |
| 3 | + |
| 4 | +local uv = vim.uv or vim.loop |
| 5 | + |
3 | 6 | describe("url", function() |
4 | 7 | it("get_url_for_path", function() |
5 | 8 | local cases = { |
6 | | - { "", "oil://" .. util.addslash(vim.fn.getcwd()) }, |
7 | | - { "term://~/oil.nvim//52953:/bin/sh", "oil://" .. vim.loop.os_homedir() .. "/oil.nvim/" }, |
8 | | - { "/foo/bar.txt", "oil:///foo/", "bar.txt" }, |
| 9 | + { "", "oil://" .. util.addslash(vim.fn.getcwd()), skip_on_windows = true }, |
| 10 | + { |
| 11 | + "term://~/oil.nvim//52953:/bin/sh", |
| 12 | + "oil://" .. vim.loop.os_homedir() .. "/oil.nvim/", |
| 13 | + skip_on_windows = true, |
| 14 | + }, |
| 15 | + { "/foo/bar.txt", "oil:///foo/", "bar.txt", skip_on_windows = true }, |
9 | 16 | { "oil:///foo/bar.txt", "oil:///foo/", "bar.txt" }, |
10 | 17 | { "oil:///", "oil:///" }, |
11 | 18 | { "oil-ssh://user@hostname:8888//bar.txt", "oil-ssh://user@hostname:8888//", "bar.txt" }, |
12 | 19 | { "oil-ssh://user@hostname:8888//", "oil-ssh://user@hostname:8888//" }, |
13 | 20 | } |
14 | 21 | for _, case in ipairs(cases) do |
15 | | - local input, expected, expected_basename = unpack(case) |
16 | | - local output, basename = oil.get_buffer_parent_url(input, true) |
17 | | - assert.equals(expected, output, string.format('Parent url for path "%s" failed', input)) |
18 | | - assert.equals( |
19 | | - expected_basename, |
20 | | - basename, |
21 | | - string.format('Basename for path "%s" failed', input) |
22 | | - ) |
| 22 | + local is_skip = case.skip_on_windows and uv.os_uname().version:match("Windows") |
| 23 | + if not is_skip then |
| 24 | + local input, expected, expected_basename = unpack(case) |
| 25 | + local output, basename = oil.get_buffer_parent_url(input, true) |
| 26 | + assert.equals(expected, output, string.format('Parent url for path "%s" failed', input)) |
| 27 | + assert.equals( |
| 28 | + expected_basename, |
| 29 | + basename, |
| 30 | + string.format('Basename for path "%s" failed', input) |
| 31 | + ) |
| 32 | + end |
23 | 33 | end |
24 | 34 | end) |
25 | 35 | end) |
0 commit comments