Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
e0596caa
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
e0596caa
编写于
5月 10, 2023
作者:
Z
zhaoke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support win and mac .
上级
6e09eae9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
87 addition
and
6 deletion
+87
-6
internal/pkg/helper/exec/report-ztf.go
internal/pkg/helper/exec/report-ztf.go
+3
-3
pkg/lib/shell/terminal-darkwin.go
pkg/lib/shell/terminal-darkwin.go
+9
-3
pkg/lib/shell/terminal-unix.go
pkg/lib/shell/terminal-unix.go
+30
-0
pkg/lib/shell/terminal-win.go
pkg/lib/shell/terminal-win.go
+45
-0
未找到文件。
internal/pkg/helper/exec/report-ztf.go
浏览文件 @
e0596caa
...
...
@@ -66,7 +66,7 @@ func GenZTFTestReport(report commDomain.ZtfReport, pathMaxWidth int,
divider
:=
"--------------------------------"
window
:=
shellUtils
.
WindowSize
()
if
window
.
Col
!=
0
{
divider
=
strings
.
Repeat
(
"-"
,
int
(
window
.
Col
)
)
divider
=
strings
.
Repeat
(
"-"
,
window
.
Col
)
}
msgFail
+=
divider
...
...
@@ -93,7 +93,7 @@ func GenZTFTestReport(report commDomain.ZtfReport, pathMaxWidth int,
failStr
:=
fmt
.
Sprintf
(
fmtStr
,
i118Utils
.
Sprintf
(
"fail_num"
),
report
.
Fail
,
float32
(
failRate
))
skipStr
:=
fmt
.
Sprintf
(
fmtStr
,
i118Utils
.
Sprintf
(
"skip_num"
),
report
.
Skip
,
float32
(
skipRate
))
if
commConsts
.
ExecFrom
==
commConsts
.
FromCmd
{
if
commConsts
.
ExecFrom
==
commConsts
.
FromCmd
{
passStr
=
fmt
.
Sprintf
(
fmtStr
,
color
.
New
(
color
.
FgGreen
)
.
Sprint
(
i118Utils
.
Sprintf
(
"pass_num"
)),
report
.
Pass
,
float32
(
passRate
))
failStr
=
fmt
.
Sprintf
(
fmtStr
,
color
.
New
(
color
.
FgRed
)
.
Sprint
(
i118Utils
.
Sprintf
(
"fail_num"
)),
report
.
Fail
,
float32
(
failRate
))
skipStr
=
fmt
.
Sprintf
(
fmtStr
,
color
.
New
(
color
.
FgYellow
)
.
Sprint
(
i118Utils
.
Sprintf
(
"skip_num"
)),
report
.
Skip
,
float32
(
skipRate
))
...
...
@@ -144,7 +144,7 @@ func appendFailedStepResult(cs commDomain.FuncResult, failedSteps *[]string) (pa
step
.
Id
=
strings
.
TrimRight
(
step
.
Id
,
"."
)
status
:=
i118Utils
.
Sprintf
(
string
(
step
.
Status
))
if
commConsts
.
ExecFrom
==
commConsts
.
FromCmd
{
if
commConsts
.
ExecFrom
==
commConsts
.
FromCmd
{
if
step
.
Status
==
commConsts
.
FAIL
{
status
=
color
.
New
(
color
.
FgRed
)
.
Sprint
(
status
)
}
else
if
step
.
Status
==
commConsts
.
PASS
{
...
...
pkg/lib/shell/terminal.go
→
pkg/lib/shell/terminal
-darkwin
.go
浏览文件 @
e0596caa
//go:build darwin
// +build darwin
package
shellUtils
import
(
"runtime"
"syscall"
"unsafe"
)
type
window
struct
{
Row
uint16
Col
uint16
Row
int
Col
int
}
func
WindowSize
()
window
{
win
:=
window
{
0
,
0
}
tio
:=
syscall
.
TIOCGWINSZ_OSX
res
,
_
,
_
:=
syscall
.
Syscall
(
syscall
.
SYS_IOCTL
,
uintptr
(
syscall
.
Stdin
),
uintptr
(
syscall
.
TIOCGWINSZ
),
//此参数,不同的操作系统可能不一样,例如:TIOCGWINSZ_OSX
uintptr
(
tio
),
uintptr
(
unsafe
.
Pointer
(
&
win
)),
)
if
int
(
res
)
==
-
1
{
...
...
pkg/lib/shell/terminal-unix.go
0 → 100644
浏览文件 @
e0596caa
//go:build linux
// +build linux
package
shellUtils
import
(
"syscall"
"unsafe"
)
type
window
struct
{
Row
int
Col
int
}
func
WindowSize
()
window
{
win
:=
window
{
0
,
0
}
tio
:=
syscall
.
TIOCGWINSZ
res
,
_
,
_
:=
syscall
.
Syscall
(
syscall
.
SYS_IOCTL
,
uintptr
(
syscall
.
Stdin
),
uintptr
(
tio
),
uintptr
(
unsafe
.
Pointer
(
&
win
)),
)
if
int
(
res
)
==
-
1
{
return
window
{
0
,
0
}
}
return
win
}
pkg/lib/shell/terminal-win.go
0 → 100644
浏览文件 @
e0596caa
//go:build windows
// +build windows
package
execHelper
import
(
"fmt"
"os/exec"
"strings"
"syscall"
)
type
window
struct
{
Row
int
Col
int
}
func
WindowSize
(
uuid
string
)
window
{
win
:=
window
{
0
,
0
}
cmd1
:=
exec
.
Command
(
"cmd"
)
cmd1
.
SysProcAttr
=
&
syscall
.
SysProcAttr
{
CmdLine
:
"/c mode con"
,
HideWindow
:
true
}
out
,
_
:=
cmd1
.
Output
()
lines
:=
strings
.
Split
(
string
(
out
),
"
\n
"
)
for
index
,
line
:=
range
lines
{
if
win
.
Row
>
0
&&
win
.
Col
>
0
{
return
win
}
line
=
strings
.
TrimSpace
(
line
)
if
strings
.
Contain
(
"行"
)
||
strings
.
Contain
(
"Row"
)
{
re
:=
regexp
.
MustCompile
(
`\d+`
)
rs
:=
re
.
FindAllString
(
out
.
String
(),
-
1
)
win
.
Row
,
_
=
strconv
.
Atoi
(
rs
[
1
])
}
if
strings
.
Contain
(
"列"
)
||
strings
.
Contain
(
"Col"
)
{
re
:=
regexp
.
MustCompile
(
`\d+`
)
rs
:=
re
.
FindAllString
(
out
.
String
(),
-
1
)
win
.
Col
,
_
=
strconv
.
Atoi
(
rs
[
1
])
}
}
return
win
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录