forked from xdebug/vscode-php-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.ts
More file actions
104 lines (102 loc) · 5.8 KB
/
Copy pathpaths.ts
File metadata and controls
104 lines (102 loc) · 5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import {isSameUri, convertClientPathToDebugger, convertDebuggerPathToClient} from '../paths';
import * as assert from 'assert';
describe('paths', () => {
describe('isSameUri', () => {
it('should compare to URIs', () => {
assert.strictEqual(isSameUri('file:///var/www/test.php', 'file:///var/www/test.php'), true);
assert.strictEqual(isSameUri('file:///var/www/test.php', 'file:///var/www/test2.php'), false);
});
it('should compare windows paths case-insensitive', () => {
assert.strictEqual(isSameUri('file:///C:/Program%20Files/Apache/2.4/htdocs/test.php', 'file:///c:/Program%20Files/Apache/2.4/htdocs/test.php'), true);
assert.strictEqual(isSameUri('file:///C:/Program%20Files/Apache/2.4/htdocs/test.php', 'file:///C:/Program%20Files/Apache/2.4/htdocs/test2.php'), false);
});
});
describe('convertClientPathToDebugger', () => {
describe('without source mapping', () => {
it('should convert a windows path to a URI', () => {
assert.equal(convertClientPathToDebugger('C:\\Users\\felix\\test.php'), 'file:///C:/Users/felix/test.php');
});
it('should convert a unix path to a URI', () => {
assert.equal(convertClientPathToDebugger('/home/felix/test.php'), 'file:///home/felix/test.php');
});
});
describe('with source mapping', () => {
it('should convert a unix path to a unix URI', () => {
const localSourceRoot = '/home/felix/myproject';
const serverSourceRoot = '/var/www';
assert.equal(
convertClientPathToDebugger('/home/felix/myproject/test.php', localSourceRoot, serverSourceRoot),
'file:///var/www/test.php'
);
});
it('should convert a unix path to a windows URI', () => {
const localSourceRoot = '/home/felix/myproject';
const serverSourceRoot = 'C:\\Program Files\\Apache\\2.4\\htdocs';
assert.equal(
convertClientPathToDebugger('/home/felix/myproject/test.php', localSourceRoot, serverSourceRoot),
'file:///C:/Program%20Files/Apache/2.4/htdocs/test.php'
);
});
it('should convert a windows path to a unix URI', () => {
const localSourceRoot = 'C:\\Users\\felix\\myproject';
const serverSourceRoot = '/var/www';
assert.equal(
convertClientPathToDebugger('C:\\Users\\felix\\myproject\\test.php', localSourceRoot, serverSourceRoot),
'file:///var/www/test.php'
);
});
it('should convert a windows path to a windows URI', () => {
const localSourceRoot = 'C:\\Users\\felix\\myproject';
const serverSourceRoot = 'C:\\Program Files\\Apache\\2.4\\htdocs';
assert.equal(
convertClientPathToDebugger('C:\\Users\\felix\\myproject\\test.php', localSourceRoot, serverSourceRoot),
'file:///C:/Program%20Files/Apache/2.4/htdocs/test.php'
);
});
});
});
describe('convertDebuggerPathToClient', () => {
describe('without source mapping', () => {
(process.platform === 'win32' ? it : it.skip)('should convert a windows URI to a windows path', () => {
assert.equal(convertDebuggerPathToClient('file:///C:/Users/felix/test.php'), 'C:\\Users\\felix\\test.php');
});
(process.platform !== 'win32' ? it : it.skip)('should convert a unix URI to a unix path', () => {
assert.equal(convertDebuggerPathToClient('file:///home/felix/test.php'), '/home/felix/test.php');
});
});
describe('with source mapping', () => {
(process.platform !== 'win32' ? it : it.skip)('should convert a unix URI to a unix path', () => {
const localSourceRoot = '/home/felix/myproject';
const serverSourceRoot = '/var/www';
assert.equal(
convertDebuggerPathToClient('file:///var/www/test.php', localSourceRoot, serverSourceRoot),
'/home/felix/myproject/test.php'
);
});
(process.platform !== 'win32' ? it : it.skip)('should convert a windows URI to a unix path', () => {
const localSourceRoot = '/home/felix/myproject';
const serverSourceRoot = 'C:\\Program Files\\Apache\\2.4\\htdocs';
assert.equal(
convertDebuggerPathToClient('file:///C:/Program%20Files/Apache/2.4/htdocs/test.php', localSourceRoot, serverSourceRoot),
'/home/felix/myproject/test.php'
);
});
(process.platform === 'win32' ? it : it.skip)('should convert a unix URI to a windows path', () => {
const localSourceRoot = 'C:\\Users\\felix\\myproject';
const serverSourceRoot = '/var/www';
assert.equal(
convertDebuggerPathToClient('file:///var/www/test.php', localSourceRoot, serverSourceRoot),
'C:\\Users\\felix\\myproject\\test.php'
);
});
(process.platform === 'win32' ? it : it.skip)('should convert a windows URI to a windows path', () => {
const localSourceRoot = 'C:\\Users\\felix\\myproject';
const serverSourceRoot = 'C:\\Program Files\\Apache\\2.4\\htdocs';
assert.equal(
convertDebuggerPathToClient('file:///C:/Program%20Files/Apache/2.4/htdocs/test.php', localSourceRoot, serverSourceRoot),
'C:\\Users\\felix\\myproject\\test.php'
);
});
});
});
});