Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Five-菜鸟级
echarts
提交
004dfecf
E
echarts
项目概览
Five-菜鸟级
/
echarts
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
echarts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
004dfecf
编写于
9月 18, 2019
作者:
S
sushuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(test): support `npm run mktest some-test-file`.
上级
105bde53
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
235 addition
and
0 deletion
+235
-0
package.json
package.json
+1
-0
test/build/mktest-tpl.html
test/build/mktest-tpl.html
+80
-0
test/build/mktest.js
test/build/mktest.js
+154
-0
未找到文件。
package.json
浏览文件 @
004dfecf
...
...
@@ -20,6 +20,7 @@
"prepublish"
:
"node build/build.js --prepublish"
,
"test:visual"
:
"node test/runTest/server.js"
,
"test"
:
"node build/build.js"
,
"mktest"
:
"node test/build/mktest.js"
,
"lint"
:
"./node_modules/.bin/eslint src extension-src"
,
"lint:dist"
:
"echo 'It might take a while. Please wait ...' && ./node_modules/.bin/jshint --config .jshintrc-dist dist/echarts.js"
},
...
...
test/build/mktest-tpl.html
0 → 100644
浏览文件 @
004dfecf
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<script
src=
"lib/esl.js"
></script>
<script
src=
"lib/config.js"
></script>
<script
src=
"lib/jquery.min.js"
></script>
<script
src=
"lib/facePrint.js"
></script>
<script
src=
"lib/testHelper.js"
></script>
<!-- <script src="ut/lib/canteen.js"></script> -->
<link
rel=
"stylesheet"
href=
"lib/reset.css"
/>
</head>
<body>
<style>
</style>
<!-- TPL_DOM_PLACE -->
<!-- TPL_JS_PLACE -->
</body>
</html>
<!-- TPL_SEGMENT_DELIMITER -->
<div
id=
"{{TPL_DOM_ID}}"
></div>
<!-- TPL_SEGMENT_DELIMITER -->
<script>
require
([
'
echarts
'
/*, 'map/js/china' */
],
function
(
echarts
)
{
var
option
;
// $.getJSON('./data/nutrients.json', function (data) {});
option
=
{
xAxis
:
{},
yAxis
:
{},
series
:
{
type
:
'
line
'
,
data
:
[[
11
,
22
],
[
33
,
44
]]
}
};
var
chart
=
testHelper
.
create
(
echarts
,
'
{{TPL_DOM_ID}}
'
,
{
title
:
[
'
Test Case Description of {{TPL_DOM_ID}}
'
,
'
(Muliple lines and **emphasis** are supported in description)
'
],
option
:
option
// height: 300,
// buttons: [{text: 'btn-txt', onclick: function () {}}],
// recordCanvas: true,
});
});
</script>
test/build/mktest.js
0 → 100755
浏览文件 @
004dfecf
#!/usr/bin/env node
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const
nodeFS
=
require
(
'
fs
'
);
const
assert
=
require
(
'
assert
'
);
const
nodePath
=
require
(
'
path
'
);
const
commander
=
require
(
'
commander
'
);
const
{
color
}
=
require
(
'
zrender/build/helper
'
);
const
colorFgCyanDim
=
color
(
'
fgCyan
'
,
'
dim
'
);
const
colorFgGreen
=
color
(
'
fgGreen
'
);
const
colorFgRed
=
color
(
'
fgRed
'
);
const
testDir
=
nodePath
.
resolve
(
__dirname
,
'
..
'
);
const
testTplPath
=
nodePath
.
resolve
(
__dirname
,
'
mktest-tpl.html
'
);
const
tplSegmentDelimiter
=
'
<!-- TPL_SEGMENT_DELIMITER -->
'
;
const
tagDomId
=
/{{TPL_DOM_ID}}/g
;
const
tagDomPlace
=
'
<!-- TPL_DOM_PLACE -->
'
;
const
tagJSPlace
=
'
<!-- TPL_JS_PLACE -->
'
;
const
manualText
=
`
${
colorFgCyanDim
(
'
Usage:
'
)}
# Make a file named "bar-action.html" in directory "echarts/test" with 1 initial chart.
${
colorFgGreen
(
'
npm run mktest bar-action
'
)}
# or
${
colorFgGreen
(
'
npm run mktest bar-action.html
'
)}
# or
${
colorFgGreen
(
'
node ./test/build/mktest bar-action
'
)}
# Make a file named "bar-action.html" in directory "echarts/test" with 5 initial charts.
${
colorFgGreen
(
'
npm run mktest bar-action 5
'
)}
# or
${
colorFgGreen
(
'
node ./test/build/mktest bar-action 5
'
)}
`
;
function
run
()
{
let
opt
=
prepareOpt
();
if
(
!
opt
)
{
return
;
}
if
(
nodeFS
.
existsSync
(
opt
.
testFilePath
))
{
printError
(
`The file
${
opt
.
testFilePath
}
exists! Please chose another name.`
);
printError
(
'
Please chose another name.
'
);
return
;
}
const
testTplContent
=
nodeFS
.
readFileSync
(
testTplPath
,
{
encoding
:
'
utf8
'
});
const
testFileContent
=
makeTestFileContent
(
opt
,
testTplContent
);
nodeFS
.
writeFileSync
(
opt
.
testFilePath
,
testFileContent
,
{
encoding
:
'
utf8
'
});
console
.
log
(
`A test file has been added in: \n
${
colorFgGreen
(
opt
.
testFilePath
)}
`
);
console
.
log
();
}
function
prepareOpt
()
{
commander
.
usage
(
'
test-file-name [chart-number]
'
)
.
description
(
manualText
)
.
parse
(
process
.
argv
);
let
args
=
commander
.
args
||
[];
let
testFileName
=
args
[
0
];
let
testCaseNumber
=
args
[
1
];
if
(
isNaN
(
testCaseNumber
))
{
testCaseNumber
=
1
;
}
if
(
!
testFileName
)
{
printError
(
'
Must input a file name!
'
);
return
;
}
testFileName
=
normalizeInputExt
(
testFileName
);
let
testFilePath
=
nodePath
.
resolve
(
testDir
,
testFileName
);
return
{
testFileName
:
testFileName
,
testFilePath
:
testFilePath
,
testCaseNumber
:
testCaseNumber
};
}
function
makeTestFileContent
(
opt
,
testTplContent
)
{
const
testTplSegments
=
testTplContent
.
split
(
tplSegmentDelimiter
);
const
tplSegMain
=
testTplSegments
[
0
];
const
tplSegDom
=
testTplSegments
[
1
];
const
tplSegJS
=
testTplSegments
[
2
];
assert
(
tplSegMain
&&
tplSegDom
&&
tplSegJS
);
let
segDomList
=
[];
let
segJSList
=
[];
for
(
let
i
=
0
;
i
<
opt
.
testCaseNumber
;
i
++
)
{
let
domId
=
'
main
'
+
i
;
segDomList
.
push
(
tplSegDom
.
replace
(
tagDomId
,
domId
));
segJSList
.
push
(
tplSegJS
.
replace
(
tagDomId
,
domId
));
}
let
htmlContent
=
tplSegMain
.
replace
(
tagDomPlace
,
segDomList
.
join
(
'
\n
'
))
.
replace
(
tagJSPlace
,
segJSList
.
join
(
'
\n
'
));
return
htmlContent
;
}
function
normalizeInputExt
(
testFileName
)
{
if
(
hasExt
(
testFileName
,
'
.html
'
))
{
return
testFileName
;
}
else
if
(
hasExt
(
testFileName
,
'
.htm
'
))
{
return
testFileName
+
'
l
'
;
}
else
{
return
testFileName
+
'
.html
'
;
}
function
hasExt
(
fileName
,
ext
)
{
let
idx
=
fileName
.
lastIndexOf
(
ext
);
return
idx
>=
0
&&
idx
===
fileName
.
length
-
ext
.
length
;
}
}
function
printError
(
msg
)
{
console
.
error
(
colorFgRed
(
'
[ERROR]:
'
+
msg
));
}
run
();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录