Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
53e457fd
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,发现更多精彩内容 >>
提交
53e457fd
编写于
10月 02, 2013
作者:
W
wwccss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* rewrite the synatx.
上级
feb20660
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
98 addition
and
76 deletion
+98
-76
zt
zt
+98
-76
未找到文件。
zt
浏览文件 @
53e457fd
...
...
@@ -26,8 +26,6 @@ define('DS', DIRECTORY_SEPARATOR);
$config
=
new
stdclass
();
$config
->
timezone
=
'Asia/Shanghai'
;
$config
->
skipfiles
=
'exe,dll,gif,jpg,png,bmp'
;
$config
->
casePrefix
=
'TC'
;
$config
->
casePostfix
=
'TC'
;
/* Ansi control codes. */
$config
->
ansi
=
new
stdclass
();
...
...
@@ -492,12 +490,8 @@ class zentaotest
$interpreter
=
strtolower
(
pathinfo
(
$script
,
PATHINFO_EXTENSION
));
if
(
$interpreter
and
strpos
(
$this
->
config
->
skipfiles
,
$interpreter
)
!==
false
)
continue
;
/* Has TC_BEGIN in the script, save it. */
if
(
strpos
(
file_get_contents
(
$script
),
$this
->
config
->
casePrefix
)
!==
false
)
{
$this
->
scripts
[]
=
realpath
(
$script
);
if
(
$interpreter
)
$this
->
interpreters
[
$interpreter
]
=
$interpreter
;
}
$this
->
scripts
[]
=
realpath
(
$script
);
if
(
$interpreter
)
$this
->
interpreters
[
$interpreter
]
=
$interpreter
;
}
}
}
...
...
@@ -616,47 +610,15 @@ class zentaotest
{
$begin
=
microtime
(
true
);
$this
->
parseScript
(
$script
);
$this
->
getScriptOutput
();
$this
->
computeResult
();
$this
->
current
->
time
=
microtime
(
true
)
-
$begin
;
}
/**
* Parse the script to extract the case definations.
*
* @param string $script
* @access public
* @return void
*/
public
function
parseScript
(
$script
)
{
/* Extract the yaml defination. */
$contents
=
trim
(
file_get_contents
(
$script
));
$begin
=
strpos
(
$contents
,
$this
->
config
->
casePrefix
)
+
strlen
(
$this
->
config
->
casePrefix
);
$end
=
strpos
(
$contents
,
$this
->
config
->
casePostfix
);
$yaml
=
substr
(
$contents
,
$begin
,
$end
-
$begin
);
/* Parse the yaml. */
$this
->
current
=
(
object
)
spyc
::
yamlLoadString
(
$yaml
);
/* Set the default value of expect. */
if
(
!
isset
(
$this
->
current
->
expect
))
$this
->
current
->
expect
=
''
;
/* Append the script file name and interpreter. */
$this
->
current
=
new
stdclass
();
$this
->
current
->
script
=
$script
;
$this
->
current
->
interpreter
=
pathinfo
(
$script
,
PATHINFO_EXTENSION
);
/* Check whether the expect file exists. */
$path
=
pathinfo
(
$script
);
$expectFile
=
str_replace
(
$path
[
'basename'
],
'.'
.
$path
[
'basename'
],
$script
);
$expectFile
=
str_replace
(
'.'
.
$path
[
'extension'
],
'.et'
,
$expectFile
);
if
(
is_file
(
$expectFile
))
return
$this
->
current
->
expect
=
trim
(
$this
->
dos2unix
(
file_get_contents
(
$expectFile
)));
$this
->
current
->
interpreter
=
pathinfo
(
$script
,
PATHINFO_EXTENSION
);
$this
->
getScriptOutput
();
$this
->
parseOutput
();
$this
->
computeCaseResult
();
/* Check whether the expectx file exists. */
$expectxFile
=
str_replace
(
'.et'
,
'.ex'
,
$expectFile
);
if
(
is_file
(
$expectxFile
))
return
$this
->
current
->
expectx
=
trim
(
$this
->
dos2unix
(
file_get_contents
(
$expectxFile
)));
$this
->
current
->
time
=
microtime
(
true
)
-
$begin
;
}
/**
...
...
@@ -709,55 +671,110 @@ class zentaotest
}
/**
* Compute the result by comparing the expect and output.
* Parse the output into yaml format and ste title, steps to current script object.
*
* @access public
* @return void
*/
public
function
parseOutput
()
{
$output
=
(
object
)
spyc
::
yamlLoadString
(
$this
->
current
->
output
);
$this
->
current
->
title
=
$output
->
title
;
$this
->
current
->
steps
=
$output
->
steps
;
}
/**
* Compute the result of current case.
*
* @access public
* @return void
*/
public
function
computeCaseResult
()
{
/* First to check the case skip or not. */
if
(
strpos
(
$this
->
current
->
output
,
'skip'
)
!==
false
)
{
$this
->
current
->
result
=
'skip'
;
$this
->
results
[
'skip'
]
++
;
return
true
;
}
$diff
=
''
;
$result
=
'pass'
;
/* Compute result of every step. */
foreach
(
$this
->
current
->
steps
as
$step
)
{
$step
=
(
object
)
$step
;
$this
->
computeStepResult
(
$step
);
if
(
$step
->
result
==
'fail'
)
{
$result
=
'fail'
;
break
;
}
}
if
(
$result
==
'fail'
)
{
$this
->
current
->
result
=
'fail'
;
$this
->
results
[
'fail'
]
++
;
$this
->
failedScripts
[]
=
$this
->
current
;
return
false
;
}
$this
->
current
->
result
=
'pass'
;
$this
->
results
[
'pass'
]
++
;
return
true
;
}
/**
* Compute result of a step by comparing the expect and output of every step.
*
* @access public
* @return void
*/
public
function
compute
Result
(
)
public
function
compute
StepResult
(
$step
)
{
if
(
!
isset
(
$step
->
expect
))
$step
->
expect
=
''
;
/* If the output is skip, skip this script. */
if
(
$
this
->
current
->
output
==
'skip'
)
if
(
$
step
->
output
==
'skip'
)
{
$this
->
current
->
result
=
'skip'
;
$this
->
results
[
'skip'
]
++
;
$step
->
result
=
'skip'
;
return
true
;
}
/* First try to compare the expect and output. */
if
(
strcmp
(
$
this
->
current
->
expect
,
$this
->
current
->
output
)
===
0
)
if
(
strcmp
(
$
step
->
expect
,
$step
->
output
)
===
0
)
{
$this
->
current
->
result
=
'pass'
;
$this
->
results
[
'pass'
]
++
;
$step
->
result
=
'pass'
;
return
true
;
}
/* Then try to get regular from expectx or try convert format chars in expect field.. */
$regulars
=
''
;
if
(
isset
(
$
this
->
current
->
expectx
))
if
(
isset
(
$
step
->
expectx
))
{
$regulars
=
$
this
->
current
->
expectx
;
$regulars
=
$
step
->
expectx
;
}
elseif
(
strpos
(
$
this
->
current
->
expect
,
'%'
)
!==
false
)
elseif
(
strpos
(
$
step
->
expect
,
'%'
)
!==
false
)
{
$expect
=
$this
->
convertFormat2REG
(
$
this
->
current
->
expect
);
if
(
$expect
!=
$
this
->
current
->
expect
)
$regulars
=
$expect
;
$expect
=
$this
->
convertFormat2REG
(
$
step
->
expect
);
if
(
$expect
!=
$
step
->
expect
)
$regulars
=
$expect
;
}
/* No regulars found, fail. */
if
(
!
$regulars
)
{
$this
->
current
->
result
=
'fail'
;
$this
->
current
->
diff
=
$this
->
diff
(
$this
->
current
->
expect
,
$this
->
current
->
output
)
.
"
\n
"
;
$this
->
failedScripts
[]
=
$this
->
current
;
$this
->
results
[
'fail'
]
++
;
$step
->
result
=
'fail'
;
$step
->
diff
=
$this
->
diff
(
$step
->
expect
,
$step
->
output
)
.
"
\n
"
;
return
false
;
}
/* Compare the results by regular. */
$regulars
=
explode
(
"
\n
"
,
$regulars
);
$output
=
explode
(
"
\n
"
,
$
this
->
current
->
output
);
$output
=
explode
(
"
\n
"
,
$
step
->
output
);
foreach
(
$regulars
as
$line
=>
$regular
)
{
if
(
isset
(
$output
[
$line
])
and
preg_match
(
"/^
$regular
$/s"
,
$output
[
$line
]))
$regulars
[
$line
]
=
$output
[
$line
];
...
...
@@ -765,19 +782,16 @@ class zentaotest
if
(
$regulars
==
$output
)
{
$this
->
current
->
result
=
'pass'
;
$this
->
results
[
'pass'
]
++
;
$step
->
result
=
'pass'
;
return
true
;
}
else
{
if
(
isset
(
$
this
->
current
->
expectx
))
$diff
=
$this
->
diff
(
join
(
"
\n
"
,
$regulars
),
join
(
"
\n
"
,
$output
));
if
(
!
isset
(
$
this
->
current
->
expectx
))
$diff
=
$this
->
diff
(
$this
->
current
->
expect
,
$this
->
current
->
output
);
if
(
isset
(
$
step
->
expectx
))
$diff
=
$this
->
diff
(
join
(
"
\n
"
,
$regulars
),
join
(
"
\n
"
,
$output
));
if
(
!
isset
(
$
step
->
expectx
))
$diff
=
$this
->
diff
(
$step
->
expect
,
$step
->
output
);
$this
->
current
->
result
=
'fail'
;
$this
->
current
->
diff
=
$diff
;
$this
->
failedScripts
[]
=
$this
->
current
;
$this
->
results
[
'fail'
]
++
;
$step
->
result
=
'fail'
;
$step
->
diff
=
$diff
;
return
false
;
}
}
...
...
@@ -964,10 +978,19 @@ class zentaotest
$this
->
reportInfo
.
=
"
\n
"
;
foreach
(
$this
->
failedScripts
as
$script
)
{
$expect
=
isset
(
$script
->
expectx
)
?
$script
->
expectx
:
$script
->
expect
;
$script
->
expect
=
''
;
$script
->
output
=
''
;
foreach
(
$script
->
steps
as
$step
)
{
$step
=
(
object
)
$step
;
$script
->
expect
.
=
(
isset
(
$step
->
expectx
)
?
$step
->
expectx
:
$step
->
expect
)
.
"
\n
"
;
$script
->
output
.
=
$step
->
output
.
"
\n
"
;
}
$script
->
diff
=
$this
->
diff
(
$script
->
expect
,
$script
->
output
);
$this
->
reportInfo
.
=
"
\n
{{===
\n
failed
$script->script
<
$script->title
>}}
\n
"
;
$this
->
reportInfo
.
=
"[expect]
\n
$
expect
\n
\n
"
;
$this
->
reportInfo
.
=
"[output]
\n
$script->output
\n
\n
"
;
$this
->
reportInfo
.
=
"[expect]
\n
$
script->expect
\n
"
;
$this
->
reportInfo
.
=
"[output]
\n
$script->output
\n
"
;
$this
->
reportInfo
.
=
"[diff]
\n
$script->diff
"
;
$this
->
reportInfo
.
=
"
\n
===}}
\n
"
;
}
...
...
@@ -1034,7 +1057,6 @@ class zentaotest
return
str_replace
(
"
\n
"
,
"
\r\n
"
,
$string
);
}
/**
* Process lang item, if the charset is not utf-8, convert it.
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录