Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5e0189c8
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e0189c8
编写于
2月 07, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests - browser tests to go through new log service
上级
f9c5a551
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
95 addition
and
40 deletion
+95
-40
extensions/vscode-api-tests/src/singlefolder-tests/webview.test.ts
...s/vscode-api-tests/src/singlefolder-tests/webview.test.ts
+1
-1
src/vs/platform/log/browser/log.ts
src/vs/platform/log/browser/log.ts
+33
-0
src/vs/platform/log/common/log.ts
src/vs/platform/log/common/log.ts
+17
-8
src/vs/workbench/browser/web.main.ts
src/vs/workbench/browser/web.main.ts
+8
-3
test/automation/src/playwrightDriver.ts
test/automation/src/playwrightDriver.ts
+3
-3
test/integration/browser/package.json
test/integration/browser/package.json
+1
-0
test/integration/browser/src/index.ts
test/integration/browser/src/index.ts
+27
-25
test/integration/browser/yarn.lock
test/integration/browser/yarn.lock
+5
-0
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/webview.test.ts
浏览文件 @
5e0189c8
...
...
@@ -14,7 +14,7 @@ const webviewId = 'myWebview';
const
testDocument
=
join
(
vscode
.
workspace
.
rootPath
||
''
,
'
./bower.json
'
);
// TODO: Re-enable after https://github.com/microsoft/vscode/issues/88415
suite
.
skip
(
'
Webview tests
'
,
()
=>
{
(
'
electron
'
in
process
.
versions
?
suite
.
skip
:
suite
)
(
'
Webview tests
'
,
()
=>
{
const
disposables
:
vscode
.
Disposable
[]
=
[];
function
_register
<
T
extends
vscode
.
Disposable
>
(
disposable
:
T
)
{
...
...
src/vs/platform/log/browser/log.ts
0 → 100644
浏览文件 @
5e0189c8
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ILogService
,
DEFAULT_LOG_LEVEL
,
LogLevel
,
LogServiceAdapter
}
from
'
vs/platform/log/common/log
'
;
interface
IAutomatedWindow
{
codeAutomationLog
(
type
:
string
,
args
:
any
[]):
void
;
}
/**
* A logger that is used when VSCode is running in the web with
* an automation such as playwright. We expect a global codeAutomationLog
* to be defined that we can use to log to.
*/
export
class
ConsoleLogInAutomationService
extends
LogServiceAdapter
implements
ILogService
{
declare
codeAutomationLog
:
any
;
_serviceBrand
:
undefined
;
constructor
(
logLevel
:
LogLevel
=
DEFAULT_LOG_LEVEL
)
{
super
({
consoleLog
:
(
type
,
args
)
=>
this
.
consoleLog
(
type
,
args
)
},
logLevel
);
}
private
consoleLog
(
type
:
string
,
args
:
any
[]):
void
{
const
automatedWindow
=
window
as
unknown
as
IAutomatedWindow
;
if
(
typeof
automatedWindow
.
codeAutomationLog
===
'
function
'
)
{
automatedWindow
.
codeAutomationLog
(
type
,
args
);
}
}
}
src/vs/platform/log/common/log.ts
浏览文件 @
5e0189c8
...
...
@@ -213,48 +213,48 @@ export class ConsoleLogService extends AbstractLogService implements ILogService
}
}
export
class
ConsoleLogInMainService
extends
AbstractLogService
implements
ILogService
{
export
class
LogServiceAdapter
extends
AbstractLogService
implements
ILogService
{
_serviceBrand
:
undefined
;
constructor
(
private
readonly
client
:
LoggerChannelClient
,
logLevel
:
LogLevel
=
DEFAULT_LOG_LEVEL
)
{
constructor
(
private
readonly
adapter
:
{
consoleLog
:
(
type
:
string
,
args
:
any
[])
=>
void
}
,
logLevel
:
LogLevel
=
DEFAULT_LOG_LEVEL
)
{
super
();
this
.
setLevel
(
logLevel
);
}
trace
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Trace
)
{
this
.
client
.
consoleLog
(
'
trace
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
this
.
adapter
.
consoleLog
(
'
trace
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
}
}
debug
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Debug
)
{
this
.
client
.
consoleLog
(
'
debug
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
this
.
adapter
.
consoleLog
(
'
debug
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
}
}
info
(
message
:
string
,
...
args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Info
)
{
this
.
client
.
consoleLog
(
'
info
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
this
.
adapter
.
consoleLog
(
'
info
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
}
}
warn
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Warning
)
{
this
.
client
.
consoleLog
(
'
warn
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
this
.
adapter
.
consoleLog
(
'
warn
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
}
}
error
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Error
)
{
this
.
client
.
consoleLog
(
'
error
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
this
.
adapter
.
consoleLog
(
'
error
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
}
}
critical
(
message
:
string
|
Error
,
...
args
:
any
[]):
void
{
if
(
this
.
getLevel
()
<=
LogLevel
.
Critical
)
{
this
.
client
.
consoleLog
(
'
critical
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
this
.
adapter
.
consoleLog
(
'
critical
'
,
[
this
.
extractMessage
(
message
),
...
args
]);
}
}
...
...
@@ -275,6 +275,15 @@ export class ConsoleLogInMainService extends AbstractLogService implements ILogS
}
}
export
class
ConsoleLogInMainService
extends
LogServiceAdapter
implements
ILogService
{
_serviceBrand
:
undefined
;
constructor
(
client
:
LoggerChannelClient
,
logLevel
:
LogLevel
=
DEFAULT_LOG_LEVEL
)
{
super
({
consoleLog
:
(
type
,
args
)
=>
client
.
consoleLog
(
type
,
args
)
},
logLevel
);
}
}
export
class
MultiplexLogService
extends
AbstractLogService
implements
ILogService
{
_serviceBrand
:
undefined
;
...
...
src/vs/workbench/browser/web.main.ts
浏览文件 @
5e0189c8
...
...
@@ -7,6 +7,7 @@ import { mark } from 'vs/base/common/performance';
import
{
domContentLoaded
,
addDisposableListener
,
EventType
,
addClass
,
EventHelper
}
from
'
vs/base/browser/dom
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ILogService
,
ConsoleLogService
,
MultiplexLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ConsoleLogInAutomationService
}
from
'
vs/platform/log/browser/log
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
BrowserWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/browser/environmentService
'
;
import
{
Workbench
}
from
'
vs/workbench/browser/workbench
'
;
...
...
@@ -49,6 +50,7 @@ import { IndexedDBLogProvider } from 'vs/workbench/services/log/browser/indexedD
import
{
InMemoryLogProvider
}
from
'
vs/workbench/services/log/common/inMemoryLogProvider
'
;
import
{
isWorkspaceToOpen
,
isFolderToOpen
}
from
'
vs/platform/windows/common/windows
'
;
import
{
getWorkspaceIdentifier
}
from
'
vs/workbench/services/workspaces/browser/workspaces
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
class
BrowserMain
extends
Disposable
{
...
...
@@ -234,9 +236,12 @@ class BrowserMain extends Disposable {
}
}
const
consoleLogService
=
new
ConsoleLogService
(
logService
.
getLevel
());
const
fileLogService
=
new
FileLogService
(
'
window
'
,
environmentService
.
logFile
,
logService
.
getLevel
(),
fileService
);
logService
.
logger
=
new
MultiplexLogService
([
consoleLogService
,
fileLogService
]);
logService
.
logger
=
new
MultiplexLogService
(
coalesce
([
new
ConsoleLogService
(
logService
.
getLevel
()),
new
FileLogService
(
'
window
'
,
environmentService
.
logFile
,
logService
.
getLevel
(),
fileService
),
// Extension development test CLI: forward everything to test runner
environmentService
.
isExtensionDevelopment
&&
!!
environmentService
.
extensionTestsLocationURI
?
new
ConsoleLogInAutomationService
(
logService
.
getLevel
())
:
undefined
]));
})();
const
connection
=
remoteAgentService
.
getConnection
();
...
...
test/automation/src/playwrightDriver.ts
浏览文件 @
5e0189c8
...
...
@@ -111,8 +111,8 @@ export async function launch(userDataDir: string, _workspacePath: string, codeSe
[
'
--browser
'
,
'
none
'
,
'
--driver
'
,
'
web
'
],
{
env
}
);
server
.
stderr
?.
on
(
'
data
'
,
e
=>
console
.
log
(
'
Server stderr:
'
+
e
));
server
.
stdout
?.
on
(
'
data
'
,
e
=>
console
.
log
(
'
Server stdout:
'
+
e
));
server
.
stderr
?.
on
(
'
data
'
,
e
rror
=>
console
.
log
(
`Server stderr:
${
error
}
`
));
server
.
stdout
?.
on
(
'
data
'
,
data
=>
console
.
log
(
`Server stdout:
${
data
}
`
));
process
.
on
(
'
exit
'
,
teardown
);
process
.
on
(
'
SIGINT
'
,
teardown
);
process
.
on
(
'
SIGTERM
'
,
teardown
);
...
...
@@ -148,7 +148,7 @@ export function connect(headless: boolean, engine: 'chromium' | 'webkit' | 'fire
await
page
.
setViewport
({
width
,
height
});
await
page
.
goto
(
`
${
endpoint
}
&folder=vscode-remote://localhost:9888
${
URI
.
file
(
workspacePath
!
).
path
}
`
);
const
result
=
{
client
:
{
dispose
:
()
=>
teardown
()
},
client
:
{
dispose
:
()
=>
browser
.
close
()
&&
teardown
()
},
driver
:
buildDriver
(
browser
,
page
)
};
c
(
result
);
...
...
test/integration/browser/package.json
浏览文件 @
5e0189c8
...
...
@@ -10,6 +10,7 @@
"@types/mkdirp"
:
"0.5.1"
,
"@types/node"
:
"^12.11.7"
,
"@types/rimraf"
:
"2.0.2"
,
"@types/tmp"
:
"^0.1.0"
,
"rimraf"
:
"^2.6.1"
,
"tmp"
:
"0.0.33"
,
"typescript"
:
"3.7.5"
...
...
test/integration/browser/src/index.ts
浏览文件 @
5e0189c8
...
...
@@ -15,18 +15,13 @@ const optimist = require('optimist')
.
describe
(
'
browser
'
,
'
browser in which integration tests should run
'
).
string
(
'
browser
'
).
default
(
'
browser
'
,
'
chromium
'
)
.
describe
(
'
help
'
,
'
show the help
'
).
alias
(
'
help
'
,
'
h
'
);
let
serverProcess
:
cp
.
ChildProcess
|
undefined
=
undefined
;
function
teardownServer
()
{
if
(
serverProcess
)
{
serverProcess
.
kill
();
serverProcess
=
undefined
;
}
}
const
width
=
1200
;
const
height
=
800
;
async
function
runTestsInBrowser
(
browserType
:
string
,
endpoint
:
string
):
Promise
<
void
>
{
const
browser
=
await
playwright
[
browserType
].
launch
({
headless
:
!
Boolean
(
optimist
.
argv
.
debug
)
});
const
page
=
(
await
browser
.
defaultContext
().
pages
())[
0
];
await
page
.
setViewport
({
width
,
height
});
const
host
=
url
.
parse
(
endpoint
).
host
;
const
protocol
=
'
vscode-remote
'
;
...
...
@@ -41,24 +36,22 @@ async function runTestsInBrowser(browserType: string, endpoint: string): Promise
await
page
.
goto
(
`
${
endpoint
}
&folder=
${
folderParam
}
&payload=
${
payloadParam
}
`
);
// const emitter = new events.EventEmitter();
// await page.exposeFunction('mocha_report', (type, data1, data2) => {
// emitter.emit(type, data1, data2)
// });
await
page
.
exposeFunction
(
'
codeAutomationLog
'
,
(
type
:
string
,
args
:
any
[])
=>
{
console
[
type
](...
args
);
});
page
.
on
(
'
console
'
,
async
(
msg
:
playwright
.
ConsoleMessage
)
=>
{
const
msgText
=
msg
.
text
();
console
[
msg
.
type
()](
msgText
,
await
Promise
.
all
(
msg
.
args
().
map
(
async
arg
=>
await
arg
.
jsonValue
())));
if
(
msgText
.
indexOf
(
'
vscode:exit
'
)
>=
0
)
{
browser
.
close
();
teardownServer
();
setTimeout
(()
=>
process
.
exit
(
msgText
===
'
vscode:exit 0
'
?
0
:
1
),
10
);
await
browser
.
close
();
process
.
exit
(
msgText
===
'
vscode:exit 0
'
?
0
:
1
);
}
});
}
async
function
launchServer
():
Promise
<
string
>
{
// Ensure a tmp user-data-dir is used for the tests
const
tmpDir
=
tmp
.
dirSync
({
prefix
:
'
t
'
});
const
testDataPath
=
tmpDir
.
name
;
process
.
once
(
'
exit
'
,
()
=>
rimraf
.
sync
(
testDataPath
));
...
...
@@ -70,7 +63,7 @@ async function launchServer(): Promise<string> {
...
process
.
env
};
let
serverLocation
;
let
serverLocation
:
string
;
if
(
process
.
env
.
VSCODE_REMOTE_SERVER_PATH
)
{
serverLocation
=
path
.
join
(
process
.
env
.
VSCODE_REMOTE_SERVER_PATH
,
`server.
${
process
.
platform
===
'
win32
'
?
'
cmd
'
:
'
sh
'
}
`
);
}
else
{
...
...
@@ -79,24 +72,33 @@ async function launchServer(): Promise<string> {
process
.
env
.
VSCODE_DEV
=
'
1
'
;
}
serverProcess
=
cp
.
spawn
(
let
serverProcess
=
cp
.
spawn
(
serverLocation
,
[
'
--browser
'
,
'
none
'
,
'
--driver
'
,
'
web
'
],
{
env
}
);
serverProcess
?.
stderr
?.
on
(
'
data
'
,
e
=>
console
.
log
(
`Server stderr:
${
e
}
`
));
serverProcess
?.
stdout
?.
on
(
'
data
'
,
e
=>
console
.
log
(
`Server stdout:
${
e
}
`
));
serverProcess
?.
stderr
?.
on
(
'
data
'
,
error
=>
console
.
log
(
`Server stderr:
${
error
}
`
));
if
(
optimist
.
argv
.
debug
)
{
serverProcess
?.
stdout
?.
on
(
'
data
'
,
data
=>
console
.
log
(
`Server stdout:
${
data
}
`
));
}
function
teardownServer
()
{
if
(
serverProcess
)
{
serverProcess
.
kill
();
}
}
process
.
on
(
'
exit
'
,
teardownServer
);
process
.
on
(
'
SIGINT
'
,
teardownServer
);
process
.
on
(
'
SIGTERM
'
,
teardownServer
);
return
new
Promise
(
r
=>
{
serverProcess
?.
stdout
?.
on
(
'
data
'
,
d
=>
{
const
matches
=
d
.
toString
(
'
ascii
'
).
match
(
/Web UI available at
(
.+
)
/
);
return
new
Promise
(
c
=>
{
serverProcess
?.
stdout
?.
on
(
'
data
'
,
d
ata
=>
{
const
matches
=
d
ata
.
toString
(
'
ascii
'
).
match
(
/Web UI available at
(
.+
)
/
);
if
(
matches
!==
null
)
{
r
(
matches
[
1
]);
c
(
matches
[
1
]);
}
});
});
...
...
test/integration/browser/yarn.lock
浏览文件 @
5e0189c8
...
...
@@ -46,6 +46,11 @@
"@types/glob" "*"
"@types/node" "*"
"@types/tmp@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.1.0.tgz#19cf73a7bcf641965485119726397a096f0049bd"
integrity sha512-6IwZ9HzWbCq6XoQWhxLpDjuADodH/MKXRUIDFudvgjcVdjFknvmR+DNsoUeer4XPrEnrZs04Jj+kfV9pFsrhmA==
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录