Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
d8979177
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
11 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d8979177
编写于
5月 27, 2013
作者:
W
wwccss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* add the support for multi language.
上级
495ea841
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
112 addition
and
9 deletion
+112
-9
zt
zt
+112
-9
未找到文件。
zt
浏览文件 @
d8979177
...
...
@@ -40,6 +40,29 @@ $config->ansi->green = "\033[32m";
$config
->
ansi
->
yellow
=
"
\033
[33m"
;
$config
->
ansi
->
purple
=
"
\033
[35m"
;
/* Supportted languages. */
$config
->
langs
[
'en'
][
'label'
]
=
'English'
;
$config
->
langs
[
'cn'
][
'label'
]
=
'Chinese Simplified'
;
$config
->
langs
[
'cn'
][
'charsets'
][
'gbk'
]
=
'GBK'
;
$config
->
langs
[
'cn'
][
'charsets'
][
'utf-8'
]
=
'UTF-8'
;
/* Languages. */
$lang
=
new
stdclass
();
$lang
->
en
=
new
stdclass
();
$lang
->
cn
=
new
stdclass
();
$lang
->
en
->
foundScripts
=
"%s, found %s scripts.
\n\n
"
;
$lang
->
en
->
failedScripts
=
"
\n
Failed scripts:
\n
"
;
$lang
->
en
->
summary
=
"
\n
%s run %s scripts in %s seconds. "
;
$lang
->
en
->
reportFile
=
"Report: %s
\n
"
;
$lang
->
cn
->
foundScripts
=
"%s, 共发现了%s个脚本。
\n\n
"
;
$lang
->
cn
->
failedScripts
=
"
\n
失败的用例:
\n
"
;
$lang
->
cn
->
summary
=
"
\n
%s 共执行了%s个用例,耗时%s秒. "
;
$lang
->
cn
->
reportFile
=
"报表文件:%s
\n
"
;
/* Run testing. */
zentaotest
::
run
(
isset
(
$argv
[
1
])
?
$argv
[
1
]
:
'./'
);
...
...
@@ -54,6 +77,14 @@ class zentaotest
*/
public
$config
;
/**
* The language object.
*
* @var int
* @access public
*/
public
$lang
;
/**
* The os type.
*
...
...
@@ -196,6 +227,7 @@ class zentaotest
$this
->
setHome
();
$this
->
setProfile
();
$this
->
loadSettings
();
$this
->
setLang
();
$this
->
setCWD
();
$this
->
setTimeZone
();
$this
->
setReportFile
();
...
...
@@ -273,7 +305,6 @@ class zentaotest
{
$this
->
home
=
getenv
(
'HOME'
)
.
DS
;
}
}
/**
...
...
@@ -315,6 +346,68 @@ class zentaotest
file_put_contents
(
$this
->
profile
,
json_encode
(
$this
->
settings
));
}
/**
* Set language.
*
* @access public
* @return void
*/
public
function
setLang
()
{
if
(
!
isset
(
$this
->
settings
->
lang
))
{
while
(
true
)
{
$langs
=
array_keys
(
$this
->
config
->
langs
);
echo
"Please select your favorite language:
\n
"
;
$i
=
1
;
foreach
(
$this
->
config
->
langs
as
$lang
)
{
echo
"(
$i
)
$lang[label]
\n
"
;
$i
++
;
}
$input
=
trim
(
fgets
(
STDIN
));
$langCode
=
isset
(
$langs
[
$input
-
1
])
?
$langs
[
$input
-
1
]
:
''
;
if
(
!
$langCode
)
continue
;
$lang
=
$this
->
config
->
langs
[
$langCode
];
$charset
=
'utf-8'
;
if
(
isset
(
$lang
[
'charsets'
]))
{
$charsets
=
array_keys
(
$lang
[
'charsets'
]);
while
(
true
)
{
echo
"Please select charset:
\n
"
;
$i
=
1
;
foreach
(
$lang
[
'charsets'
]
as
$charset
)
{
echo
"(
$i
)
$charset
\n
"
;
$i
++
;
}
$input
=
trim
(
fgets
(
STDIN
));
$charset
=
isset
(
$charsets
[
$input
-
1
])
?
$charsets
[
$input
-
1
]
:
''
;
if
(
!
$charset
)
continue
;
break
;
}
}
/* Update the settings. */
$this
->
settings
->
lang
=
$langCode
;
$this
->
settings
->
charset
=
$charset
;
$this
->
saveSettings
();
break
;
}
}
global
$lang
;
$this
->
lang
=
$lang
->
{
$this
->
settings
->
lang
};
}
/**
* Set current working directory.
*
...
...
@@ -345,7 +438,7 @@ class zentaotest
*/
public
function
setReportFile
()
{
$this
->
reportFile
=
$this
->
temp
.
DS
.
date
(
'Ymd.Hi'
)
.
'.log'
;
$this
->
reportFile
=
$this
->
temp
.
date
(
'Ymd.Hi'
)
.
'.log'
;
}
/**
...
...
@@ -498,7 +591,7 @@ class zentaotest
*/
public
function
printTotal
()
{
$totalInfo
=
date
(
'n/j G:i:s'
)
.
" found "
.
$this
->
colorString
(
count
(
$this
->
scripts
),
$this
->
config
->
ansi
->
yellow
)
.
" scripts.
\n\n
"
;
$totalInfo
=
sprintf
(
$this
->
processLang
(
$this
->
lang
->
foundScripts
),
date
(
'n/j G:i:s'
),
$this
->
colorString
(
count
(
$this
->
scripts
),
$this
->
config
->
ansi
->
yellow
))
;
(
print
(
$totalInfo
))
&&
$this
->
reportInfo
.
=
$totalInfo
;
}
...
...
@@ -814,7 +907,7 @@ class zentaotest
$this
->
setMaxLength
(
$scriptFiles
);
/* Print info of failed scripts. */
$failedInfo
=
"
\n
Failed scripts:
\n
"
;
$failedInfo
=
$this
->
processLang
(
$this
->
lang
->
failedScripts
)
;
(
print
(
$failedInfo
))
&&
$this
->
reportInfo
.
=
$failedInfo
;
foreach
(
$this
->
failedScripts
as
$script
)
{
...
...
@@ -834,8 +927,10 @@ class zentaotest
*/
public
function
printSummary
()
{
$summary
=
"
\n
"
.
date
(
"n/j G:i:s"
)
.
' run '
.
$this
->
colorString
(
count
(
$this
->
scripts
),
$this
->
config
->
ansi
->
yellow
)
.
' scripts '
;
$summary
.
=
"in "
.
round
(
$this
->
end
-
$this
->
begin
,
2
)
.
's. '
;
$now
=
date
(
"n/j G:i:s"
);
$scripts
=
$this
->
colorString
(
count
(
$this
->
scripts
),
$this
->
config
->
ansi
->
yellow
);
$seconds
=
round
(
$this
->
end
-
$this
->
begin
,
2
);
$summary
=
sprintf
(
$this
->
processLang
(
$this
->
lang
->
summary
),
$now
,
$scripts
,
$seconds
);
$passRate
=
'('
.
round
(
$this
->
results
[
'pass'
]
/
count
(
$this
->
scripts
),
3
)
*
100
.
'%'
.
')'
;
$failRate
=
'('
.
round
(
$this
->
results
[
'fail'
]
/
count
(
$this
->
scripts
),
3
)
*
100
.
'%'
.
')'
;
...
...
@@ -872,7 +967,7 @@ class zentaotest
}
file_put_contents
(
$this
->
reportFile
,
$this
->
removeColor
(
$this
->
reportInfo
));
echo
'Report: '
.
$this
->
colorString
(
$this
->
reportFile
,
$this
->
config
->
ansi
->
yellow
)
.
" .
\n
"
;
printf
(
$this
->
processLang
(
$this
->
lang
->
reportFile
),
$this
->
colorString
(
$this
->
reportFile
,
$this
->
config
->
ansi
->
yellow
))
;
}
/**
...
...
@@ -919,9 +1014,17 @@ class zentaotest
return
str_replace
(
"
\r
"
,
''
,
$string
);
}
public
function
printIconv
(
$string
)
/**
* Process lang item, if the charset is not utf-8, convert it.
*
* @param string $string
* @access public
* @return string
*/
public
function
processLang
(
$string
)
{
echo
iconv
(
'utf-8'
,
'gbk'
,
$string
);
if
(
!
function_exists
(
'iconv'
)
or
$this
->
settings
->
charset
==
'utf-8'
)
return
$string
;
return
iconv
(
'utf-8'
,
$this
->
settings
->
charset
,
$string
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录