FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-python/src/test/sourceMapSupport.test.ts at main · Pythoneryeah/vscode-python · GitHub
Pythoneryeah
/
vscode-python
Public
forked from
microsoft/vscode-python
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vscode-python
/
src
/
test
/
sourceMapSupport.test.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
95 lines (86 loc) · 3.88 KB
Breadcrumbs
vscode-python
/
src
/
test
/
sourceMapSupport.test.ts
Copy path
File metadata and controls
95 lines (86 loc) · 3.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict'
;
import
{
expect
}
from
'chai'
;
import
*
as
fs
from
'fs'
;
import
{
ConfigurationTarget
,
Disposable
}
from
'vscode'
;
import
{
FileSystem
}
from
'../client/common/platform/fileSystem'
;
import
{
Diagnostics
}
from
'../client/common/utils/localize'
;
import
{
SourceMapSupport
}
from
'../client/sourceMapSupport'
;
import
{
noop
}
from
'./core'
;
suite
(
'Source Map Support'
,
(
)
=>
{
function
createVSCStub
(
isEnabled
:
boolean
=
false
,
selectDisableButton
:
boolean
=
false
)
{
const
stubInfo
=
{
configValueRetrieved
:
false
,
configValueUpdated
:
false
,
messageDisplayed
:
false
,
}
;
const
vscode
=
{
workspace
:
{
getConfiguration
:
(
setting
:
string
,
_defaultValue
:
any
)
=>
{
if
(
setting
!==
'python.diagnostics'
)
{
return
;
}
return
{
get
:
(
prop
:
string
)
=>
{
stubInfo
.
configValueRetrieved
=
prop
===
'sourceMapsEnabled'
;
return
isEnabled
;
}
,
update
:
(
prop
:
string
,
value
:
boolean
,
scope
:
ConfigurationTarget
)
=>
{
if
(
prop
===
'sourceMapsEnabled'
&&
value
===
false
&&
scope
===
ConfigurationTarget
.
Global
)
{
stubInfo
.
configValueUpdated
=
true
;
}
}
,
}
;
}
,
}
,
window
:
{
showWarningMessage
:
(
)
=>
{
stubInfo
.
messageDisplayed
=
true
;
return
Promise
.
resolve
(
selectDisableButton
?
Diagnostics
.
disableSourceMaps
:
undefined
)
;
}
,
}
,
ConfigurationTarget
:
ConfigurationTarget
,
}
;
return
{
stubInfo
,
vscode
}
;
}
const
disposables
:
Disposable
[
]
=
[
]
;
teardown
(
(
)
=>
{
disposables
.
forEach
(
(
disposable
)
=>
{
try
{
disposable
.
dispose
(
)
;
}
catch
{
noop
(
)
;
}
}
)
;
}
)
;
test
(
'When disabling source maps, the map file is renamed and vice versa'
,
async
(
)
=>
{
const
fileSystem
=
new
FileSystem
(
)
;
const
jsFile
=
await
fileSystem
.
createTemporaryFile
(
'.js'
)
;
disposables
.
push
(
jsFile
)
;
const
mapFile
=
`
${
jsFile
.
filePath
}
.map`
;
disposables
.
push
(
{
dispose
:
(
)
=>
fs
.
unlinkSync
(
mapFile
)
,
}
)
;
await
fileSystem
.
writeFile
(
mapFile
,
'ABC'
)
;
expect
(
await
fileSystem
.
fileExists
(
mapFile
)
)
.
to
.
be
.
true
;
const
stub
=
createVSCStub
(
true
,
true
)
;
const
instance
=
new
(
class
extends
SourceMapSupport
{
public
async
enableSourceMap
(
enable
:
boolean
,
sourceFile
:
string
)
{
return
super
.
enableSourceMap
(
enable
,
sourceFile
)
;
}
}
)
(
stub
.
vscode
as
any
)
;
await
instance
.
enableSourceMap
(
false
,
jsFile
.
filePath
)
;
expect
(
await
fileSystem
.
fileExists
(
jsFile
.
filePath
)
)
.
to
.
be
.
equal
(
true
,
'Source file does not exist'
)
;
expect
(
await
fileSystem
.
fileExists
(
mapFile
)
)
.
to
.
be
.
equal
(
false
,
'Source map file not renamed'
)
;
expect
(
await
fileSystem
.
fileExists
(
`
${
mapFile
}
.disabled`
)
)
.
to
.
be
.
equal
(
true
,
'Expected renamed file not found'
)
;
await
instance
.
enableSourceMap
(
true
,
jsFile
.
filePath
)
;
expect
(
await
fileSystem
.
fileExists
(
jsFile
.
filePath
)
)
.
to
.
be
.
equal
(
true
,
'Source file does not exist'
)
;
expect
(
await
fileSystem
.
fileExists
(
mapFile
)
)
.
to
.
be
.
equal
(
true
,
'Source map file not found'
)
;
expect
(
await
fileSystem
.
fileExists
(
`
${
mapFile
}
.disabled`
)
)
.
to
.
be
.
equal
(
false
,
'Source map file not renamed'
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL