Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
3685e655
C
code-server
项目概览
myhjmzy
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3685e655
编写于
2月 19, 2019
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move and refactor child_process tests
上级
d80f82ab
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
103 addition
and
22 deletion
+103
-22
packages/ide/src/fill/child_process.ts
packages/ide/src/fill/child_process.ts
+11
-5
packages/ide/test/child_process.test.ts
packages/ide/test/child_process.test.ts
+74
-0
packages/ide/test/forker.js
packages/ide/test/forker.js
+1
-1
packages/package.json
packages/package.json
+1
-0
packages/vscode/src/fill/node-pty.ts
packages/vscode/src/fill/node-pty.ts
+3
-3
packages/vscode/src/fill/spdlog.ts
packages/vscode/src/fill/spdlog.ts
+13
-13
未找到文件。
packages/ide/src/fill/child_process.ts
浏览文件 @
3685e655
...
...
@@ -60,9 +60,9 @@ class ChildProcess extends CallbackEmitter implements cp.ChildProcess {
}
ae
.
on
(
"
disconnect
"
,
()
=>
childProcess
.
disconnect
());
ae
.
on
(
"
kill
"
,
(
signal
)
=>
childProcess
.
kill
(
signal
));
ae
.
on
(
"
kill
"
,
(
signal
:
string
)
=>
childProcess
.
kill
(
signal
));
ae
.
on
(
"
ref
"
,
()
=>
childProcess
.
ref
());
ae
.
on
(
"
send
"
,
(
message
,
callbackId
)
=>
childProcess
.
send
(
message
,
maybeCallback
(
ae
,
callbackId
)));
ae
.
on
(
"
send
"
,
(
message
:
string
,
callbackId
:
number
)
=>
childProcess
.
send
(
message
,
maybeCallback
(
ae
,
callbackId
)));
ae
.
on
(
"
unref
"
,
()
=>
childProcess
.
unref
());
ae
.
emit
(
"
pid
"
,
childProcess
.
pid
);
...
...
@@ -72,9 +72,15 @@ class ChildProcess extends CallbackEmitter implements cp.ChildProcess {
childProcess
.
on
(
"
exit
"
,
(
code
,
signal
)
=>
ae
.
emit
(
"
exit
"
,
code
,
signal
));
childProcess
.
on
(
"
message
"
,
(
message
)
=>
ae
.
emit
(
"
message
"
,
message
));
bindWritable
(
createUniqueEval
(
ae
,
"
stdin
"
),
childProcess
.
stdin
);
bindReadable
(
createUniqueEval
(
ae
,
"
stdout
"
),
childProcess
.
stdout
);
bindReadable
(
createUniqueEval
(
ae
,
"
stderr
"
),
childProcess
.
stderr
);
if
(
childProcess
.
stdin
)
{
bindWritable
(
createUniqueEval
(
ae
,
"
stdin
"
),
childProcess
.
stdin
);
}
if
(
childProcess
.
stdout
)
{
bindReadable
(
createUniqueEval
(
ae
,
"
stdout
"
),
childProcess
.
stdout
);
}
if
(
childProcess
.
stderr
)
{
bindReadable
(
createUniqueEval
(
ae
,
"
stderr
"
),
childProcess
.
stderr
);
}
return
{
onDidDispose
:
(
cb
):
cp
.
ChildProcess
=>
childProcess
.
on
(
"
close
"
,
cb
),
...
...
packages/ide/test/child_process.test.ts
0 → 100644
浏览文件 @
3685e655
import
{
ChildProcess
}
from
"
child_process
"
;
import
*
as
path
from
"
path
"
;
import
{
Readable
}
from
"
stream
"
;
import
*
as
util
from
"
util
"
;
import
{
createClient
}
from
"
@coder/protocol/test
"
;
const
client
=
createClient
();
jest
.
mock
(
"
../src/fill/client
"
,
()
=>
({
client
}));
const
cp
=
require
(
"
../src/fill/child_process
"
)
as
typeof
import
(
"
child_process
"
);
describe
(
"
child_process
"
,
()
=>
{
const
getStdout
=
async
(
proc
:
ChildProcess
):
Promise
<
string
>
=>
{
return
new
Promise
((
r
):
Readable
=>
proc
.
stdout
.
on
(
"
data
"
,
r
))
.
then
((
s
)
=>
s
.
toString
());
};
describe
(
"
exec
"
,
()
=>
{
it
(
"
should get exec stdout
"
,
async
()
=>
{
await
expect
(
util
.
promisify
(
cp
.
exec
)(
"
echo test
"
,
{
encoding
:
"
utf8
"
}))
.
resolves
.
toEqual
({
stdout
:
"
test
\n
"
,
stderr
:
""
,
});
});
});
describe
(
"
spawn
"
,
()
=>
{
it
(
"
should get spawn stdout
"
,
async
()
=>
{
const
proc
=
cp
.
spawn
(
"
echo
"
,
[
"
test
"
]);
await
expect
(
Promise
.
all
([
getStdout
(
proc
),
new
Promise
((
r
):
ChildProcess
=>
proc
.
on
(
"
exit
"
,
r
)),
]).
then
((
values
)
=>
values
[
0
])).
resolves
.
toEqual
(
"
test
\n
"
);
});
it
(
"
should cat
"
,
async
()
=>
{
const
proc
=
cp
.
spawn
(
"
cat
"
,
[]);
expect
(
proc
.
pid
).
toBe
(
-
1
);
proc
.
stdin
.
write
(
"
banana
"
);
await
expect
(
getStdout
(
proc
)).
resolves
.
toBe
(
"
banana
"
);
proc
.
stdin
.
end
();
proc
.
kill
();
expect
(
proc
.
pid
).
toBeGreaterThan
(
-
1
);
await
new
Promise
((
r
):
ChildProcess
=>
proc
.
on
(
"
exit
"
,
r
));
});
it
(
"
should print env
"
,
async
()
=>
{
const
proc
=
cp
.
spawn
(
"
env
"
,
[],
{
env
:
{
hi
:
"
donkey
"
},
});
await
expect
(
getStdout
(
proc
)).
resolves
.
toContain
(
"
hi=donkey
\n
"
);
});
});
describe
(
"
fork
"
,
()
=>
{
it
(
"
should echo messages
"
,
async
()
=>
{
const
proc
=
cp
.
fork
(
path
.
join
(
__dirname
,
"
forker.js
"
));
proc
.
send
({
bananas
:
true
});
await
expect
(
new
Promise
((
r
):
ChildProcess
=>
proc
.
on
(
"
message
"
,
r
)))
.
resolves
.
toMatchObject
({
bananas
:
true
,
});
proc
.
kill
();
await
new
Promise
((
r
):
ChildProcess
=>
proc
.
on
(
"
exit
"
,
r
));
});
});
});
packages/
protocol
/test/forker.js
→
packages/
ide
/test/forker.js
100755 → 100644
浏览文件 @
3685e655
process
.
on
(
"
message
"
,
(
data
)
=>
{
process
.
send
(
data
);
});
\ No newline at end of file
});
packages/package.json
浏览文件 @
3685e655
...
...
@@ -23,6 +23,7 @@
],
"moduleNameMapper"
:
{
"^.+\\.(s?css|png|svg)$"
:
"<rootDir>/../scripts/dummy.js"
,
"@coder/ide/src/fill/evaluation"
:
"<rootDir>/ide/src/fill/evaluation"
,
"@coder/(.*)/test"
:
"<rootDir>/$1/test"
,
"@coder/(.*)"
:
"<rootDir>/$1/src"
},
...
...
packages/vscode/src/fill/node-pty.ts
浏览文件 @
3685e655
...
...
@@ -42,9 +42,9 @@ class Pty implements nodePty.IPty {
ptyProc
.
on
(
"
data
"
,
(
data
)
=>
ae
.
emit
(
"
data
"
,
data
));
ae
.
on
(
"
resize
"
,
(
cols
,
rows
)
=>
ptyProc
.
resize
(
cols
,
rows
));
ae
.
on
(
"
write
"
,
(
data
)
=>
ptyProc
.
write
(
data
));
ae
.
on
(
"
kill
"
,
(
signal
)
=>
ptyProc
.
kill
(
signal
));
ae
.
on
(
"
resize
"
,
(
cols
:
number
,
rows
:
number
)
=>
ptyProc
.
resize
(
cols
,
rows
));
ae
.
on
(
"
write
"
,
(
data
:
string
)
=>
ptyProc
.
write
(
data
));
ae
.
on
(
"
kill
"
,
(
signal
:
string
)
=>
ptyProc
.
kill
(
signal
));
return
{
onDidDispose
:
(
cb
):
void
=>
ptyProc
.
on
(
"
exit
"
,
cb
),
...
...
packages/vscode/src/fill/spdlog.ts
浏览文件 @
3685e655
...
...
@@ -9,22 +9,22 @@ const ae = client.run((ae) => {
const
spdlog
=
__non_webpack_require__
(
"
spdlog
"
)
as
typeof
import
(
"
spdlog
"
);
const
loggers
=
new
Map
<
number
,
NodeRotatingLogger
>
();
ae
.
on
(
"
new
"
,
(
id
,
name
,
filePath
,
fileSize
,
fileCount
)
=>
{
ae
.
on
(
"
new
"
,
(
id
:
number
,
name
:
string
,
filePath
:
string
,
fileSize
:
number
,
fileCount
:
number
)
=>
{
const
logger
=
new
spdlog
.
RotatingLogger
(
name
,
filePath
,
fileSize
,
fileCount
);
loggers
.
set
(
id
,
logger
);
});
ae
.
on
(
"
clearFormatters
"
,
(
id
)
=>
loggers
.
get
(
id
)
!
.
clearFormatters
());
ae
.
on
(
"
critical
"
,
(
id
,
message
)
=>
loggers
.
get
(
id
)
!
.
critical
(
message
));
ae
.
on
(
"
debug
"
,
(
id
,
message
)
=>
loggers
.
get
(
id
)
!
.
debug
(
message
));
ae
.
on
(
"
drop
"
,
(
id
)
=>
loggers
.
get
(
id
)
!
.
drop
());
ae
.
on
(
"
errorLog
"
,
(
id
,
message
)
=>
loggers
.
get
(
id
)
!
.
error
(
message
));
ae
.
on
(
"
flush
"
,
(
id
)
=>
loggers
.
get
(
id
)
!
.
flush
());
ae
.
on
(
"
info
"
,
(
id
,
message
)
=>
loggers
.
get
(
id
)
!
.
info
(
message
));
ae
.
on
(
"
setAsyncMode
"
,
(
bufferSize
,
flushInterval
)
=>
spdlog
.
setAsyncMode
(
bufferSize
,
flushInterval
));
ae
.
on
(
"
setLevel
"
,
(
id
,
level
)
=>
loggers
.
get
(
id
)
!
.
setLevel
(
level
));
ae
.
on
(
"
trace
"
,
(
id
,
message
)
=>
loggers
.
get
(
id
)
!
.
trace
(
message
));
ae
.
on
(
"
warn
"
,
(
id
,
message
)
=>
loggers
.
get
(
id
)
!
.
warn
(
message
));
ae
.
on
(
"
clearFormatters
"
,
(
id
:
number
)
=>
loggers
.
get
(
id
)
!
.
clearFormatters
());
ae
.
on
(
"
critical
"
,
(
id
:
number
,
message
:
string
)
=>
loggers
.
get
(
id
)
!
.
critical
(
message
));
ae
.
on
(
"
debug
"
,
(
id
:
number
,
message
:
string
)
=>
loggers
.
get
(
id
)
!
.
debug
(
message
));
ae
.
on
(
"
drop
"
,
(
id
:
number
)
=>
loggers
.
get
(
id
)
!
.
drop
());
ae
.
on
(
"
errorLog
"
,
(
id
:
number
,
message
:
string
)
=>
loggers
.
get
(
id
)
!
.
error
(
message
));
ae
.
on
(
"
flush
"
,
(
id
:
number
)
=>
loggers
.
get
(
id
)
!
.
flush
());
ae
.
on
(
"
info
"
,
(
id
:
number
,
message
:
string
)
=>
loggers
.
get
(
id
)
!
.
info
(
message
));
ae
.
on
(
"
setAsyncMode
"
,
(
bufferSize
:
number
,
flushInterval
:
number
)
=>
spdlog
.
setAsyncMode
(
bufferSize
,
flushInterval
));
ae
.
on
(
"
setLevel
"
,
(
id
:
number
,
level
:
number
)
=>
loggers
.
get
(
id
)
!
.
setLevel
(
level
));
ae
.
on
(
"
trace
"
,
(
id
:
number
,
message
:
string
)
=>
loggers
.
get
(
id
)
!
.
trace
(
message
));
ae
.
on
(
"
warn
"
,
(
id
:
number
,
message
:
string
)
=>
loggers
.
get
(
id
)
!
.
warn
(
message
));
const
disposeCallbacks
=
<
Array
<
()
=>
void
>>
[];
...
...
@@ -40,7 +40,7 @@ const ae = client.run((ae) => {
const
spdLogger
=
logger
.
named
(
"
spdlog
"
);
ae
.
on
(
"
close
"
,
()
=>
spdLogger
.
error
(
"
session closed prematurely
"
));
ae
.
on
(
"
error
"
,
(
error
)
=>
spdLogger
.
error
(
error
.
message
));
ae
.
on
(
"
error
"
,
(
error
:
Error
)
=>
spdLogger
.
error
(
error
.
message
));
let
id
=
0
;
export
class
RotatingLogger
implements
NodeRotatingLogger
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录