|
1 | | -require("plenary.async").tests.add_to_env() |
2 | | -local fs = require("oil.fs") |
3 | | - |
4 | | -local function set_env_windows() |
5 | | - fs.is_windows = true |
6 | | - fs.is_mac = false |
7 | | - fs.is_linux = false |
8 | | - fs.sep = "\\" |
9 | | -end |
10 | | - |
11 | | -local function set_env_linux() |
12 | | - fs.is_windows = false |
13 | | - fs.is_mac = false |
14 | | - fs.is_linux = true |
15 | | - fs.sep = "/" |
16 | | -end |
17 | | - |
18 | | -a.describe("File system", function() |
19 | | - after_each(function() |
20 | | - fs._initialize_environment() |
21 | | - end) |
22 | | - |
23 | | - a.it("converts linux path to posix", function() |
24 | | - set_env_linux() |
25 | | - assert.equals("/a/b/c", fs.os_to_posix_path("/a/b/c")) |
26 | | - end) |
27 | | - |
28 | | - a.it("converts Windows local path to posix", function() |
29 | | - set_env_windows() |
30 | | - assert.equals("/C/a/b/c", fs.os_to_posix_path("C:\\a\\b\\c")) |
31 | | - end) |
32 | | - |
33 | | - a.it("converts Windows UNC path to posix", function() |
34 | | - set_env_windows() |
35 | | - assert.equals("//a/b/c", fs.os_to_posix_path("\\\\a\\b\\c")) |
36 | | - end) |
37 | | - |
38 | | - a.it("converts posix to linux path", function() |
39 | | - set_env_linux() |
40 | | - assert.equals("/a/b/c", fs.posix_to_os_path("/a/b/c")) |
41 | | - end) |
42 | | - |
43 | | - a.it("converts posix to Windows local path", function() |
44 | | - set_env_windows() |
45 | | - assert.equals("C:\\a\\b\\c", fs.posix_to_os_path("/C/a/b/c")) |
46 | | - end) |
47 | | - |
48 | | - a.it("converts posix to Windows UNC path", function() |
49 | | - set_env_windows() |
50 | | - assert.equals("\\\\a\\b\\c", fs.posix_to_os_path("//a/b/c")) |
51 | | - end) |
52 | | -end) |
| 1 | +require("plenary.async").tests.add_to_env() |
| 2 | +local fs = require("oil.fs") |
| 3 | + |
| 4 | +local function set_env_windows() |
| 5 | + fs.is_windows = true |
| 6 | + fs.is_mac = false |
| 7 | + fs.is_linux = false |
| 8 | + fs.sep = "\\" |
| 9 | +end |
| 10 | + |
| 11 | +local function set_env_linux() |
| 12 | + fs.is_windows = false |
| 13 | + fs.is_mac = false |
| 14 | + fs.is_linux = true |
| 15 | + fs.sep = "/" |
| 16 | +end |
| 17 | + |
| 18 | +a.describe("File system", function() |
| 19 | + after_each(function() |
| 20 | + fs._initialize_environment() |
| 21 | + end) |
| 22 | + |
| 23 | + a.it("converts linux path to posix", function() |
| 24 | + set_env_linux() |
| 25 | + assert.equals("/a/b/c", fs.os_to_posix_path("/a/b/c")) |
| 26 | + end) |
| 27 | + |
| 28 | + a.it("converts Windows local path to posix", function() |
| 29 | + set_env_windows() |
| 30 | + assert.equals("/C/a/b/c", fs.os_to_posix_path("C:\\a\\b\\c")) |
| 31 | + end) |
| 32 | + |
| 33 | + a.it("converts Windows UNC path to posix", function() |
| 34 | + set_env_windows() |
| 35 | + assert.equals("//a/b/c", fs.os_to_posix_path("\\\\a\\b\\c")) |
| 36 | + end) |
| 37 | + |
| 38 | + a.it("converts posix to linux path", function() |
| 39 | + set_env_linux() |
| 40 | + assert.equals("/a/b/c", fs.posix_to_os_path("/a/b/c")) |
| 41 | + end) |
| 42 | + |
| 43 | + a.it("converts posix to Windows local path", function() |
| 44 | + set_env_windows() |
| 45 | + assert.equals("C:\\a\\b\\c", fs.posix_to_os_path("/C/a/b/c")) |
| 46 | + end) |
| 47 | + |
| 48 | + a.it("converts posix to Windows UNC path", function() |
| 49 | + set_env_windows() |
| 50 | + assert.equals("\\\\a\\b\\c", fs.posix_to_os_path("//a/b/c")) |
| 51 | + end) |
| 52 | +end) |
0 commit comments