Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a7675860
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,发现更多精彩内容 >>
提交
a7675860
编写于
8月 25, 2017
作者:
J
Joao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
smoke test: fix bad code
上级
30e81176
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
149 addition
and
181 deletion
+149
-181
test/smoke/src/areas/extensions.ts
test/smoke/src/areas/extensions.ts
+35
-34
test/smoke/src/areas/git.ts
test/smoke/src/areas/git.ts
+29
-28
test/smoke/src/areas/javascript.ts
test/smoke/src/areas/javascript.ts
+43
-41
test/smoke/src/helpers/screenshot.ts
test/smoke/src/helpers/screenshot.ts
+2
-10
test/smoke/src/main.ts
test/smoke/src/main.ts
+12
-32
test/smoke/src/mocha-runner.ts
test/smoke/src/mocha-runner.ts
+2
-3
test/smoke/src/spectron/application.ts
test/smoke/src/spectron/application.ts
+24
-31
test/smoke/src/test.ts
test/smoke/src/test.ts
+1
-1
test/smoke/src/tests/data-loss.ts
test/smoke/src/tests/data-loss.ts
+1
-1
未找到文件。
test/smoke/src/areas/extensions.ts
浏览文件 @
a7675860
...
...
@@ -70,42 +70,43 @@ export class Extensions {
}
private
getExtensionIndex
(
name
:
string
,
extensionListSelector
:
string
):
Promise
<
number
>
{
return
new
Promise
(
async
(
res
,
rej
)
=>
{
const
html
=
await
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
extensionListSelector
);
let
extensionIndex
:
number
=
0
;
let
extension
:
boolean
;
let
tags
:
string
[]
=
[];
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
,
attribs
)
{
if
(
name
===
'
div
'
&&
attribs
.
class
===
'
extension
'
)
{
extensionIndex
++
;
extension
=
true
;
return
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
extensionListSelector
).
then
(
html
=>
{
return
new
Promise
<
number
>
((
res
,
rej
)
=>
{
let
extensionIndex
:
number
=
0
;
let
extension
:
boolean
;
let
tags
:
string
[]
=
[];
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
,
attribs
)
{
if
(
name
===
'
div
'
&&
attribs
.
class
===
'
extension
'
)
{
extensionIndex
++
;
extension
=
true
;
}
if
(
extension
)
{
tags
.
push
(
name
);
}
},
ontext
:
function
(
text
)
{
if
(
extension
&&
text
===
name
)
{
parser
.
end
();
}
},
onclosetag
:
function
(
name
)
{
if
(
extension
)
{
tags
.
pop
();
}
if
(
extension
&&
tags
.
length
===
0
)
{
extension
=
false
;
}
},
onend
:
function
()
{
if
(
extensionIndex
===
0
)
{
return
rej
(
`
${
name
}
extension was not found.`
);
}
return
res
(
extensionIndex
);
}
if
(
extension
)
{
tags
.
push
(
name
);
}
},
ontext
:
function
(
text
)
{
if
(
extension
&&
text
===
name
)
{
parser
.
end
();
}
},
onclosetag
:
function
(
name
)
{
if
(
extension
)
{
tags
.
pop
();
}
if
(
extension
&&
tags
.
length
===
0
)
{
extension
=
false
;
}
},
onend
:
function
()
{
if
(
extensionIndex
===
0
)
{
return
rej
(
`
${
name
}
extension was not found.`
);
}
return
res
(
extensionIndex
);
}
});
parser
.
write
(
html
);
});
parser
.
write
(
html
);
});
}
}
\ No newline at end of file
test/smoke/src/areas/git.ts
浏览文件 @
a7675860
...
...
@@ -131,36 +131,37 @@ export class Git {
}
private
getFirstChangeIndex
(
changeClass
:
string
,
selector
:
string
):
Promise
<
number
>
{
return
new
Promise
(
async
(
res
,
rej
)
=>
{
const
html
=
await
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
selector
);
let
lineIndex
:
number
=
0
;
let
changeFound
:
boolean
;
let
tags
:
string
[]
=
[];
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
:
string
,
attribs
:
any
)
{
tags
.
push
(
name
);
if
(
name
===
'
div
'
&&
!
attribs
.
class
)
{
lineIndex
++
;
}
else
if
(
name
===
'
div
'
&&
attribs
.
class
===
changeClass
)
{
changeFound
=
true
;
parser
.
end
();
return
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
selector
).
then
(
html
=>
{
return
new
Promise
<
number
>
((
res
,
rej
)
=>
{
let
lineIndex
:
number
=
0
;
let
changeFound
:
boolean
;
let
tags
:
string
[]
=
[];
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
:
string
,
attribs
:
any
)
{
tags
.
push
(
name
);
if
(
name
===
'
div
'
&&
!
attribs
.
class
)
{
lineIndex
++
;
}
else
if
(
name
===
'
div
'
&&
attribs
.
class
===
changeClass
)
{
changeFound
=
true
;
parser
.
end
();
}
},
onclosetag
:
function
(
name
)
{
// Terminate once last tag is closed
tags
.
pop
();
if
(
!
changeFound
&&
tags
.
length
===
0
)
{
parser
.
end
();
}
},
onend
:
function
()
{
if
(
!
changeFound
)
{
return
rej
(
`No changes in the diff found.`
);
}
return
res
(
lineIndex
);
}
},
onclosetag
:
function
(
name
)
{
// Terminate once last tag is closed
tags
.
pop
();
if
(
!
changeFound
&&
tags
.
length
===
0
)
{
parser
.
end
();
}
},
onend
:
function
()
{
if
(
!
changeFound
)
{
return
rej
(
`No changes in the diff found.`
);
}
return
res
(
lineIndex
);
}
});
parser
.
write
(
html
);
});
parser
.
write
(
html
);
});
}
}
\ No newline at end of file
test/smoke/src/areas/javascript.ts
浏览文件 @
a7675860
...
...
@@ -130,55 +130,57 @@ export class JavaScript {
}
private
getLineIndexOfFirst
(
string
:
string
,
selector
:
string
):
Promise
<
number
>
{
return
new
Promise
(
async
(
res
,
rej
)
=>
{
const
html
=
await
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
selector
);
let
lineIndex
:
number
=
0
;
let
stringFound
:
boolean
;
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
:
string
,
attribs
:
any
)
{
if
(
name
===
'
div
'
&&
attribs
.
class
===
'
view-line
'
)
{
lineIndex
++
;
return
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
selector
).
then
(
html
=>
{
return
new
Promise
<
number
>
((
res
,
rej
)
=>
{
let
lineIndex
:
number
=
0
;
let
stringFound
:
boolean
;
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
:
string
,
attribs
:
any
)
{
if
(
name
===
'
div
'
&&
attribs
.
class
===
'
view-line
'
)
{
lineIndex
++
;
}
},
ontext
:
function
(
text
)
{
if
(
!
stringFound
&&
text
===
string
)
{
stringFound
=
true
;
parser
.
end
();
}
},
onend
:
function
()
{
if
(
!
stringFound
)
{
return
rej
(
`No
${
string
}
in editor found.`
);
}
return
res
(
lineIndex
);
}
},
ontext
:
function
(
text
)
{
if
(
!
stringFound
&&
text
===
string
)
{
stringFound
=
true
;
parser
.
end
();
}
},
onend
:
function
()
{
if
(
!
stringFound
)
{
return
rej
(
`No
${
string
}
in editor found.`
);
}
return
res
(
lineIndex
);
}
});
parser
.
write
(
html
);
});
parser
.
write
(
html
);
});
}
private
getLineIndexOfFirstFoldableElement
(
selector
:
string
):
Promise
<
number
>
{
return
new
Promise
(
async
(
res
,
rej
)
=>
{
const
html
=
await
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
selector
);
let
lineIndex
:
number
=
0
;
let
foldFound
:
boolean
;
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
:
string
,
attribs
:
any
)
{
if
(
name
===
'
div
'
&&
!
attribs
.
class
)
{
lineIndex
++
;
}
else
if
(
name
===
'
div
'
&&
attribs
.
class
.
indexOf
(
'
cldr folding
'
)
!==
-
1
)
{
foldFound
=
true
;
parser
.
end
();
}
},
onend
:
function
()
{
if
(
!
foldFound
)
{
return
rej
(
`No foldable elements found.`
);
return
this
.
spectron
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
selector
).
then
(
html
=>
{
return
new
Promise
<
number
>
((
res
,
rej
)
=>
{
let
lineIndex
:
number
=
0
;
let
foldFound
:
boolean
;
let
parser
=
new
htmlparser
.
Parser
({
onopentag
:
function
(
name
:
string
,
attribs
:
any
)
{
if
(
name
===
'
div
'
&&
!
attribs
.
class
)
{
lineIndex
++
;
}
else
if
(
name
===
'
div
'
&&
attribs
.
class
.
indexOf
(
'
cldr folding
'
)
!==
-
1
)
{
foldFound
=
true
;
parser
.
end
();
}
},
onend
:
function
()
{
if
(
!
foldFound
)
{
return
rej
(
`No foldable elements found.`
);
}
return
res
(
lineIndex
);
}
return
res
(
lineIndex
);
}
}
);
parser
.
write
(
html
);
});
parser
.
write
(
html
);
});
}
}
\ No newline at end of file
test/smoke/src/helpers/screenshot.ts
浏览文件 @
a7675860
...
...
@@ -21,16 +21,8 @@ export class Screenshot {
}
public
async
capture
():
Promise
<
any
>
{
return
new
Promise
(
async
(
res
,
rej
)
=>
{
const
image
:
Electron
.
NativeImage
=
await
this
.
spectron
.
app
.
browserWindow
.
capturePage
();
fs
.
writeFile
(
`
${
this
.
testPath
}
/
${
this
.
index
}
.png`
,
image
,
(
err
)
=>
{
if
(
err
)
{
rej
(
err
);
}
this
.
index
++
;
res
();
});
});
const
image
=
await
this
.
spectron
.
app
.
browserWindow
.
capturePage
();
await
new
Promise
((
c
,
e
)
=>
fs
.
writeFile
(
`
${
this
.
testPath
}
/
${
this
.
index
++
}
.png`
,
image
,
err
=>
err
?
e
(
err
)
:
c
()));
}
private
createFolder
(
name
:
string
):
void
{
...
...
test/smoke/src/main.ts
浏览文件 @
a7675860
...
...
@@ -119,24 +119,16 @@ function runTests(): void {
});
}
function
cleanOrClone
(
repo
:
string
,
dir
:
string
):
Promise
<
any
>
{
async
function
cleanOrClone
(
repo
:
string
,
dir
:
string
):
Promise
<
any
>
{
console
.
log
(
'
Cleaning or cloning test project repository...
'
);
return
new
Promise
(
async
(
res
,
rej
)
=>
{
if
(
!
folderExists
(
dir
))
{
await
gitClone
(
repo
,
dir
);
res
();
}
else
{
git
.
cwd
(
dir
);
git
.
fetch
(
async
err
=>
{
if
(
err
)
{
rej
(
err
);
}
await
gitResetAndClean
();
res
();
});
}
});
if
(
!
folderExists
(
dir
))
{
await
gitClone
(
repo
,
dir
);
}
else
{
git
.
cwd
(
dir
);
await
new
Promise
((
c
,
e
)
=>
git
.
fetch
(
err
=>
err
?
e
(
err
)
:
c
()));
await
gitResetAndClean
();
}
}
function
gitClone
(
repo
:
string
,
dir
:
string
):
Promise
<
any
>
{
...
...
@@ -148,22 +140,10 @@ function gitClone(repo: string, dir: string): Promise<any> {
});
}
function
gitResetAndClean
():
Promise
<
any
>
{
return
new
Promise
((
res
,
rej
)
=>
{
git
.
reset
([
'
FETCH_HEAD
'
,
'
--hard
'
],
err
=>
{
if
(
err
)
{
rej
(
err
);
}
git
.
clean
(
'
f
'
,
[
'
-d
'
],
err
=>
{
if
(
err
)
{
rej
(
err
);
}
console
.
log
(
'
Test project was successfully reset to initial state.
'
);
res
();
});
});
});
async
function
gitResetAndClean
():
Promise
<
any
>
{
await
new
Promise
((
c
,
e
)
=>
git
.
reset
([
'
FETCH_HEAD
'
,
'
--hard
'
],
err
=>
err
?
e
(
err
)
:
c
()));
await
new
Promise
((
c
,
e
)
=>
git
.
clean
(
'
f
'
,
[
'
-d
'
],
err
=>
err
?
e
(
err
)
:
c
()));
console
.
log
(
'
Test project was successfully reset to initial state.
'
);
}
function
execute
(
cmd
:
string
,
dir
:
string
):
Promise
<
any
>
{
...
...
test/smoke/src/mocha-runner.ts
浏览文件 @
a7675860
...
...
@@ -6,9 +6,8 @@
const
MochaTest
=
require
(
'
mocha
'
);
const
mochaTest
=
new
MochaTest
({
timeout
:
360000
,
retries
:
2
,
slow
:
50000
,
timeout
:
60000
,
slow
:
10000
,
useColors
:
true
});
mochaTest
.
addFile
(
require
(
'
path
'
).
join
(
process
.
cwd
(),
'
out/test.js
'
));
...
...
test/smoke/src/spectron/application.ts
浏览文件 @
a7675860
...
...
@@ -68,13 +68,9 @@ export class SpectronApplication {
}
public
async
start
():
Promise
<
any
>
{
try
{
await
this
.
spectron
.
start
();
await
this
.
focusOnWindow
(
1
);
// focuses on main renderer window
return
this
.
checkWindowReady
();
}
catch
(
err
)
{
throw
err
;
}
await
this
.
spectron
.
start
();
await
this
.
focusOnWindow
(
1
);
// focuses on main renderer window
await
this
.
checkWindowReady
();
}
public
async
stop
():
Promise
<
any
>
{
...
...
@@ -95,8 +91,8 @@ export class SpectronApplication {
return
this
.
client
.
windowByIndex
(
index
);
}
private
checkWindowReady
():
Promise
<
any
>
{
return
this
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
'
[id="workbench.main.container"]
'
);
private
async
checkWindowReady
():
Promise
<
any
>
{
await
this
.
waitFor
(
this
.
spectron
.
client
.
getHTML
,
'
[id="workbench.main.container"]
'
);
}
private
retrieveKeybindings
()
{
...
...
@@ -112,30 +108,27 @@ export class SpectronApplication {
});
}
private
callClientAPI
(
func
:
(...
args
:
any
[])
=>
Promise
<
any
>
,
args
:
any
):
Promise
<
any
>
{
private
async
callClientAPI
(
func
:
(...
args
:
any
[])
=>
Promise
<
any
>
,
args
:
any
):
Promise
<
any
>
{
let
trial
=
1
;
return
new
Promise
(
async
(
res
,
rej
)
=>
{
while
(
true
)
{
if
(
trial
>
this
.
pollTrials
)
{
rej
(
`Could not retrieve the element in
${
this
.
testRetry
*
this
.
pollTrials
*
this
.
pollTimeout
}
seconds.`
);
break
;
}
let
result
;
try
{
result
=
await
func
.
call
(
this
.
client
,
args
,
false
);
}
catch
(
e
)
{
}
if
(
result
&&
result
!==
''
)
{
await
this
.
screenshot
.
capture
();
res
(
result
);
break
;
}
await
this
.
wait
();
trial
++
;
while
(
true
)
{
if
(
trial
>
this
.
pollTrials
)
{
throw
new
Error
(
`Could not retrieve the element in
${
this
.
testRetry
*
this
.
pollTrials
*
this
.
pollTimeout
}
seconds.`
);
}
});
let
result
;
try
{
result
=
await
func
.
call
(
this
.
client
,
args
,
false
);
}
catch
(
e
)
{
}
if
(
result
&&
result
!==
''
)
{
await
this
.
screenshot
.
capture
();
return
result
;
}
await
this
.
wait
();
trial
++
;
}
}
/**
...
...
test/smoke/src/test.ts
浏览文件 @
a7675860
...
...
@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
testDataLoss
}
from
'
./tests/data-loss
'
;
import
{
testDataMigration
}
from
'
./tests/data-migration
'
;
import
{
testDataLoss
}
from
'
./tests/data-loss
'
;
import
{
testExplorer
}
from
'
./tests/explorer
'
;
import
{
testConfigViews
}
from
'
./tests/configuration-views
'
;
import
{
testSearch
}
from
'
./tests/search
'
;
...
...
test/smoke/src/tests/data-loss.ts
浏览文件 @
a7675860
...
...
@@ -22,7 +22,7 @@ export function testDataLoss() {
dl
=
new
DataLoss
(
app
);
await
common
.
removeDirectory
(
USER_DIR
);
return
await
app
.
start
();
await
app
.
start
();
});
afterEach
(
async
function
()
{
return
await
app
.
stop
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录