Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
c4741798
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c4741798
编写于
6月 01, 2014
作者:
O
Oliver Gondža
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor BuildCommandTest
上级
9402bd82
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
15 deletion
+18
-15
test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
+18
-15
未找到文件。
test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
浏览文件 @
c4741798
...
...
@@ -24,8 +24,12 @@
package
hudson.cli
import
org.apache.commons.io.output.TeeOutputStream
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.*;
import
static
org
.
junit
.
Assert
.*
import
hudson.Extension
import
org.junit.Rule
import
org.junit.Test
import
org.jvnet.hudson.test.Bug
...
...
@@ -37,6 +41,7 @@ import org.jvnet.hudson.test.TestExtension
import
org.kohsuke.stapler.StaplerRequest
import
hudson.Launcher
import
hudson.cli.CLICommandInvoker
;
import
hudson.model.AbstractBuild
import
hudson.model.Action
import
hudson.model.BuildListener
...
...
@@ -54,7 +59,9 @@ import hudson.model.StringParameterValue
import
hudson.model.labels.LabelAtom
import
hudson.tasks.Shell
import
hudson.util.OneShotEvent
import
java.util.concurrent.Executor
import
net.sf.json.JSONObject
/**
...
...
@@ -194,8 +201,8 @@ public class BuildCommandTest {
def
invoker
=
new
CLICommandInvoker
(
j
,
new
BuildCommand
());
def
result
=
invoker
.
invokeWithArgs
(
"the-project"
);
assertT
rue
(
"Error message missing"
,
result
.
stderr
().
contains
(
"Cannot build the-project because it is disabled."
));
assert
Equals
(
"Command is expected to fail"
,
-
1
,
result
.
returnCode
(
));
assertT
hat
(
result
,
failedWith
(-
1
));
assert
That
(
result
.
stderr
(),
containsString
(
"Cannot build the-project because it is disabled."
));
assertNull
(
"Project should not be built"
,
project
.
getBuildByNumber
(
1
));
}
...
...
@@ -206,8 +213,8 @@ public class BuildCommandTest {
def
invoker
=
new
CLICommandInvoker
(
j
,
new
BuildCommand
());
def
result
=
invoker
.
invokeWithArgs
(
"new-one"
);
assertT
rue
(
"Error message missing"
,
result
.
stderr
().
contains
(
"Cannot build new-one because its configuration has not been saved."
));
assert
Equals
(
"Command is expected to fail"
,
-
1
,
result
.
returnCode
(
));
assertT
hat
(
result
,
failedWith
(-
1
));
assert
That
(
result
.
stderr
(),
containsString
(
"Cannot build new-one because its configuration has not been saved."
));
assertNull
(
"Project should not be built"
,
newOne
.
getBuildByNumber
(
1
));
}
...
...
@@ -221,7 +228,7 @@ public class BuildCommandTest {
def
invoker
=
new
CLICommandInvoker
(
j
,
new
BuildCommand
());
def
result
=
invoker
.
invokeWithArgs
(
"the-project"
,
"-p"
,
"expr=a=b"
,
"-s"
);
assert
Equals
(
"Command is expected to succeed"
,
0
,
result
.
returnCode
());
assert
That
(
result
,
succeeded
());
assertEquals
(
"a=b"
,
project
.
getBuildByNumber
(
1
).
getBuildVariables
().
get
(
"expr"
));
}
...
...
@@ -249,17 +256,13 @@ public class BuildCommandTest {
// Create CLI & run command
def
invoker
=
new
CLICommandInvoker
(
j
,
new
BuildCommand
());
def
result
=
invoker
.
authorizedTo
(
jenkins
.
model
.
Jenkins
.
ADMINISTER
)
.
invokeWithArgs
(
"foo"
,
"-p"
,
"string=value"
);
assertEquals
(
"Command is expected to fail with -1 code. \nSTDOUT="
+
result
.
stdout
()
+
"\nSTDERR: "
+
result
.
stderr
(),
-
1
,
result
.
returnCode
());
assertTrue
(
"Unexpected error message"
,
result
.
stderr
().
startsWith
(
"No default value for the parameter \'FOO\'."
));
def
result
=
invoker
.
invokeWithArgs
(
"foo"
,
"-p"
,
"string=value"
);
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
.
stderr
(),
containsString
(
"No default value for the parameter \'FOO\'."
));
// Give the job 5 seconds to be submitted
def
q
=
j
.
jenkins
.
getQueue
().
getItem
(
project
);
Thread
.
sleep
(
5000
);
Thread
.
sleep
(
5000
);
// Give the job 5 seconds to be submitted
assertNull
(
"Build should not be scheduled"
,
j
.
jenkins
.
getQueue
().
getItem
(
project
)
);
assertNull
(
"Build should not be scheduled"
,
project
.
getBuildByNumber
(
2
)
);
// Check executors health after a timeout
for
(
def
exec
:
slave
.
toComputer
().
getExecutors
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录