小编Jul*_*ina的帖子

如何检测 Expect 脚本中的超时

考虑一个期望脚本,它生成一个命令并等待一系列事件。我们用它来测试软件。当超时时,我总是试图从脚本中获取失败返回值。

spawn some-command

set timeout 10

expect "First message"
expect "Other message"
Run Code Online (Sandbox Code Playgroud)

即使超时,此脚本也始终返回 0(成功)。处理超时的唯一方法是将每个 Expect 语句转换为:

expect {
    timeout { exit 1 }
    eof     { exit 1 }
    "First message"
}
Run Code Online (Sandbox Code Playgroud)

但这很快就会变得笨拙。有任何简化吗?是否有一个期望选项会导致早期超时/ eof 致命错误?

automation automated-testing expect

7
推荐指数
1
解决办法
4116
查看次数

标签 统计

automated-testing ×1

automation ×1

expect ×1